eaglelandsonce commited on
Commit
b280ffb
1 Parent(s): 23e1297

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -39
app.py CHANGED
@@ -1,49 +1,24 @@
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.")
 
 
1
  import streamlit as st
2
+ import subprocess
3
+ import json
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  st.title('Math Problem Solver')
6
 
 
7
  api_key = st.text_input("Enter your API Key:")
8
  math_problem = st.text_input("Enter your math problem:")
9
 
 
10
  if st.button('Solve'):
11
  if api_key and math_problem:
12
+ input_data = {
13
+ "math_problem": math_problem,
14
+ "api_key": api_key
15
+ }
16
+
17
+ result = subprocess.check_output(
18
+ ["python", "query_solver.py"],
19
+ input=json.dumps(input_data),
20
+ text=True
21
+ )
22
+ st.write(result.strip())
23
  else:
24
+ st.write("Please provide both API key and math problem.")