Skip to content

Commit 0d0572c

Browse files
committed
Make mypy happy
1 parent 2a3552d commit 0d0572c

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/backend/fastapi_app/rag_advanced.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from agents import (
66
Agent,
7+
ItemHelpers,
78
ModelSettings,
89
OpenAIChatCompletionsModel,
910
Runner,
@@ -124,7 +125,8 @@ async def prepare_context(self) -> tuple[list[ItemPublic], list[ThoughtStep]]:
124125
thoughts = [
125126
ThoughtStep(
126127
title="Prompt to generate search arguments",
127-
description=[{"content": self.search_agent.instructions}] + run_results.input,
128+
description=[{"content": self.query_prompt_template}]
129+
+ ItemHelpers.input_to_new_input_list(run_results.input),
128130
props=self.model_for_thoughts,
129131
),
130132
ThoughtStep(
@@ -163,7 +165,8 @@ async def answer(
163165
+ [
164166
ThoughtStep(
165167
title="Prompt to generate answer",
166-
description=[{"content": self.answer_agent.instructions}] + run_results.input,
168+
description=[{"content": self.answer_prompt_template}]
169+
+ ItemHelpers.input_to_new_input_list(run_results.input),
167170
props=self.model_for_thoughts,
168171
),
169172
],
@@ -178,7 +181,7 @@ async def answer_stream(
178181
run_results = Runner.run_streamed(
179182
self.answer_agent,
180183
input=self.chat_params.past_messages
181-
+ [{"content": self.prepare_rag_request(self.chat_params.original_user_query, items), "role": "user"}],
184+
+ [{"content": self.prepare_rag_request(self.chat_params.original_user_query, items), "role": "user"}], # noqa
182185
)
183186

184187
yield RetrievalResponseDelta(
@@ -188,7 +191,8 @@ async def answer_stream(
188191
+ [
189192
ThoughtStep(
190193
title="Prompt to generate answer",
191-
description=[{"content": self.answer_agent.instructions}] + run_results.input,
194+
description=[{"content": self.answer_prompt_template}]
195+
+ ItemHelpers.input_to_new_input_list(run_results.input),
192196
props=self.model_for_thoughts,
193197
),
194198
],

src/backend/fastapi_app/rag_simple.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from collections.abc import AsyncGenerator
22
from typing import Optional, Union
33

4-
from agents import Agent, ModelSettings, OpenAIChatCompletionsModel, Runner, set_tracing_disabled
4+
from agents import Agent, ItemHelpers, ModelSettings, OpenAIChatCompletionsModel, Runner, set_tracing_disabled
55
from openai import AsyncAzureOpenAI, AsyncOpenAI
66
from openai.types.responses import ResponseInputItemParam, ResponseTextDeltaEvent
77

@@ -98,7 +98,8 @@ async def answer(
9898
+ [
9999
ThoughtStep(
100100
title="Prompt to generate answer",
101-
description=[{"content": self.answer_agent.instructions}] + run_results.input,
101+
description=[{"content": self.answer_prompt_template}]
102+
+ ItemHelpers.input_to_new_input_list(run_results.input),
102103
props=self.model_for_thoughts,
103104
),
104105
],
@@ -123,7 +124,8 @@ async def answer_stream(
123124
+ [
124125
ThoughtStep(
125126
title="Prompt to generate answer",
126-
description=[{"content": self.answer_agent.instructions}] + run_results.input,
127+
description=[{"content": self.answer_agent.instructions}]
128+
+ ItemHelpers.input_to_new_input_list(run_results.input),
127129
props=self.model_for_thoughts,
128130
),
129131
],

0 commit comments

Comments
 (0)