Spaces:
Runtime error
Runtime error
File size: 1,020 Bytes
85878a9 af79586 85878a9 af79586 d111a26 af79586 d111a26 af79586 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import json
import streamlit as st
from scrapegraphai.graphs import SearchGraph
st.title("AI Query Application")
query_prompt = st.text_input("Enter your AI query", value="List me all the attributes of 'cannabis strain'.")
if st.button("Fetch Data from AI"):
# Define the configuration for the graph based on user input
graph_config = {
"llm": {
"api_key": st.secrets["OPENAI_API_KEY"],
"model": "gpt-3.5-turbo",
"temperature": 0,
},
}
# Create the SearchGraph instance dynamically
search_graph = SearchGraph(prompt=query_prompt, config=graph_config)
try:
# Run the graph to fetch results
result = search_graph.run()
# Convert the result to a JSON string with indentation for better readability
output = json.dumps(result, indent=2)
# Display each line of the JSON output
st.text_area("Result", value=output, height=300)
except Exception as e:
st.error(f"An error occurred: {e}") |