Spaces:
Sleeping
Sleeping
aasherkamal216 commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -37,12 +37,15 @@ if "messages" not in st.session_state:
|
|
| 37 |
]
|
| 38 |
|
| 39 |
for message in st.session_state.messages:
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
if api_key:
|
| 43 |
if prompt := st.chat_input("What is Generative AI?"):
|
| 44 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
| 45 |
-
st.chat_message("user").write(prompt)
|
| 46 |
|
| 47 |
llm = ChatGroq(model="llama-3.1-70b-versatile", api_key=api_key, streaming=True)
|
| 48 |
tools = [wiki_tool, arxiv_tool, search]
|
|
@@ -50,7 +53,7 @@ if api_key:
|
|
| 50 |
search_agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
|
| 51 |
agent_executor_kwargs={"handle_parsing_errors": True})
|
| 52 |
try:
|
| 53 |
-
with st.chat_message("assistant"):
|
| 54 |
st_callback = StreamlitCallbackHandler(st.container(), expand_new_thoughts=True)
|
| 55 |
response = search_agent.run(st.session_state.messages, callbacks=[st_callback])
|
| 56 |
st.write(response)
|
|
|
|
| 37 |
]
|
| 38 |
|
| 39 |
for message in st.session_state.messages:
|
| 40 |
+
if message["role"] == "user":
|
| 41 |
+
st.chat_message("user", avatar="boss.png").write(message['content'])
|
| 42 |
+
else:
|
| 43 |
+
st.chat_message("assistant", avatar="robot.png").write(message['content']
|
| 44 |
|
| 45 |
if api_key:
|
| 46 |
if prompt := st.chat_input("What is Generative AI?"):
|
| 47 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
| 48 |
+
st.chat_message("user", avatar="boss.png").write(prompt)
|
| 49 |
|
| 50 |
llm = ChatGroq(model="llama-3.1-70b-versatile", api_key=api_key, streaming=True)
|
| 51 |
tools = [wiki_tool, arxiv_tool, search]
|
|
|
|
| 53 |
search_agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
|
| 54 |
agent_executor_kwargs={"handle_parsing_errors": True})
|
| 55 |
try:
|
| 56 |
+
with st.chat_message("assistant", avatar="robot.png"):
|
| 57 |
st_callback = StreamlitCallbackHandler(st.container(), expand_new_thoughts=True)
|
| 58 |
response = search_agent.run(st.session_state.messages, callbacks=[st_callback])
|
| 59 |
st.write(response)
|