Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -47,7 +47,7 @@ if "search_tool" not in st.session_state:
|
|
| 47 |
serper_api_key=str(os.getenv('SERPER_API')))
|
| 48 |
|
| 49 |
|
| 50 |
-
def get_answer(
|
| 51 |
new_search_query = st.session_state.llm.invoke(
|
| 52 |
f"Convert below query to english for Ahmedabad Municipal Corporation (AMC) You just need to give translated query. Don't add any additional details.\n Query: {query}").content
|
| 53 |
search_result = st.session_state.search_tool.run(
|
|
@@ -56,10 +56,9 @@ def get_answer(conversation, query):
|
|
| 56 |
system_prompt = """You are a helpful assistance for The Ahmedabad Municipal Corporation (AMC). which asnwer user query from given context only. Output language should be as same as language of `original_query_from_user`.
|
| 57 |
context: {context}
|
| 58 |
original_query_from_user: {original_query}
|
| 59 |
-
history: {history}
|
| 60 |
query: {query}"""
|
| 61 |
|
| 62 |
-
return st.session_state.llm.invoke(system_prompt.format(context=search_result,
|
| 63 |
|
| 64 |
|
| 65 |
session_manager.set_session_state(st.session_state)
|
|
@@ -91,11 +90,11 @@ if prompt := st.chat_input("Enter your query here... "):
|
|
| 91 |
current_conversation = """"""
|
| 92 |
|
| 93 |
# if st.session_state.next_agent != "general_agent" and st.session_state.next_agent in st.session_state.agent_history:
|
| 94 |
-
for message in st.session_state.messages:
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
|
| 100 |
# current_conversation += f"""user: {prompt}\n"""
|
| 101 |
|
|
@@ -103,7 +102,7 @@ if prompt := st.chat_input("Enter your query here... "):
|
|
| 103 |
print("messages", current_conversation)
|
| 104 |
print()
|
| 105 |
print()
|
| 106 |
-
response = get_answer(
|
| 107 |
print("******************************************************** Response ********************************************************")
|
| 108 |
print("MY RESPONSE IS:", response)
|
| 109 |
|
|
|
|
| 47 |
serper_api_key=str(os.getenv('SERPER_API')))
|
| 48 |
|
| 49 |
|
| 50 |
+
def get_answer(query):
|
| 51 |
new_search_query = st.session_state.llm.invoke(
|
| 52 |
f"Convert below query to english for Ahmedabad Municipal Corporation (AMC) You just need to give translated query. Don't add any additional details.\n Query: {query}").content
|
| 53 |
search_result = st.session_state.search_tool.run(
|
|
|
|
| 56 |
system_prompt = """You are a helpful assistance for The Ahmedabad Municipal Corporation (AMC). which asnwer user query from given context only. Output language should be as same as language of `original_query_from_user`.
|
| 57 |
context: {context}
|
| 58 |
original_query_from_user: {original_query}
|
|
|
|
| 59 |
query: {query}"""
|
| 60 |
|
| 61 |
+
return st.session_state.llm.invoke(system_prompt.format(context=search_result, query=new_search_query, original_query=query)).content
|
| 62 |
|
| 63 |
|
| 64 |
session_manager.set_session_state(st.session_state)
|
|
|
|
| 90 |
current_conversation = """"""
|
| 91 |
|
| 92 |
# if st.session_state.next_agent != "general_agent" and st.session_state.next_agent in st.session_state.agent_history:
|
| 93 |
+
# for message in st.session_state.messages:
|
| 94 |
+
# if message['role'] == 'user':
|
| 95 |
+
# current_conversation += f"""user: {message['content']}\n"""
|
| 96 |
+
# if message['role'] == 'assistant':
|
| 97 |
+
# current_conversation += f"""ai: {message['content']}\n"""
|
| 98 |
|
| 99 |
# current_conversation += f"""user: {prompt}\n"""
|
| 100 |
|
|
|
|
| 102 |
print("messages", current_conversation)
|
| 103 |
print()
|
| 104 |
print()
|
| 105 |
+
response = get_answer(prompt)
|
| 106 |
print("******************************************************** Response ********************************************************")
|
| 107 |
print("MY RESPONSE IS:", response)
|
| 108 |
|