mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-08 15:48:29 +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,
|
||||
available_functions: Optional[Dict[str, Any]] = None,
|
||||
) -> Union[str, Any]:
|
||||
completion_params = self._prepare_completion_params(messages)
|
||||
completion_params = self._prepare_completion_params(messages, tools)
|
||||
# print(f"Completion params: {completion_params}")
|
||||
response = self.client.chat.completions.create(**completion_params)
|
||||
print(f"Response: {response}")
|
||||
|
||||
tool_calls = getattr(response.choices[0].message, "tool_calls", [])
|
||||
print(f"Tool calls: {tool_calls}")
|
||||
|
||||
return response.choices[0].message.content
|
||||
|
||||
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]:
|
||||
print(f"Preparing completion params for {self.model}")
|
||||
# print(f"Messages: {messages}")
|
||||
print(f"Temperature: {self.temperature}")
|
||||
return {
|
||||
"model": self.model,
|
||||
"messages": messages,
|
||||
"temperature": self.temperature,
|
||||
"tools": tools,
|
||||
}
|
||||
|
||||
def supports_function_calling(self) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user