Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import json
|
| 3 |
import google.generativeai as genai
|
|
@@ -5,7 +6,6 @@ import google.generativeai as genai
|
|
| 5 |
def add_to_json(goal):
|
| 6 |
"""
|
| 7 |
Adds a new goal to the "test.json" file, ensuring the JSON structure is correct.
|
| 8 |
-
|
| 9 |
Args:
|
| 10 |
goal (str): The goal text to be added.
|
| 11 |
"""
|
|
@@ -32,7 +32,7 @@ model = genai.GenerativeModel('gemini-pro')
|
|
| 32 |
|
| 33 |
def main():
|
| 34 |
"""
|
| 35 |
-
Main application logic. Handles user input, interaction with generative AI, and
|
| 36 |
"""
|
| 37 |
prompt = st.chat_input("Hi, how can I help you?")
|
| 38 |
if prompt:
|
|
@@ -45,6 +45,12 @@ def main():
|
|
| 45 |
|
| 46 |
add_to_json(goal)
|
| 47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
if __name__ == "__main__":
|
| 50 |
main()
|
|
|
|
| 1 |
+
|
| 2 |
import streamlit as st
|
| 3 |
import json
|
| 4 |
import google.generativeai as genai
|
|
|
|
| 6 |
def add_to_json(goal):
|
| 7 |
"""
|
| 8 |
Adds a new goal to the "test.json" file, ensuring the JSON structure is correct.
|
|
|
|
| 9 |
Args:
|
| 10 |
goal (str): The goal text to be added.
|
| 11 |
"""
|
|
|
|
| 32 |
|
| 33 |
def main():
|
| 34 |
"""
|
| 35 |
+
Main application logic. Handles user input, interaction with generative AI, data saving, and JSON display.
|
| 36 |
"""
|
| 37 |
prompt = st.chat_input("Hi, how can I help you?")
|
| 38 |
if prompt:
|
|
|
|
| 45 |
|
| 46 |
add_to_json(goal)
|
| 47 |
|
| 48 |
+
# Display JSON Data
|
| 49 |
+
if st.button("Show JSON Data"):
|
| 50 |
+
with open("test.json", "r") as file:
|
| 51 |
+
data = json.load(file)
|
| 52 |
+
st.json(data) # Streamlit's way to display JSON
|
| 53 |
+
|
| 54 |
|
| 55 |
if __name__ == "__main__":
|
| 56 |
main()
|