Update app.py
Browse files
app.py
CHANGED
|
@@ -83,7 +83,7 @@ agent = ToolCallingAgent(tools=[retriever_tool], model=HfApiModel(model))
|
|
| 83 |
def respond(message, history: list[tuple[str, str]], system_message, max_tokens, temperature, top_p, score,):
|
| 84 |
|
| 85 |
print(datetime.now())
|
| 86 |
-
context = retriever_tool(
|
| 87 |
|
| 88 |
prompt = f"""Given the question and supporting documents below, give a comprehensive answer to the question.
|
| 89 |
Respond only to the question asked, response should be concise and relevant to the question and answer in the same language as the question.
|
|
@@ -96,15 +96,13 @@ def respond(message, history: list[tuple[str, str]], system_message, max_tokens,
|
|
| 96 |
{context}
|
| 97 |
"""
|
| 98 |
|
| 99 |
-
messages = [{"role": "user", "content": prompt}]
|
| 100 |
-
|
| 101 |
for val in history:
|
| 102 |
if val[0]:
|
| 103 |
messages.append({"role": "user", "content": val[0]})
|
| 104 |
if val[1]:
|
| 105 |
messages.append({"role": "assistant", "content": val[1]})
|
| 106 |
|
| 107 |
-
messages.append({"role": "user", "content":
|
| 108 |
|
| 109 |
response = ""
|
| 110 |
|
|
@@ -117,8 +115,6 @@ def respond(message, history: list[tuple[str, str]], system_message, max_tokens,
|
|
| 117 |
):
|
| 118 |
token = message.choices[0].delta.content
|
| 119 |
|
| 120 |
-
# answer = client.chat_completion(messages, temperature=0.1).choices[0].message.content
|
| 121 |
-
|
| 122 |
response += token
|
| 123 |
yield response
|
| 124 |
|
|
|
|
| 83 |
def respond(message, history: list[tuple[str, str]], system_message, max_tokens, temperature, top_p, score,):
|
| 84 |
|
| 85 |
print(datetime.now())
|
| 86 |
+
context = retriever_tool(message)
|
| 87 |
|
| 88 |
prompt = f"""Given the question and supporting documents below, give a comprehensive answer to the question.
|
| 89 |
Respond only to the question asked, response should be concise and relevant to the question and answer in the same language as the question.
|
|
|
|
| 96 |
{context}
|
| 97 |
"""
|
| 98 |
|
|
|
|
|
|
|
| 99 |
for val in history:
|
| 100 |
if val[0]:
|
| 101 |
messages.append({"role": "user", "content": val[0]})
|
| 102 |
if val[1]:
|
| 103 |
messages.append({"role": "assistant", "content": val[1]})
|
| 104 |
|
| 105 |
+
messages.append({"role": "user", "content": prompt})
|
| 106 |
|
| 107 |
response = ""
|
| 108 |
|
|
|
|
| 115 |
):
|
| 116 |
token = message.choices[0].delta.content
|
| 117 |
|
|
|
|
|
|
|
| 118 |
response += token
|
| 119 |
yield response
|
| 120 |
|