mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-09 08:08:32 +00:00
Refactor AISuiteLLM to include tools parameter in completion methods
- Update the _prepare_completion_params method to accept an optional tools parameter - Modify the chat completion method to utilize the new tools parameter for enhanced functionality - Clean up print statements for better code clarity
This commit is contained in:
14
src/crewai/llms/third_party/ai_suite.py
vendored
14
src/crewai/llms/third_party/ai_suite.py
vendored
@@ -17,24 +17,24 @@ class AISuiteLLM(BaseLLM):
|
|||||||
callbacks: Optional[List[Any]] = None,
|
callbacks: Optional[List[Any]] = None,
|
||||||
available_functions: Optional[Dict[str, Any]] = None,
|
available_functions: Optional[Dict[str, Any]] = None,
|
||||||
) -> Union[str, Any]:
|
) -> Union[str, Any]:
|
||||||
completion_params = self._prepare_completion_params(messages)
|
completion_params = self._prepare_completion_params(messages, tools)
|
||||||
# print(f"Completion params: {completion_params}")
|
# print(f"Completion params: {completion_params}")
|
||||||
response = self.client.chat.completions.create(**completion_params)
|
response = self.client.chat.completions.create(**completion_params)
|
||||||
print(f"Response: {response}")
|
|
||||||
tool_calls = getattr(response.choices[0].message, "tool_calls", [])
|
tool_calls = getattr(response.choices[0].message, "tool_calls", [])
|
||||||
print(f"Tool calls: {tool_calls}")
|
|
||||||
return response.choices[0].message.content
|
return response.choices[0].message.content
|
||||||
|
|
||||||
def _prepare_completion_params(
|
def _prepare_completion_params(
|
||||||
self, messages: Union[str, List[Dict[str, str]]]
|
self,
|
||||||
|
messages: Union[str, List[Dict[str, str]]],
|
||||||
|
tools: Optional[List[dict]] = None,
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
print(f"Preparing completion params for {self.model}")
|
|
||||||
# print(f"Messages: {messages}")
|
|
||||||
print(f"Temperature: {self.temperature}")
|
|
||||||
return {
|
return {
|
||||||
"model": self.model,
|
"model": self.model,
|
||||||
"messages": messages,
|
"messages": messages,
|
||||||
"temperature": self.temperature,
|
"temperature": self.temperature,
|
||||||
|
"tools": tools,
|
||||||
}
|
}
|
||||||
|
|
||||||
def supports_function_calling(self) -> bool:
|
def supports_function_calling(self) -> bool:
|
||||||
|
|||||||
Reference in New Issue
Block a user