Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -16,7 +16,7 @@ from datetime import datetime
|
|
16 |
|
17 |
#model_config = getconfig("model_params.cfg")
|
18 |
###########
|
19 |
-
# ToDo move to
|
20 |
# Configuration for the dedicated model
|
21 |
DEDICATED_MODEL = "meta-llama/Llama-3.1-8B-Instruct"
|
22 |
DEDICATED_ENDPOINT = "https://qu2d8m6dmsollhly.us-east-1.aws.endpoints.huggingface.cloud"
|
@@ -29,7 +29,8 @@ def get_rag_answer(query, top_results):
|
|
29 |
if len(context) > max_context_chars:
|
30 |
context = context[:max_context_chars]
|
31 |
prompt = (
|
32 |
-
"
|
|
|
33 |
"Only output the final answer below, without repeating the context or question.\n\n"
|
34 |
f"Context:\n{context}\n\n"
|
35 |
f"Question: {query}\n\n"
|
@@ -38,7 +39,7 @@ def get_rag_answer(query, top_results):
|
|
38 |
headers = {"Authorization": f"Bearer {WRITE_ACCESS_TOKEN}"}
|
39 |
payload = {
|
40 |
"inputs": prompt,
|
41 |
-
"parameters": {"max_new_tokens":
|
42 |
}
|
43 |
response = requests.post(DEDICATED_ENDPOINT, headers=headers, json=payload)
|
44 |
if response.status_code == 200:
|
@@ -78,7 +79,12 @@ def get_crs_options(_client, collection_name):
|
|
78 |
crs_key = metadata.get("crs_key", "").strip()
|
79 |
crs_value = metadata.get("crs_value", "").strip()
|
80 |
if crs_key or crs_value:
|
81 |
-
|
|
|
|
|
|
|
|
|
|
|
82 |
crs_set.add(crs_combined)
|
83 |
return sorted(crs_set)
|
84 |
|
|
|
16 |
|
17 |
#model_config = getconfig("model_params.cfg")
|
18 |
###########
|
19 |
+
# ToDo move functions to utils and model specifications to config file!
|
20 |
# Configuration for the dedicated model
|
21 |
DEDICATED_MODEL = "meta-llama/Llama-3.1-8B-Instruct"
|
22 |
DEDICATED_ENDPOINT = "https://qu2d8m6dmsollhly.us-east-1.aws.endpoints.huggingface.cloud"
|
|
|
29 |
if len(context) > max_context_chars:
|
30 |
context = context[:max_context_chars]
|
31 |
prompt = (
|
32 |
+
"You are a project portfolio adviser at the development cooperation GIZ. "
|
33 |
+
"Using the following context, answer the question precisely. "
|
34 |
"Only output the final answer below, without repeating the context or question.\n\n"
|
35 |
f"Context:\n{context}\n\n"
|
36 |
f"Question: {query}\n\n"
|
|
|
39 |
headers = {"Authorization": f"Bearer {WRITE_ACCESS_TOKEN}"}
|
40 |
payload = {
|
41 |
"inputs": prompt,
|
42 |
+
"parameters": {"max_new_tokens": 200}
|
43 |
}
|
44 |
response = requests.post(DEDICATED_ENDPOINT, headers=headers, json=payload)
|
45 |
if response.status_code == 200:
|
|
|
79 |
crs_key = metadata.get("crs_key", "").strip()
|
80 |
crs_value = metadata.get("crs_value", "").strip()
|
81 |
if crs_key or crs_value:
|
82 |
+
# Convert crs_value to integer if possible:
|
83 |
+
try:
|
84 |
+
crs_int = int(float(crs_value))
|
85 |
+
except:
|
86 |
+
crs_int = crs_value
|
87 |
+
crs_combined = f"{crs_key}: {crs_int}"
|
88 |
crs_set.add(crs_combined)
|
89 |
return sorted(crs_set)
|
90 |
|