Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature anthropic action #22

Merged
merged 13 commits into from
Apr 6, 2024
Merged

Feature anthropic action #22

merged 13 commits into from
Apr 6, 2024

Conversation

dockhardman
Copy link
Owner

No description provided.

- Add Role, ContentType, SourceType enums for Anthropic chat messages
- Define ContentBlock, MessageParam, Metadata, ToolInputSchema, Tool models
- Implement AnthropicChatCompletionRequest model
- Add method to convert from OpenAI ChatCompletionRequest to AnthropicChatCompletionRequest
[/COMMIT_MSG]
Add from_kwargs classmethod to ChatCompletionRequest for validation
- Raises ValueError if messages or model not provided
- Calls model_validate on the kwargs
- Update AnthropicAction to support AnthropicChatCompletionRequest
- Convert ChatCompletionRequest to AnthropicChatCompletionRequest
- Call Anthropic's messages.create API with the converted request
- Map the API response back to ChatCompletion model
- Set default value of stream to False in AnthropicChatCompletionRequest
- Remove unused text_completion and text_completion_stream methods
- Update AnthropicAction to use the latest Anthropic API
- Add new types for Anthropic's API, including Role, ContentType, SourceType, Source, ContentBlock, and MessageParam
- Update tests for AnthropicAction
- Handle different stop reasons from Anthropic API and map them to OpenAI's finish_reason
- Include model name in the ChatCompletion response
- Implement chat_stream method in AnthropicAction class
- Validate model name, stream, and prepare request
- Send streaming request and yield ChatCompletionChunk
- Handle different message event types (message_start, message_delta, content_block_delta)
- Process stop reasons and update finish_reason accordingly
- Yield final ChatCompletionChunk with finish_reason and empty content
- Enable test for anthropic_action_chat_stream
- Add languru-llm-anthropic service to docker-compose.yml
- Define environment variables and configurations for the service
- Create dockerfile.anthropic.dev to build the languru-llm-anthropic image
- Install required dependencies and set up the working directory
- Expose port 80 and define entrypoint and default command
Copy link

codecov bot commented Apr 6, 2024

Codecov Report

Attention: Patch coverage is 86.01399% with 20 lines in your changes are missing coverage. Please review.

Project coverage is 81.34%. Comparing base (6a5311e) to head (cdf1f6d).

Files Patch % Lines
languru/action/anthropic.py 76.92% 18 Missing ⚠️
languru/types/chat/completions.py 71.42% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #22      +/-   ##
==========================================
+ Coverage   80.97%   81.34%   +0.37%     
==========================================
  Files          41       43       +2     
  Lines        1798     1941     +143     
==========================================
+ Hits         1456     1579     +123     
- Misses        342      362      +20     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dockhardman dockhardman merged commit f6d92e1 into master Apr 6, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant