Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,18 +3,18 @@ import json
|
|
| 3 |
import google.generativeai as genai
|
| 4 |
|
| 5 |
|
| 6 |
-
def add_to_json(goal):
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
new_item = {
|
| 11 |
-
|
| 12 |
-
# "reminder": new_reminder # Remove if not used
|
| 13 |
-
}
|
| 14 |
-
# data["goal"].append(new_item)
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
|
| 19 |
|
| 20 |
GOOGLE_API_KEY = "AIzaSyCUBaL7TdISL7lRuBy19_X0-OsZfgbIgEc"
|
|
@@ -24,7 +24,7 @@ model = genai.GenerativeModel('gemini-pro')
|
|
| 24 |
|
| 25 |
def main(): # Wrap main logic in a function
|
| 26 |
if prompt := st.chat_input("Hi, how can I help you?"):
|
| 27 |
-
|
| 28 |
|
| 29 |
goals_prompt = f"""Act as a personal assistant. Understand user intent from the point of view for asking a few questions. Ask to know more details about {goal} :- {goal}"""
|
| 30 |
completion = model.generate_content(goals_prompt)
|
|
|
|
| 3 |
import google.generativeai as genai
|
| 4 |
|
| 5 |
|
| 6 |
+
def add_to_json(goal):
|
| 7 |
+
try:
|
| 8 |
+
with open("test.json", "r") as file:
|
| 9 |
+
data = json.load(file)
|
| 10 |
+
except FileNotFoundError:
|
| 11 |
+
data = {"goals": []} # Create an empty "goals" list if the file doesn't exist
|
| 12 |
|
| 13 |
+
new_item = {"Goal": goal}
|
| 14 |
+
data["goals"].append(new_item)
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
+
with open("test.json", "w") as file:
|
| 17 |
+
json.dump(data, file, indent=4)
|
| 18 |
|
| 19 |
|
| 20 |
GOOGLE_API_KEY = "AIzaSyCUBaL7TdISL7lRuBy19_X0-OsZfgbIgEc"
|
|
|
|
| 24 |
|
| 25 |
def main(): # Wrap main logic in a function
|
| 26 |
if prompt := st.chat_input("Hi, how can I help you?"):
|
| 27 |
+
goals = prompt # Capture the user's goal
|
| 28 |
|
| 29 |
goals_prompt = f"""Act as a personal assistant. Understand user intent from the point of view for asking a few questions. Ask to know more details about {goal} :- {goal}"""
|
| 30 |
completion = model.generate_content(goals_prompt)
|