Spaces:
Sleeping
Sleeping
prompt adjusted
Browse files
app.py
CHANGED
|
@@ -72,7 +72,7 @@ def llm_expand_query(query):
|
|
| 72 |
""" Expands a query to variations of fulltext searches """
|
| 73 |
|
| 74 |
response = client.chat.completions.create(
|
| 75 |
-
model="gpt-4o",
|
| 76 |
messages=[
|
| 77 |
{
|
| 78 |
"role": "user",
|
|
@@ -108,7 +108,7 @@ def llm_expand_query(query):
|
|
| 108 |
response_format={
|
| 109 |
"type": "text"
|
| 110 |
},
|
| 111 |
-
temperature=
|
| 112 |
max_tokens=2048,
|
| 113 |
top_p=1,
|
| 114 |
frequency_penalty=0,
|
|
@@ -121,7 +121,7 @@ def llm_generate_answer(prompt):
|
|
| 121 |
""" Generate a response from the LLM """
|
| 122 |
|
| 123 |
response = client.chat.completions.create(
|
| 124 |
-
model="gpt-4o",
|
| 125 |
messages=[
|
| 126 |
{
|
| 127 |
"role": "system",
|
|
@@ -131,12 +131,13 @@ def llm_generate_answer(prompt):
|
|
| 131 |
"text": """You are part of a Retrieval Augmented Generation system
|
| 132 |
(RAG) and are asked with a query and a context of results. Generate an
|
| 133 |
answer substantiated by the results provided and citing them using
|
| 134 |
-
their index when used to provide an answer text. Do not
|
| 135 |
-
|
|
|
|
| 136 |
search result. End the answer with the query and a brief answer as
|
| 137 |
summary of the previous discussed results. Do not consider results
|
| 138 |
-
that are not related to the query and, if no
|
| 139 |
-
provided,
|
| 140 |
}
|
| 141 |
]
|
| 142 |
},
|
|
@@ -153,7 +154,7 @@ def llm_generate_answer(prompt):
|
|
| 153 |
response_format={
|
| 154 |
"type": "text"
|
| 155 |
},
|
| 156 |
-
temperature=
|
| 157 |
max_tokens=2048,
|
| 158 |
top_p=1,
|
| 159 |
frequency_penalty=0,
|
|
@@ -185,7 +186,7 @@ def clean_refs(answer, results):
|
|
| 185 |
|
| 186 |
new_i = 1
|
| 187 |
for i in unique_ordered:
|
| 188 |
-
answer = answer.replace(f"[{i}]", f"[
|
| 189 |
new_i += 1
|
| 190 |
answer = answer.replace("__NEW_REF_ID_", "")
|
| 191 |
|
|
|
|
| 72 |
""" Expands a query to variations of fulltext searches """
|
| 73 |
|
| 74 |
response = client.chat.completions.create(
|
| 75 |
+
model="gpt-4o-mini",
|
| 76 |
messages=[
|
| 77 |
{
|
| 78 |
"role": "user",
|
|
|
|
| 108 |
response_format={
|
| 109 |
"type": "text"
|
| 110 |
},
|
| 111 |
+
temperature=0,
|
| 112 |
max_tokens=2048,
|
| 113 |
top_p=1,
|
| 114 |
frequency_penalty=0,
|
|
|
|
| 121 |
""" Generate a response from the LLM """
|
| 122 |
|
| 123 |
response = client.chat.completions.create(
|
| 124 |
+
model="gpt-4o-mini",
|
| 125 |
messages=[
|
| 126 |
{
|
| 127 |
"role": "system",
|
|
|
|
| 131 |
"text": """You are part of a Retrieval Augmented Generation system
|
| 132 |
(RAG) and are asked with a query and a context of results. Generate an
|
| 133 |
answer substantiated by the results provided and citing them using
|
| 134 |
+
their index when used to provide an answer text. Do not put two or more
|
| 135 |
+
references together (ex: use [1][2] instead of [1,2]. Do not generate an answer
|
| 136 |
+
that cannot be entailed from cited abstract, so all paragraphs should cite a
|
| 137 |
search result. End the answer with the query and a brief answer as
|
| 138 |
summary of the previous discussed results. Do not consider results
|
| 139 |
+
that are not related to the query and, if no specific answer can be
|
| 140 |
+
provided, assert that in the brief answer."""
|
| 141 |
}
|
| 142 |
]
|
| 143 |
},
|
|
|
|
| 154 |
response_format={
|
| 155 |
"type": "text"
|
| 156 |
},
|
| 157 |
+
temperature=0,
|
| 158 |
max_tokens=2048,
|
| 159 |
top_p=1,
|
| 160 |
frequency_penalty=0,
|
|
|
|
| 186 |
|
| 187 |
new_i = 1
|
| 188 |
for i in unique_ordered:
|
| 189 |
+
answer = answer.replace(f"[{i}]", f"**[__NEW_REF_ID_{new_i}]**")
|
| 190 |
new_i += 1
|
| 191 |
answer = answer.replace("__NEW_REF_ID_", "")
|
| 192 |
|