36 lines
1.0 KiB
Python
36 lines
1.0 KiB
Python
|
|
import streamlit as st
|
|
from agent_util import config_agent, configure_llm
|
|
|
|
# Streamlit Application Interface
|
|
st.sidebar.header("Configure LLM")
|
|
st.title("CEC Seller Assistant")
|
|
# Model Selection
|
|
model_options = ["llama3.2"]
|
|
selected_model = st.sidebar.selectbox(
|
|
"Choose the LLM Model", options=model_options, index=0)
|
|
|
|
# Temperature Setting
|
|
temperature = st.sidebar.slider(
|
|
"Set the Temperature", min_value=0.0, max_value=1.0, value=0.5, step=0.1)
|
|
|
|
llama3, llama3_json = configure_llm(selected_model, temperature)
|
|
|
|
local_agent = config_agent(llama3, llama3_json)
|
|
|
|
|
|
def run_agent(query):
|
|
config = {"configurable": {"thread_id": "1", "user_id": "1"}}
|
|
output = local_agent.invoke({"question": [query]}, config)
|
|
print(list(local_agent.get_state_history(config)))
|
|
# output = local_agent.invoke({"question": ['hi, my name is cz', query]})
|
|
print("=======")
|
|
return output["generation"]
|
|
|
|
|
|
user_query = st.text_input("Enter your research question:", "")
|
|
|
|
if st.button("Run Query"):
|
|
if user_query:
|
|
st.write(run_agent(user_query))
|