Skip to content

Commit 7f9bb39

Browse files
committed
Remove unnecessary changes
1 parent c79bdf0 commit 7f9bb39

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

src/neo4j_graphrag/llm/openai_llm.py

+4-12
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,8 @@ def invoke(
115115
try:
116116
if isinstance(message_history, MessageHistory):
117117
message_history = message_history.messages
118-
# We know these are compatible with OpenAI's API at runtime
119-
messages = self.get_messages(input, message_history, system_instruction)
120118
response = self.client.chat.completions.create(
121-
messages=messages,
119+
messages=self.get_messages(input, message_history, system_instruction),
122120
model=self.model_name,
123121
**self.model_params,
124122
)
@@ -158,15 +156,13 @@ def invoke_with_tools(
158156
if "temperature" not in params:
159157
params["temperature"] = 0.0
160158

161-
# We know these are compatible with OpenAI's API at runtime
162-
messages = self.get_messages(input, message_history, system_instruction)
163159
# Convert tools to OpenAI's expected type
164160
openai_tools: List[ChatCompletionToolParam] = []
165161
for tool in tools:
166162
openai_tools.append(cast(ChatCompletionToolParam, tool))
167163

168164
response = self.client.chat.completions.create(
169-
messages=messages,
165+
messages=self.get_messages(input, message_history, system_instruction),
170166
model=self.model_name,
171167
tools=openai_tools,
172168
tool_choice="auto",
@@ -226,10 +222,8 @@ async def ainvoke(
226222
try:
227223
if isinstance(message_history, MessageHistory):
228224
message_history = message_history.messages
229-
# We know these are compatible with OpenAI's API at runtime
230-
messages = self.get_messages(input, message_history, system_instruction)
231225
response = await self.async_client.chat.completions.create(
232-
messages=messages,
226+
messages=self.get_messages(input, message_history, system_instruction),
233227
model=self.model_name,
234228
**self.model_params,
235229
)
@@ -269,15 +263,13 @@ async def ainvoke_with_tools(
269263
if "temperature" not in params:
270264
params["temperature"] = 0.0
271265

272-
# We know these are compatible with OpenAI's API at runtime
273-
messages = self.get_messages(input, message_history, system_instruction)
274266
# Convert tools to OpenAI's expected type
275267
openai_tools: List[ChatCompletionToolParam] = []
276268
for tool in tools:
277269
openai_tools.append(cast(ChatCompletionToolParam, tool))
278270

279271
response = await self.async_client.chat.completions.create(
280-
messages=messages,
272+
messages=self.get_messages(input, message_history, system_instruction),
281273
model=self.model_name,
282274
tools=openai_tools,
283275
tool_choice="auto",

0 commit comments

Comments
 (0)