Update litellm_wrapper.py

pull/1005/head
CI-DEV 2 months ago committed by GitHub
parent 072f04c363
commit 6497e5d827
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -214,6 +214,14 @@ class LiteLLM:
def output_for_tools(self, response: any): def output_for_tools(self, response: any):
if self.mcp_call is True: if self.mcp_call is True:
# Check if there are any tool calls in the response
if (hasattr(response, 'choices') and
response.choices and
hasattr(response.choices[0], 'message') and
hasattr(response.choices[0].message, 'tool_calls') and
response.choices[0].message.tool_calls):
# Extract the first tool call
out = response.choices[0].message.tool_calls[0].function out = response.choices[0].message.tool_calls[0].function
output = { output = {
"function": { "function": {
@ -222,6 +230,16 @@ class LiteLLM:
} }
} }
return output return output
else:
# No tool calls present, return the regular content
if (hasattr(response, 'choices') and
response.choices and
hasattr(response.choices[0], 'message') and
hasattr(response.choices[0].message, 'content')):
return response.choices[0].message.content
else:
# Fallback: return the response as is
return response
else: else:
out = response.choices[0].message.tool_calls out = response.choices[0].message.tool_calls

Loading…
Cancel
Save