Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -55,13 +55,13 @@ def preprocess_response(response: str) -> str:
|
|
| 55 |
response = response.replace(" ,", ",")
|
| 56 |
response = response.replace(" .", ".")
|
| 57 |
response = " ".join(response.split())
|
| 58 |
-
if not any(word in response.lower() for word in ["
|
| 59 |
response = "I'm here to help. " + response
|
| 60 |
return response
|
| 61 |
|
| 62 |
def shorten_response(response: str) -> str:
|
| 63 |
"""Uses the Zephyr model to shorten and refine the response."""
|
| 64 |
-
messages = [{"role": "system", "content": "Greet, Shorten and refine this response
|
| 65 |
result = client.chat_completion(messages, max_tokens=512, temperature=0.5, top_p=0.9)
|
| 66 |
return result.choices[0].message['content'].strip()
|
| 67 |
|
|
@@ -78,7 +78,7 @@ def respond(message: str, history: List[Tuple[str, str]]):
|
|
| 78 |
messages.append({"role": "user", "content": message})
|
| 79 |
|
| 80 |
# RAG - Retrieve relevant documents if the query suggests exercises or specific information
|
| 81 |
-
if any(keyword in message.lower() for keyword in ["exercise", "technique", "information", "guide", "help", "how to"]):
|
| 82 |
retrieved_docs = app.search_documents(message)
|
| 83 |
context = "\n".join(retrieved_docs)
|
| 84 |
if context.strip():
|
|
|
|
| 55 |
response = response.replace(" ,", ",")
|
| 56 |
response = response.replace(" .", ".")
|
| 57 |
response = " ".join(response.split())
|
| 58 |
+
if not any(word in response.lower() for word in ["Capa Complaints"]):
|
| 59 |
response = "I'm here to help. " + response
|
| 60 |
return response
|
| 61 |
|
| 62 |
def shorten_response(response: str) -> str:
|
| 63 |
"""Uses the Zephyr model to shorten and refine the response."""
|
| 64 |
+
messages = [{"role": "system", "content": "Greet, Shorten and refine this response"}, {"role": "user", "content": response}]
|
| 65 |
result = client.chat_completion(messages, max_tokens=512, temperature=0.5, top_p=0.9)
|
| 66 |
return result.choices[0].message['content'].strip()
|
| 67 |
|
|
|
|
| 78 |
messages.append({"role": "user", "content": message})
|
| 79 |
|
| 80 |
# RAG - Retrieve relevant documents if the query suggests exercises or specific information
|
| 81 |
+
if any(keyword in message.lower() for keyword in ["exercise", "technique", "information", "guide", "help", "how to", "tell me", "find","which"]):
|
| 82 |
retrieved_docs = app.search_documents(message)
|
| 83 |
context = "\n".join(retrieved_docs)
|
| 84 |
if context.strip():
|