Spaces:
Runtime error
Runtime error
ENH: Update the contextualize question
Browse files
openai_prompts/contextualize.py
CHANGED
@@ -5,7 +5,11 @@ import openai
|
|
5 |
functions = [
|
6 |
{
|
7 |
"name": "with_context",
|
8 |
-
"description":
|
|
|
|
|
|
|
|
|
9 |
"parameters": {
|
10 |
"type": "object",
|
11 |
"properties": {
|
@@ -23,7 +27,7 @@ functions = [
|
|
23 |
def contextualize_question(user_query: str, messages: list[str]):
|
24 |
prompt = (
|
25 |
f"The user said: {user_query}\n\n"
|
26 |
-
"If the user is asking a question, make sure you contextualize it using the replies exchanged before, add details to the question.\n"
|
27 |
"The previous messages are:\n"
|
28 |
)
|
29 |
|
@@ -42,7 +46,7 @@ def contextualize_question(user_query: str, messages: list[str]):
|
|
42 |
],
|
43 |
functions=functions,
|
44 |
function_call={"name": "with_context"}, # force the function to be called
|
45 |
-
temperature=0.
|
46 |
)
|
47 |
|
48 |
try:
|
@@ -53,4 +57,4 @@ def contextualize_question(user_query: str, messages: list[str]):
|
|
53 |
return result_data["contextualized_question"]
|
54 |
except Exception as error:
|
55 |
print(error)
|
56 |
-
return
|
|
|
5 |
functions = [
|
6 |
{
|
7 |
"name": "with_context",
|
8 |
+
"description": (
|
9 |
+
"Writes the question in a more verbose way by filling in missing data from the conversation, to make it more clear"
|
10 |
+
", imagine you are a third person that just got in on the conversation and heard only the last question. Make it easier to understand what it is about."
|
11 |
+
"Replace words like 'there' with the actual location, 'that' with the actual subject, 'it' with the actual object, etc."
|
12 |
+
),
|
13 |
"parameters": {
|
14 |
"type": "object",
|
15 |
"properties": {
|
|
|
27 |
def contextualize_question(user_query: str, messages: list[str]):
|
28 |
prompt = (
|
29 |
f"The user said: {user_query}\n\n"
|
30 |
+
"If the user is asking a question, make sure you contextualize it using the replies exchanged before, add relevant details to the question.\n"
|
31 |
"The previous messages are:\n"
|
32 |
)
|
33 |
|
|
|
46 |
],
|
47 |
functions=functions,
|
48 |
function_call={"name": "with_context"}, # force the function to be called
|
49 |
+
temperature=0.1,
|
50 |
)
|
51 |
|
52 |
try:
|
|
|
57 |
return result_data["contextualized_question"]
|
58 |
except Exception as error:
|
59 |
print(error)
|
60 |
+
return user_query
|