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

.Net Anthropic connector progress (Claude 3) #5690

Open
9 tasks done
Krzysztof318 opened this issue Mar 28, 2024 · 26 comments · May be fixed by #7364
Open
9 tasks done

.Net Anthropic connector progress (Claude 3) #5690

Krzysztof318 opened this issue Mar 28, 2024 · 26 comments · May be fixed by #7364
Assignees
Labels
.NET Issue or Pull requests regarding .NET code

Comments

@Krzysztof318
Copy link
Contributor

Krzysztof318 commented Mar 28, 2024

Progress of implementation of Anthropic Claude 3 family connector.
Current implementation BRANCH

TODO

  1. ChatCompletionService
  • Get chat
    • Create examples
  • Stream chat
    • Create examples
  • Add DI extensions
  • Provide metadata from response
  • Pass images with prompt
  1. Others
  • Logging
  • Telemetry
Copy link

This issue is stale because it has been open for 90 days with no activity.

@github-actions github-actions bot added the stale Issue is stale because it has been open for 90 days with no activity label Jun 27, 2024
@Krzysztof318
Copy link
Contributor Author

Bump

@github-actions github-actions bot removed the stale Issue is stale because it has been open for 90 days with no activity label Jun 28, 2024
@Pekket
Copy link

Pekket commented Jul 4, 2024

Any update on this? @RogerBarreto

@Krzysztof318
Copy link
Contributor Author

Krzysztof318 commented Jul 4, 2024

@Pekket I held with developing connector until function calling abstraction will be ready. But probably fca won't be ready fast, so yesterday we decided with @RogerBarreto to deploy connector now without fc functionality. I am working currently on connector code.

@Pekket
Copy link

Pekket commented Jul 5, 2024

@Krzysztof318 Thanks for the work, looks good 🦸
Any idea when the stream chat will be implemented?

@Krzysztof318
Copy link
Contributor Author

@Pekket soon but before we merge claude to main brach I think it will take couple of weeks.

@rodion-m
Copy link

@Krzysztof318 We’re so excited for it.

@celsound
Copy link

Hear hear! Claude support please!

RogerBarreto added a commit that referenced this issue Jul 29, 2024
Part of: #5690 

Anthropic chat generation (non-streaming)

@RogerBarreto 

### 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: Roger Barreto <[email protected]>
@payoff
Copy link

payoff commented Aug 26, 2024

There is any update?

@Krzysztof318
Copy link
Contributor Author

Sorry, I have much work last time, but I started working on streaming. I hope I will publish PR this week.

RogerBarreto added a commit that referenced this issue Sep 10, 2024
#5690 

Added samples

@RogerBarreto

---------

Co-authored-by: Roger Barreto <[email protected]>
@payoff
Copy link

payoff commented Sep 25, 2024

I wanted to check in and see if there are any updates on the current development status. Specifically, I would like to know if there is an estimated date when the ongoing work will be merged into the master branch.

Thank you for your time and support.
Mik

@Krzysztof318
Copy link
Contributor Author

@payoff I hope soon, currently I am waiting for review latest PR.

@therealpaulgg
Copy link

@payoff I hope soon, currently I am waiting for review latest PR.

Looks like 2 unit tests are failing?

@kcrandall
Copy link

kcrandall commented Oct 18, 2024

Any plans to support prompt caching at some point?

https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching

Might want to just want to have users add a flag to the ChatMessageContent metadata object and then add it to the payload when you serialize before sending.

@lostmsu
Copy link

lostmsu commented Oct 23, 2024

Is this up to date? Does the lack of function calling mean we can't use the new computer tool?

@nonoc
Copy link

nonoc commented Oct 24, 2024

Hi guys, I'm having a hard time finding a way to connect to Anthropic. It's something that's actually implemented in the latest versions of SemanticKernel. I'm currently working with version 1.72, which is the most stable, using KernelFactory. I don't really know why higher versions don't work with KernelFactory, and with Anthropic I have a connection error. It's something that's being tested.
Thank you all very much.

