Spaces:
Runtime error
Runtime error
Commit ·
4dfe7c0
1
Parent(s): 683c56e
prompts change
Browse files- app_one.py +11 -9
app_one.py
CHANGED
|
@@ -44,11 +44,14 @@ from uuid import uuid4
|
|
| 44 |
#os.environ["LANGCHAIN_API_KEY"] = getpass.getpass("LangSmith_API_Key: ")
|
| 45 |
|
| 46 |
# PROMPTS IN USE
|
| 47 |
-
duckduckgo_description = "Useful for when you need to answer questions about aml."
|
| 48 |
|
| 49 |
-
aml_act_retriever_description = "Searches and returns
|
| 50 |
|
| 51 |
-
agent_prompt = "
|
|
|
|
|
|
|
|
|
|
| 52 |
# If the question is not about aml answer with: I don't know.
|
| 53 |
|
| 54 |
|
|
@@ -75,7 +78,7 @@ retreiver_tool = create_retriever_tool(
|
|
| 75 |
)
|
| 76 |
|
| 77 |
tool_belt = [DuckDuckGoSearchRun(description=duckduckgo_description +
|
| 78 |
-
"Input should be a search query."), retreiver_tool]
|
| 79 |
|
| 80 |
tool_executor = ToolExecutor(tool_belt)
|
| 81 |
|
|
@@ -163,25 +166,24 @@ def print_messages(messages):
|
|
| 163 |
@cl.on_chat_start
|
| 164 |
async def on_chat_start():
|
| 165 |
|
| 166 |
-
runnable =
|
| 167 |
|
| 168 |
cl.user_session.set("runnable", runnable)
|
| 169 |
|
| 170 |
|
| 171 |
@cl.on_message
|
| 172 |
async def on_message(message: cl.Message):
|
| 173 |
-
|
| 174 |
-
|
| 175 |
|
| 176 |
input_message = HumanMessage(content=(agent_prompt + message.content))
|
| 177 |
|
| 178 |
-
response =
|
| 179 |
|
| 180 |
await cl.Message(
|
| 181 |
content=response["messages"][-1].content).send()
|
| 182 |
|
| 183 |
print_messages(response)
|
| 184 |
|
| 185 |
-
print("Answer content----------", response["messages"][-1].content)
|
| 186 |
|
| 187 |
|
|
|
|
| 44 |
#os.environ["LANGCHAIN_API_KEY"] = getpass.getpass("LangSmith_API_Key: ")
|
| 45 |
|
| 46 |
# PROMPTS IN USE
|
| 47 |
+
duckduckgo_description = "Useful for when you need to answer questions about aml. "
|
| 48 |
|
| 49 |
+
aml_act_retriever_description = "Searches and returns information from the aml act in Australia."
|
| 50 |
|
| 51 |
+
agent_prompt = """ When asked about Anti Money Laundering use the retriever tool.
|
| 52 |
+
If the information is not there make DuckDuckGo searches and add this text to the query: site:austrac.gov.au
|
| 53 |
+
|
| 54 |
+
Answer the follow question: """
|
| 55 |
# If the question is not about aml answer with: I don't know.
|
| 56 |
|
| 57 |
|
|
|
|
| 78 |
)
|
| 79 |
|
| 80 |
tool_belt = [DuckDuckGoSearchRun(description=duckduckgo_description +
|
| 81 |
+
" Input should be a search query."), retreiver_tool]
|
| 82 |
|
| 83 |
tool_executor = ToolExecutor(tool_belt)
|
| 84 |
|
|
|
|
| 166 |
@cl.on_chat_start
|
| 167 |
async def on_chat_start():
|
| 168 |
|
| 169 |
+
runnable = app #| output_parser # | StrOutputParser()
|
| 170 |
|
| 171 |
cl.user_session.set("runnable", runnable)
|
| 172 |
|
| 173 |
|
| 174 |
@cl.on_message
|
| 175 |
async def on_message(message: cl.Message):
|
| 176 |
+
|
| 177 |
+
runnable = cl.user_session.get("runnable")
|
| 178 |
|
| 179 |
input_message = HumanMessage(content=(agent_prompt + message.content))
|
| 180 |
|
| 181 |
+
response = runnable.invoke({"messages": [input_message]})
|
| 182 |
|
| 183 |
await cl.Message(
|
| 184 |
content=response["messages"][-1].content).send()
|
| 185 |
|
| 186 |
print_messages(response)
|
| 187 |
|
|
|
|
| 188 |
|
| 189 |
|