File size: 1,351 Bytes
86f6634
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Import necessary libraries
import streamlit as st
import autogen
from autogen.agentchat.contrib.math_user_proxy_agent import MathUserProxyAgent

# Function to run the query
def run_query(math_problem, api_key):
    config_list = [
        {
            'model': 'gpt-3.5-turbo',
            'api_key': api_key,
        },
    ]

    autogen.ChatCompletion.start_logging()

    assistant = autogen.AssistantAgent(
        name="assistant",
        system_message="You are a helpful assistant.",
        llm_config={
            "request_timeout": 600,
            "seed": 42,
            "config_list": config_list,
        }
    )

    mathproxyagent = MathUserProxyAgent(
        name="mathproxyagent",
        human_input_mode="NEVER",
        code_execution_config={"use_docker": False},
    )

    return mathproxyagent.initiate_chat(assistant, problem=math_problem)
   

# Streamlit app
st.title('Math Problem Solver')

# Input fields for API key and math problem
api_key = st.text_input("Enter your API Key:")
math_problem = st.text_input("Enter your math problem:")

# When the button is pressed, call run_query and display the result
if st.button('Solve'):
    if api_key and math_problem:
        result = run_query(math_problem, api_key)
        st.write(result)
    else:
        st.write("Please provide both API key and math problem.")