-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from AllenNeuralDynamics/error_handling
efficiency improved + error handling
- Loading branch information
Showing
23 changed files
with
248 additions
and
3,078 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Import the Streamlit library | ||
import streamlit as st | ||
from metadata_chatbot.agents.GAMER import GAMER | ||
import asyncio | ||
|
||
#run on terminal with streamlit run <FILE PATH> [ARGUMENTS] | ||
|
||
async def main(): | ||
# Write a simple message to the app's webpage | ||
llm = GAMER() | ||
message = st.chat_message("assistant") | ||
message.write("Hello!") | ||
|
||
prompt = st.chat_input("Ask a question about the AIND Metadata!") | ||
|
||
if "messages" not in st.session_state: | ||
st.session_state.messages = [] | ||
|
||
for message in st.session_state.messages: | ||
with st.chat_message(message["role"]): | ||
st.markdown(message["content"]) | ||
|
||
if prompt: | ||
# Display user message in chat message container | ||
with st.chat_message("user"): | ||
st.markdown(prompt) | ||
# Add user message to chat history | ||
st.session_state.messages.append({"role": "user", "content": prompt}) | ||
response = await llm.ainvoke(prompt) | ||
|
||
with st.chat_message("assistant"): | ||
st.markdown(response) | ||
|
||
# Add assistant response to chat history | ||
st.session_state.messages.append({"role": "assistant", "content": response}) | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.run(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.