Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
| 1 |
|
| 2 |
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import json
|
| 3 |
+
import google.generativeai as genai
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def add_to_json(new_data):
|
| 11 |
+
with open("test.json", "r") as file:
|
| 12 |
+
existing_data = json.load(file)
|
| 13 |
+
|
| 14 |
+
# Assuming you want to add 'new_goal' and 'reminder' into existing_data
|
| 15 |
+
existing_data.update(new_data)
|
| 16 |
+
|
| 17 |
+
with open("test.json", "w") as file:
|
| 18 |
+
json.dump(existing_data, file, indent=4)
|
| 19 |
+
|
| 20 |
+
# Usage:
|
| 21 |
+
new_data = {
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
"goal": "userinput ",
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
# st.button("Save",on_click=add_to_json)
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
GOOGLE_API_KEY="AIzaSyCUBaL7TdISL7lRuBy19_X0-OsZfgbIgEc"
|
| 37 |
+
|
| 38 |
+
genai.configure(api_key=GOOGLE_API_KEY)
|
| 39 |
+
|
| 40 |
+
model = genai.GenerativeModel('gemini-pro')
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
if userinput := st.chat_input("Hi"):
|
| 44 |
+
newuserinput = f"""
|
| 45 |
+
Act as a personal assistant, Understand users intent and tell user their intent while also motivating for setting goals from this input = {userinput}"""
|
| 46 |
+
completetion = model.generate_content(enprom)
|
| 47 |
+
with st.chat_message("Assistant"):
|
| 48 |
+
st.write(completetion.text)
|
| 49 |
+
|
| 50 |
+
|