-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Python: #6501 Anthropic Chat Completion #7851
Python: #6501 Anthropic Chat Completion #7851
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of small things, but overall this looks great!
python/semantic_kernel/connectors/ai/anthropic/services/anthropic_chat_completion.py
Outdated
Show resolved
Hide resolved
python/tests/unit/connectors/anthropic/services/test_anthropic_chat_completion.py
Outdated
Show resolved
Hide resolved
python/tests/unit/connectors/anthropic/services/test_anthropic_chat_completion.py
Outdated
Show resolved
Hide resolved
python/tests/unit/connectors/anthropic/services/test_anthropic_chat_completion.py
Outdated
Show resolved
Hide resolved
This is looking great, @andrewldesousa. Thank you for working on it! |
python/semantic_kernel/connectors/ai/anthropic/services/anthropic_chat_completion.py
Outdated
Show resolved
Hide resolved
python/semantic_kernel/connectors/ai/anthropic/services/anthropic_chat_completion.py
Outdated
Show resolved
Hide resolved
python/semantic_kernel/connectors/ai/anthropic/services/anthropic_chat_completion.py
Outdated
Show resolved
Hide resolved
Some additional info on streaming with the Anthropic SDK. Here is an example showing the streaming events. I make sure to stream all the content and still stream the metadata about usage, message author role, and stop reason. async with client.messages.stream(
max_tokens=1024,
messages=[
{
"role": "user",
"content": "What is semantic kernel??",
}
],
model="claude-3-opus-20240229",
) as stream:
async for text in stream:
print(text)
print() Output:
To learn more about the streaming events for Anthropic: |
60dc069
to
ebca03c
Compare
Python Test Coverage Report
Python Unit Test Overview
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A small comment otherwise LGTM.
python/semantic_kernel/connectors/ai/anthropic/services/anthropic_chat_completion.py
Show resolved
Hide resolved
5eff9b2
to
bda1c67
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couple of small notes, but looking good overall!
python/semantic_kernel/connectors/ai/anthropic/services/anthropic_chat_completion.py
Outdated
Show resolved
Hide resolved
python/semantic_kernel/connectors/ai/anthropic/services/utils.py
Outdated
Show resolved
Hide resolved
18dbe21
to
b2815e8
Compare
python/semantic_kernel/connectors/ai/anthropic/services/anthropic_chat_completion.py
Outdated
Show resolved
Hide resolved
python/semantic_kernel/connectors/ai/anthropic/services/anthropic_chat_completion.py
Outdated
Show resolved
Hide resolved
python/semantic_kernel/connectors/ai/anthropic/services/anthropic_chat_completion.py
Outdated
Show resolved
Hide resolved
…pic_chat_completion.py Co-authored-by: Tao Chen <[email protected]>
…pic_chat_completion.py Co-authored-by: Tao Chen <[email protected]>
Co-authored-by: Tao Chen <[email protected]>
Co-authored-by: Tao Chen <[email protected]>
@andrewldesousa there is a merge conflict, let me know when you resolve that, then we can merge this in! nice work! |
Head branch was pushed to by a user without write access
Thanks! Will look into function calling next |
@moonbox3 @eavanvalkenburg can you guys rereview given I have made some changes since your last review? |
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> 1. Why is this changed required? Support Anthropic models with Python (microsoft#6501) 2. What problem does it solve? ^^ 3. What scenario does it contribute to? Multi model use cases and applications that would like to use Anthropic models 4. If it fixes an open issue, please link to the issue here: microsoft#6501 ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> The changes made follow the designs followed by the Mistral AI and Open AI connectors. I added the following Classes : - AnthropicChatPromptExcecutionSettings - AnthropicChatCompletion - AnthropicSettings **To test the changes with the tests please add ANTHROPIC_API_KEY and ANTHROPIC_CHAT_MODEL_ID as Enviorment Variable** What is implemented: - [X] Integrate Anthropic ChatCompletion Models without Streaming - [X] Integrate Anthropic Chat Completion Models with Streaming - [X] Unit tests and integration tests - [X] Extended Testing including Unit Testing & More Integration Tests ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [X] The code builds clean without any errors or warnings - [X] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [X] All unit tests pass, and I have added new tests where possible - [X] I didn't break anyone 😄 --------- Co-authored-by: Tao Chen <[email protected]> Co-authored-by: Eduard van Valkenburg <[email protected]>
Motivation and Context
Description
The changes made follow the designs followed by the Mistral AI and Open AI connectors.
I added the following Classes :
To test the changes with the tests please add ANTHROPIC_API_KEY and
ANTHROPIC_CHAT_MODEL_ID as Enviorment Variable
What is implemented:
Contribution Checklist