melk2025 commited on
Commit
f9dc10f
·
verified ·
1 Parent(s): 7da06a0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -136,10 +136,10 @@ def retrieve_from_rag(user_query, chat_history):
136
  # Combine history with current query
137
  #history_context = " ".join([f"User: {msg[0]} Bot: {msg[1]}" for msg in chat_history]) + " "
138
  #full_query = history_context + user_query
139
- full_query= user_query
140
  print("Searching in RAG with history context...")
141
 
142
- query_embedding = embedding_model.encode(full_query)
143
  results = collection.query(query_embeddings=[query_embedding], n_results=5) # Get top 5 first
144
 
145
  if not results or not results.get('documents'):
@@ -179,8 +179,7 @@ Instructions:
179
  - If the answer is not in the documents, simply say: "I don't know." / "Je ne sais pas."
180
  - Cite only the sources you use, indicated at the end of each document like (Source: https://example.com).
181
 
182
- Chat History:
183
- {history_text}
184
 
185
  Documents:
186
  {context}
@@ -191,7 +190,8 @@ Answer:
191
  """
192
  try:
193
  response = client1.chat.completions.create(
194
- model="mistralai/mistral-7b-instruct:free",
 
195
  messages=[{"role": "user", "content": prompt}]
196
  )
197
  return response.choices[0].message.content.strip()
 
136
  # Combine history with current query
137
  #history_context = " ".join([f"User: {msg[0]} Bot: {msg[1]}" for msg in chat_history]) + " "
138
  #full_query = history_context + user_query
139
+ #full_query= user_query
140
  print("Searching in RAG with history context...")
141
 
142
+ query_embedding = embedding_model.encode(user_query)
143
  results = collection.query(query_embeddings=[query_embedding], n_results=5) # Get top 5 first
144
 
145
  if not results or not results.get('documents'):
 
179
  - If the answer is not in the documents, simply say: "I don't know." / "Je ne sais pas."
180
  - Cite only the sources you use, indicated at the end of each document like (Source: https://example.com).
181
 
182
+
 
183
 
184
  Documents:
185
  {context}
 
190
  """
191
  try:
192
  response = client1.chat.completions.create(
193
+ # model="mistralai/mistral-7b-instruct:free",
194
+ model="mistralai/mistral-small-3.1-24b-instruct:free",
195
  messages=[{"role": "user", "content": prompt}]
196
  )
197
  return response.choices[0].message.content.strip()