Update app.py
Browse files
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 =
|
|
|
|
|
|
|
|
|
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 |
-
|
51 |
-
|
52 |
-
|
|
|
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]
|