Skip to content

Commit c51c472

Browse files
pjoshi30Preetam Joshi
andauthored
Moving the IA text box back to the top of the page. (#32)
* Initial commit Adding the Aimon Rely README, images, the postman collection, a simple client and examples. A few small changes for error handling in the client and the example application. Getting the Aimon API key from the streamlit app updating README Updating langchain example gif Updating API endpoint Adding V2 API with support for conciseness, completeness and toxicity checks (#1) * Adding V2 API with support for conciseness, completeness and toxicity checks. * Removing prints and updating config for the example application. * Updating README --------- Co-authored-by: Preetam Joshi <info@aimon.ai> Updating postman collection Fixed the simple aimon client's handling of batch requests. Updated postman collection. Added support for a user_query parameter in the input data dictionary. Updating readme Fixed bug in the example app Uploading client code Adding more convenience APIs Fixing bug in create_dataset Added Github actions config to publish to PyPI. Cleaned up dependencies and updated documentation. Fixing langchain example Fixing doc links Formatting changes Changes for aimon-rely * Adding instruction adherence and hallucination v0.2 to the client Updating git ignore Adding more to gitignore Removing .idea files * Fixing doc string * Updating documentation * Updating Client to use V3 API * Fixing test * Updating tests * Updating documentation in the client * Adding .streamlit dir to .gitignore * initial version of decorators for syntactic sugar * A few more changes * updating analyze and detect decorators * Adding new notebooks * Fixing bug in analyze decorator * Updating Detect decorator to make it simpler. Adding Metaflow example. Adding documentation for the chatbot. * fixing chatbot example * Fixed issue in detect decorator. Improved code organization. * fixed typo * Updated the decorators with a more cleaner interface. Added a metaflow analyze example. * Updated version * Updated Notebook * Fixing context parsing issue with analyze_eval decorator * Updating application to production in the analyze_prod decorator * Updating SDK to handle instructions in evaluation and continuous monitoring. * Deleting old notebook * Fixing usability issues in the chatbot. Organizing examples a bit better. * Adding analyze to the chatbot * Fixing readme and adding instruction bar at the bottom * Reverting the IA text box to be back on the top of the page * Moving the IA text box back to the top of the page. --------- Co-authored-by: Preetam Joshi <info@aimon.ai>
1 parent d8a6415 commit c51c472

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

examples/streamlit_apps/chatbot/aimon_chatbot_demo.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ def execute():
101101
openai_api_key = os.getenv("OPENAI_API_KEY")
102102

103103
openai.api_key = openai_api_key
104+
instructions = st.text_input(
105+
"Instructions for the chatbot. Ex: Answer the user's question in a professional tone.",
106+
value="Answer the user's question in a professional tone."
107+
)
104108
st.title("Ask questions on Paul Graham's Work Experience")
105109

106110
if "messages" not in st.session_state.keys(): # Initialize the chat messages history
@@ -123,7 +127,7 @@ def execute():
123127
"Here are the relevant documents for the context:\n"
124128
"{context_str}"
125129
"\nInstruction: Use the previous chat history, or the context above, to interact and help the user. " +
126-
"{}".format(st.session_state.instructions if "instructions" in st.session_state else "Answer the user's question in a professional tone.")
130+
"{}".format(instructions if instructions else "")
127131
),
128132
verbose=False,
129133
similarity_top_k=4,
@@ -132,23 +136,18 @@ def execute():
132136
if cprompt := st.chat_input("Example: Where did Paul Graham Work?"):
133137
st.session_state.messages.append({"role": "user", "content": cprompt})
134138

135-
136139
for message in st.session_state.messages: # Write message history to UI
137140
with st.chat_message(message["role"]):
138141
st.write(message["content"])
139142
if "aimon_response" in message:
140143
combined_json = {"AIMon Response": message["aimon_response"], "context": message["context"]}
141144
st.json(combined_json, expanded=False)
142-
143-
instructions = st.text_input("Instructions for the chatbot",
144-
value=st.session_state.instructions if "instructions" in st.session_state else "Answer the user's question in a professional tone.")
145-
st.session_state.instructions = instructions if instructions else "Answer the user's question in a professional tone."
146145

147146
# If last message is not from assistant, generate a new response
148147
if st.session_state.messages[-1]["role"] != "assistant":
149148
with st.chat_message("assistant"):
150149
if cprompt:
151-
context, usr_prompt, instructions, response, am_res, am_analyze_res = am_chat(cprompt, st.session_state.instructions if "instructions" in st.session_state else "Answer the user's question in a professional tone.")
150+
context, usr_prompt, instructions, response, am_res, am_analyze_res = am_chat(cprompt, instructions)
152151
message = {"role": "assistant", "content": response}
153152
am_res_json = am_res.to_json()
154153
st.write(response)
@@ -158,11 +157,6 @@ def execute():
158157
message.update({'aimon_response': am_res_json, 'context': {"text": context}})
159158
# Add response to message history
160159
st.session_state.messages.append(message)
161-
instructions = st.text_input(
162-
"Instructions for the chatbot. Ex: Answer the user's question in a professional tone.",
163-
value="Answer the user's question in a professional tone." if "instructions" not in st.session_state else st.session_state.instructions
164-
)
165-
st.session_state.instructions = instructions
166160

167161

168162
try:

0 commit comments

Comments
 (0)