|
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"): |
|
|
|
graph_config = { |
|
"llm": { |
|
"api_key": st.secrets["OPENAI_API_KEY"], |
|
"model": "gpt-3.5-turbo", |
|
"temperature": 0, |
|
}, |
|
} |
|
|
|
|
|
search_graph = SearchGraph(prompt=query_prompt, config=graph_config) |
|
|
|
try: |
|
|
|
result = search_graph.run() |
|
|
|
output = json.dumps(result, indent=2) |
|
|
|
st.text_area("Result", value=output, height=300) |
|
except Exception as e: |
|
st.error(f"An error occurred: {e}") |