@lostmsu
Copy link

lostmsu commented Oct 24, 2024

@nonoc Funny you ask, I started implementing computer use tool off where this work was stopped, have prototype here: https://github.com/BorgGames/semantic-kernel/tree/AnthropicTools (fork of this repo)

Beta package is here: https://www.nuget.org/packages/Lost.SemanticKernel.Connectors.Anthropic/1.22.0-alpha0

Usage

var chatHistory = new ChatHistory();
chatHistory.AddUserMessage("Open Notepad and type Hi!");

var sut = new AnthropicChatCompletionService(this.AnthropicGetModel(), this.AnthropicGetApiKey(), new(beta: ComputerUse_2024_10_22.Beta));

var kernel = new Kernel();
kernel.Plugins.Add(ComputerUse_2024_10_22.ComputerPlugin(NoOpComputer.Instance));

// Act
var response = await sut.GetChatMessageContentsAsync(chatHistory, kernel: kernel);

// Assert
var lastMessage = response[^1];
var metadata = lastMessage.Metadata as AnthropicMetadata;
Assert.NotNull(metadata);
this.Output.WriteLine($"FinishReason: {metadata.FinishReason}");
Assert.Equal(AnthropicFinishReason.ToolUse, metadata.FinishReason);

var supposedlyScreenshotCall = lastMessage.Items
    .OfType<FunctionCallContent>()
    .FirstOrDefault();
Assert.NotNull(supposedlyScreenshotCall);
Assert.Equal("computer", supposedlyScreenshotCall.FunctionName);
if (supposedlyScreenshotCall.Arguments?["action"] is not JsonElement action)
{
    Assert.Fail("action is not supplied or wrong type");
    return;
}
Assert.Equal("screenshot", action.Deserialize<string>());

@mhensen
Copy link

mhensen commented Oct 27, 2024

Any updates? really looking formward to use anthropic in my projects..

@lostmsu
Copy link

lostmsu commented Oct 28, 2024

Just updated the alpha to the latest official release 1.25.0, and enabled an option to auto execute Computer Use tool.

https://www.nuget.org/packages/Lost.SemanticKernel.Connectors.Anthropic/1.25.0-alpha2#readme-body-tab

@Krzysztof318
Copy link
Contributor Author

@lostmsu hi, nice to see you are working also on this connector. But instead of creating own repo could you contribute to anthropic branch and create PR in SK?

@lostmsu
Copy link

lostmsu commented Oct 28, 2024

@Krzysztof318 sure, I didn't notice the branch until recently.

@therealpaulgg
Copy link

@Krzysztof318 have you tested on Google vertex? For me earlier I was having issues unless I made changes, which I commented on your PR.

@Krzysztof318
Copy link
Contributor Author

Krzysztof318 commented Oct 28, 2024

@therealpaulgg I haven't tested but I applied your suggestions.

RogerBarreto pushed a commit that referenced this issue Oct 29, 2024
### 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.
-->

#5690

### Description

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->

Added streaming functionality and related tests.

@RogerBarreto @RogerBarret0

### 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 😄
@nonoc
Copy link

nonoc commented Nov 4, 2024

Why we need to use .NET Standard 2.0 to use it?

@giannik
Copy link

giannik commented Nov 13, 2024

Will the Anthropic connector eventually get into semantic kernel repository? I'm asking because I saw the Ai.extensions released and got me thinking if this pr will be postponed. I hope not.

@Krzysztof318
Copy link
Contributor Author

@GLaNIK it will, PR is waiting for final review. AI.extensions is designed to integration with existing .net sdk of model providers. But anthropic doesn't have .net sdk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
.NET Issue or Pull requests regarding .NET code
Projects
Status: Community PRs
Development

Successfully merging a pull request may close this issue.