Spaces:
Runtime error
Runtime error
eaglelandsonce
commited on
Commit
•
86f6634
1
Parent(s):
db8257a
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Import necessary libraries
|
2 |
+
import streamlit as st
|
3 |
+
import autogen
|
4 |
+
from autogen.agentchat.contrib.math_user_proxy_agent import MathUserProxyAgent
|
5 |
+
|
6 |
+
# Function to run the query
|
7 |
+
def run_query(math_problem, api_key):
|
8 |
+
config_list = [
|
9 |
+
{
|
10 |
+
'model': 'gpt-3.5-turbo',
|
11 |
+
'api_key': api_key,
|
12 |
+
},
|
13 |
+
]
|
14 |
+
|
15 |
+
autogen.ChatCompletion.start_logging()
|
16 |
+
|
17 |
+
assistant = autogen.AssistantAgent(
|
18 |
+
name="assistant",
|
19 |
+
system_message="You are a helpful assistant.",
|
20 |
+
llm_config={
|
21 |
+
"request_timeout": 600,
|
22 |
+
"seed": 42,
|
23 |
+
"config_list": config_list,
|
24 |
+
}
|
25 |
+
)
|
26 |
+
|
27 |
+
mathproxyagent = MathUserProxyAgent(
|
28 |
+
name="mathproxyagent",
|
29 |
+
human_input_mode="NEVER",
|
30 |
+
code_execution_config={"use_docker": False},
|
31 |
+
)
|
32 |
+
|
33 |
+
return mathproxyagent.initiate_chat(assistant, problem=math_problem)
|
34 |
+
|
35 |
+
|
36 |
+
# Streamlit app
|
37 |
+
st.title('Math Problem Solver')
|
38 |
+
|
39 |
+
# Input fields for API key and math problem
|
40 |
+
api_key = st.text_input("Enter your API Key:")
|
41 |
+
math_problem = st.text_input("Enter your math problem:")
|
42 |
+
|
43 |
+
# When the button is pressed, call run_query and display the result
|
44 |
+
if st.button('Solve'):
|
45 |
+
if api_key and math_problem:
|
46 |
+
result = run_query(math_problem, api_key)
|
47 |
+
st.write(result)
|
48 |
+
else:
|
49 |
+
st.write("Please provide both API key and math problem.")
|