File tree 2 files changed +4
-3
lines changed
2 files changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ def build_search_function() -> list[ChatCompletionToolParam]:
56
56
]
57
57
58
58
59
- def extract_search_arguments (chat_completion : ChatCompletion ):
59
+ def extract_search_arguments (original_user_query : str , chat_completion : ChatCompletion ):
60
60
response_message = chat_completion .choices [0 ].message
61
61
search_query = None
62
62
filters = []
@@ -67,7 +67,8 @@ def extract_search_arguments(chat_completion: ChatCompletion):
67
67
function = tool .function
68
68
if function .name == "search_database" :
69
69
arg = json .loads (function .arguments )
70
- search_query = arg .get ("search_query" )
70
+ # Even though its required, search_query is not always specified
71
+ search_query = arg .get ("search_query" , original_user_query )
71
72
if "price_filter" in arg and arg ["price_filter" ]:
72
73
price_filter = arg ["price_filter" ]
73
74
filters .append (
Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ async def run(
65
65
tool_choice = "auto" ,
66
66
)
67
67
68
- query_text , filters = extract_search_arguments (chat_completion )
68
+ query_text , filters = extract_search_arguments (original_user_query , chat_completion )
69
69
70
70
# Retrieve relevant items from the database with the GPT optimized query
71
71
results = await self .searcher .search_and_embed (
You can’t perform that action at this time.
0 commit comments