-
Notifications
You must be signed in to change notification settings - Fork 23
Connector Implementation & Inheritance: Anthropic Claude #499
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
base: main
Are you sure you want to change the base?
Connector Implementation & Inheritance: Anthropic Claude #499
Conversation
…c Claude integration
…lternative model options
Adds links to the documentation for the Anthropic connector in the README, covering local machine, local container, and Azure deployments. Addresses the need to provide clear instructions for utilizing the new Anthropic connector. Related to aliencube#261
Updates the documentation to refer to Anthropic models instead of the specific Claude model, reflecting the broader range of models now supported. Relates to aliencube#261
…n and ensure proper function invocation
var client = new AnthropicClient() { Auth = new APIAuthentication(apiKey) }; | ||
|
||
var chatClient = client.Messages | ||
.AsBuilder() | ||
.UseFunctionInvocation() | ||
.Use((messages, options, next, cancellationToken) => | ||
{ | ||
options!.ModelId = settings!.Model; | ||
options.MaxOutputTokens ??= 1000; | ||
return next(messages, options, cancellationToken); | ||
}) | ||
.Build(); |
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.
테스트 해보다가, anthropic sdk의 api 호출이 잘 안 되어서 우리 프로젝트의 파일들을 살펴봤습니다.
- ChatInput.razor.cs 파일에서
private async Task SendMessageAsync()
→await OnSend.InvokeAsync(new ChatMessage(ChatRole.User, trimmedText));
호출
- Chat.razor.cs 파일에서
private async Task AddUserMessageAsync(ChatMessage userMessage)
→ChatService.GetStreamingResponseAsync([.. messages], chatOptions, currentResponseCancellation.Token)
호출
- ChatService.cs 파일에서
public IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync()
→ returnthis._chatClient.GetStreamingResponseAsync(chats, options, cancellationToken);
호출
이쪽 부분에서 token 수를 지정해야 호출이 되어서 임의로 토큰수를 1000으로 지정했습니다. 혹시 어떻게 하면 좋을지 궁금합니다.
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.
테스트 해보다가, anthropic sdk의 api 호출이 잘 안 되어서 우리 프로젝트의 파일들을 살펴봤습니다.
호출이 잘 안 됐다는 게 정확히 어떤 의미죠? Exception이 발생했다는 건가요?
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.
앗 네 만약 57번을 주석처리하면
"message":"max_tokens: must be greater than or equal to 1"
이런 식으로 예외가 뜹니다
fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111]
Unhandled exception in circuit 'F9Rlr3x3VTCcGA5lnf-m5VlCqoos2nCX63LAzBhR2Ow'.
System.Net.Http.HttpRequestException: {"type":"error","error":{"type":"invalid_request_error","message":"max_tokens: must be greater than or equal to 1"},"request_id":"req_011CU7LZEatnHLLUn6kkH2h7"}
at Anthropic.SDK.BaseEndpoint.HttpRequestRaw(String url, HttpMethod verb, Object postData, Boolean streaming, CancellationToken ctx)
at Anthropic.SDK.EndpointBase.HttpStreamingRequestMessages(String url, HttpMethod verb, Object postData, CancellationToken ctx)+MoveNext()
at Anthropic.SDK.EndpointBase.HttpStreamingRequestMessages(String url, HttpMethod verb, Object postData, CancellationToken ctx)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
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.
MaxToken 값이 필수인 것으로 보이는데, appsettings.json 부터 차근차근 추가할 필요가 있어 보이는데요?
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.
MaxToken 값이 필수인 것으로 보이는데, appsettings.json 부터 차근차근 추가할 필요가 있어 보이는데요?
@sikutisa 아하.. 그러면 필요한 부분 살펴보고 정리해서 말씀드리겠습니다!
Related to : aliencube#342 * Add `MaxTokens` parameter to the Anthropic section in appsettings.json (Microsoft.Extensions.Configuration.Binder automatically converts string values to integers when binding configuration)
Relate to : aliencube#258 * Add`MaxTokens` property to AnthropicSettings
…lementation-Inheritance-AnthropicClaude
* update LanguageModelConnector to include Anthropic in unsupported list * will be re-enabled when Anthropic PR is merged
* mark all AnthropicConnectorTests as skipped to avoid CI failures while connector is unsupported
{ | ||
/// <summary> | ||
/// Gets or sets the API key for Anthropic Claude. | ||
/// Gets or sets the API key for Anthropic. |
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.
20번, 25번, 30번 라인에서 Calude를 뺏다가 다시 넣었는데요, (20번줄은 다시 안 넣었네요)
Anthropic Claude 라고 하는 것보다 Anthropic으로 넣는 게 맞는 것 같은데 어떤 식으로 할까요?
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.
빼시죠!
Purpose
Does this introduce a breaking change?
Pull Request Type
What kind of change does this Pull Request introduce?
README updated?
The top-level readme for this repo contains a link to each sample in the repo. If you're adding a new sample did you update the readme?
How to Test
What to Check
Other Information about
AnthropicConnectorTests.cs
생성/타입 관련
EnsureLanguageModelSettingsValid()
GetChatClientAsync()
CreateChatClientAsync()