@@ -25,8 +25,7 @@ def __init__(
25
25
chat_model : str ,
26
26
chat_deployment : str | None , # Not needed for non-Azure OpenAI
27
27
openai_embed_client : AsyncOpenAI ,
28
- embed_deployment : str
29
- | None , # Not needed for non-Azure OpenAI or for retrieval_mode="text"
28
+ embed_deployment : str | None , # Not needed for non-Azure OpenAI or for retrieval_mode="text"
30
29
embed_model : str ,
31
30
embed_dimensions : int ,
32
31
):
@@ -60,8 +59,7 @@ async def run(
60
59
system_prompt = self .query_prompt_template ,
61
60
new_user_content = original_user_query ,
62
61
past_messages = past_messages ,
63
- max_tokens = self .chat_token_limit
64
- - query_response_token_limit , # TODO: count functions
62
+ max_tokens = self .chat_token_limit - query_response_token_limit , # TODO: count functions
65
63
fallback_to_default = True ,
66
64
)
67
65
@@ -93,17 +91,14 @@ async def run(
93
91
94
92
results = await self .searcher .search (query_text , vector , top , filters )
95
93
96
- sources_content = [
97
- f"[{ (item .id )} ]:{ item .to_str_for_rag ()} \n \n " for item in results
98
- ]
94
+ sources_content = [f"[{ (item .id )} ]:{ item .to_str_for_rag ()} \n \n " for item in results ]
99
95
content = "\n " .join (sources_content )
100
96
101
97
# Generate a contextual and content specific answer using the search results and chat history
102
98
response_token_limit = 1024
103
99
messages = build_messages (
104
100
model = self .chat_model ,
105
- system_prompt = overrides .get ("prompt_template" )
106
- or self .answer_prompt_template ,
101
+ system_prompt = overrides .get ("prompt_template" ) or self .answer_prompt_template ,
107
102
new_user_content = original_user_query + "\n \n Sources:\n " + content ,
108
103
past_messages = past_messages ,
109
104
max_tokens = self .chat_token_limit - response_token_limit ,
0 commit comments