microsoft / semantic-kernel

Integrate cutting-edge LLM technology quickly and easily into your apps
https://aka.ms/semantic-kernel
MIT License
22.13k stars 3.3k forks source link

.Net Anthropic connector progress (Claude 3) #5690

Open Krzysztof318 opened 8 months ago

Krzysztof318 commented 8 months ago

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

TODO

  1. ChatCompletionService
  1. Others
    • [x] Logging
    • [x] Telemetry
github-actions[bot] commented 5 months ago

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

Krzysztof318 commented 5 months ago

Bump

Pekket commented 4 months ago

Any update on this? @RogerBarreto

Krzysztof318 commented 4 months ago

@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 commented 4 months ago

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

Krzysztof318 commented 4 months ago

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

rodion-m commented 4 months ago

@Krzysztof318 We’re so excited for it.

celsound commented 4 months ago

Hear hear! Claude support please!

payoff commented 3 months ago

There is any update?

Krzysztof318 commented 3 months ago

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

payoff commented 2 months ago

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 commented 2 months ago

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

therealpaulgg commented 2 months ago

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

Looks like 2 unit tests are failing?

kcrandall commented 1 month ago

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 commented 1 month ago

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

nonoc commented 1 month ago

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 commented 1 month ago

@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 commented 1 month ago

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

lostmsu commented 1 month ago

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 commented 1 month ago

@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 commented 1 month ago

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

therealpaulgg commented 1 month ago

@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 commented 1 month ago

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

nonoc commented 3 weeks ago

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

giannik commented 2 weeks ago

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 commented 2 weeks ago

@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.