feat: enhance AnthropicCompletion class with additional client parameters and tool handling

- Added support for client_params in the AnthropicCompletion class to allow for additional client configuration.
- Refactored client initialization to use a dedicated method for retrieving client parameters.
- Implemented a new method to handle tool use conversation flow, ensuring proper execution and response handling.
- Introduced comprehensive test cases to validate the functionality of the AnthropicCompletion class, including tool use scenarios and parameter handling.
This commit is contained in:
lorenzejay
2025-10-14 15:34:28 -07:00
parent 8a9835a59f
commit 7e8d33104a

View File

@@ -123,6 +123,7 @@ class AnthropicCompletion(BaseLLM):
Chat completion response or tool call result
"""
try:
print("we are calling", messages)
# Emit call started event
self._emit_call_started_event(
messages=messages,
@@ -142,6 +143,7 @@ class AnthropicCompletion(BaseLLM):
completion_params = self._prepare_completion_params(
formatted_messages, system_message, tools
)
print("completion_params", completion_params)
# Handle streaming vs non-streaming
if self.stream:
@@ -292,6 +294,7 @@ class AnthropicCompletion(BaseLLM):
) -> str | Any:
"""Handle non-streaming message completion."""
try:
print("params", params)
response: Message = self.client.messages.create(**params)
except Exception as e: