Thiloid commited on
Commit
b0e7c6d
·
verified ·
1 Parent(s): 9ddd8bb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -24,8 +24,13 @@ collection = client.get_collection(name="chromatsc", embedding_function=sentence
24
  client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
25
 
26
 
 
27
  def format_prompt(message, history):
28
- prompt = f"[INST] {message} [/INST]"
 
 
 
 
29
  return prompt
30
 
31
 
@@ -47,9 +52,10 @@ def response(prompt, history, selected_option, temperature=0.9, max_new_tokens=5
47
  selected_option = "Die Nutzer Frage bezieht sich auf folgende Wahl-O-Mat These: " + selected_option
48
  queryprompt= prompt + " "+ selected_option
49
  addon = ""
50
- results = collection.query(
51
- query_texts=[queryprompt],
52
- n_results=60,
 
53
  )
54
  dists = ["<br><small>(relevance: " + str(round((1 - d) * 100) / 100) + ";" for d in results['distances'][0]]
55
  results = results['documents'][0]
 
24
  client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
25
 
26
 
27
+
28
  def format_prompt(message, history):
29
+ prompt = ""
30
+ if history:
31
+ user_prompt, bot_response = history[-1]
32
+ prompt += f"[INST] {user_prompt} [/INST] {bot_response}</s> "
33
+ prompt += f"[INST] {message} [/INST]"
34
  return prompt
35
 
36
 
 
52
  selected_option = "Die Nutzer Frage bezieht sich auf folgende Wahl-O-Mat These: " + selected_option
53
  queryprompt= prompt + " "+ selected_option
54
  addon = ""
55
+ search_prompt = format_prompt(prompt, history)
56
+ results=collection.query(
57
+ query_texts=[search_prompt],
58
+ n_results=60
59
  )
60
  dists = ["<br><small>(relevance: " + str(round((1 - d) * 100) / 100) + ";" for d in results['distances'][0]]
61
  results = results['documents'][0]