Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions inference_gateway/providers/targon.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,15 @@ async def _inference(
tools=inference_tools_to_openai_tools(tools) if tools else None,
stream=False
)
choice = chat_completion.choices[0]
message = choice.message

message = chat_completion.choices[0].message
finish_reason = getattr(choice, 'finish_reason', None)
reasoning_content = getattr(message, 'reasoning_content', None)

final_content = message.content if message.content else ""
if not final_content and reasoning_content and finish_reason == "stop":
final_content = reasoning_content

num_input_tokens = chat_completion.usage.prompt_tokens
num_output_tokens = chat_completion.usage.completion_tokens
Expand All @@ -160,7 +167,7 @@ async def _inference(
return InferenceResult(
status_code=200,

content=message.content if message.content else "",
content=final_content,
tool_calls=openai_tool_calls_to_inference_tool_calls(message.tool_calls) if message.tool_calls else [],

num_input_tokens=num_input_tokens,
Expand Down Expand Up @@ -222,4 +229,4 @@ async def _embedding(
return EmbeddingResult(
status_code=-1,
error_message=f"Error in TargonProvider._embedding(): {type(e).__name__}: {str(e)}"
)
)