Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
CHANGED
|
@@ -91,25 +91,23 @@ def query_rag(question, store, client):
|
|
| 91 |
|
| 92 |
context = "\n\n".join([chunk for chunk, src, score in results])
|
| 93 |
|
| 94 |
-
|
| 95 |
If you don't know the answer from the context, say "I don't have that information in my profile."
|
| 96 |
|
| 97 |
Context:
|
| 98 |
-
{context}
|
| 99 |
-
|
| 100 |
-
Question: {question}
|
| 101 |
-
|
| 102 |
-
Answer:"""
|
| 103 |
|
| 104 |
try:
|
| 105 |
-
response = client.
|
| 106 |
-
|
|
|
|
|
|
|
|
|
|
| 107 |
model="mistralai/Mistral-7B-Instruct-v0.2",
|
| 108 |
-
|
| 109 |
temperature=0.3,
|
| 110 |
-
repetition_penalty=1.1
|
| 111 |
)
|
| 112 |
-
return response.strip()
|
| 113 |
except Exception as e:
|
| 114 |
return f"Error: {str(e)}"
|
| 115 |
|
|
|
|
| 91 |
|
| 92 |
context = "\n\n".join([chunk for chunk, src, score in results])
|
| 93 |
|
| 94 |
+
system_prompt = f"""You are an AI Twin that represents a person. Use ONLY the following context to answer the question.
|
| 95 |
If you don't know the answer from the context, say "I don't have that information in my profile."
|
| 96 |
|
| 97 |
Context:
|
| 98 |
+
{context}"""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
|
| 100 |
try:
|
| 101 |
+
response = client.chat_completion(
|
| 102 |
+
messages=[
|
| 103 |
+
{"role": "system", "content": system_prompt},
|
| 104 |
+
{"role": "user", "content": question}
|
| 105 |
+
],
|
| 106 |
model="mistralai/Mistral-7B-Instruct-v0.2",
|
| 107 |
+
max_tokens=512,
|
| 108 |
temperature=0.3,
|
|
|
|
| 109 |
)
|
| 110 |
+
return response.choices[0].message.content.strip()
|
| 111 |
except Exception as e:
|
| 112 |
return f"Error: {str(e)}"
|
| 113 |
|