Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import google.generativeai as
|
| 2 |
import gradio as gr
|
| 3 |
import os
|
| 4 |
import json
|
|
@@ -8,7 +8,11 @@ import uuid
|
|
| 8 |
import re
|
| 9 |
|
| 10 |
# Set your API key
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
# Select the PaLM 2 model
|
| 14 |
# model = 'models/text-bison-001'
|
|
@@ -57,8 +61,8 @@ def responsenew(data):
|
|
| 57 |
print(text)
|
| 58 |
except json.JSONDecodeError as e:
|
| 59 |
print("Invalid JSON:", e)
|
| 60 |
-
response =
|
| 61 |
-
print(f"\n{response.
|
| 62 |
if text is not None:
|
| 63 |
if "remind me" in text:
|
| 64 |
values = getValues(text)
|
|
@@ -231,7 +235,7 @@ def responsenew(data):
|
|
| 231 |
}
|
| 232 |
else:
|
| 233 |
respo = {
|
| 234 |
-
"message": response.
|
| 235 |
"action": "nothing",
|
| 236 |
"function": "nothing",
|
| 237 |
}
|
|
|
|
| 1 |
+
import google.generativeai as genai
|
| 2 |
import gradio as gr
|
| 3 |
import os
|
| 4 |
import json
|
|
|
|
| 8 |
import re
|
| 9 |
|
| 10 |
# Set your API key
|
| 11 |
+
# Or use `os.getenv('GOOGLE_API_KEY')` to fetch an environment variable.
|
| 12 |
+
GOOGLE_API_KEY=userdata.get('GEMINI_KEY')
|
| 13 |
+
|
| 14 |
+
genai.configure(api_key=GOOGLE_API_KEY)
|
| 15 |
+
model = genai.GenerativeModel('gemini-pro')
|
| 16 |
|
| 17 |
# Select the PaLM 2 model
|
| 18 |
# model = 'models/text-bison-001'
|
|
|
|
| 61 |
print(text)
|
| 62 |
except json.JSONDecodeError as e:
|
| 63 |
print("Invalid JSON:", e)
|
| 64 |
+
response = model.generate_content( text)
|
| 65 |
+
print(f"\n{response.text}")
|
| 66 |
if text is not None:
|
| 67 |
if "remind me" in text:
|
| 68 |
values = getValues(text)
|
|
|
|
| 235 |
}
|
| 236 |
else:
|
| 237 |
respo = {
|
| 238 |
+
"message": response.text,
|
| 239 |
"action": "nothing",
|
| 240 |
"function": "nothing",
|
| 241 |
}
|