I’m trying to set up a chat using Claude and SignalR. We’re in .Net 6 and currently can’t upgrade to .Net 8 at this time. I found Claudia which is supposed to support .Net 6 but the sample code won’t compile. I’ve added an issue on the github repo but so far haven’t received any help. I’m hoping someone here can give me some advice on how to modify this code in my hub to get it working.
public async IAsyncEnumerable<string> Chat(AiChatRequestViewModel requestViewModel,
[EnumeratorCancellation]
CancellationToken cancellationToken)
{
var anthropic = new Anthropic()
{
ApiKey = _anthropicApiKey
};
var stream = anthropic.Messages.CreateStreamAsync(new()
{
Model = "claude-3-opus-20240229",
MaxTokens = requestViewModel.Samples,
Temperature = 0.0,
Messages = [new () { Role = "user", Content = requestViewModel.AIPrompt }]
}, cancellationToken: cancellationToken);
await foreach (var messageStreamEvent in stream)
{
yield return messageStreamEvent.Type;
}
}
The spot where it’s complaining about is on the Messages line with the error – Invalid expression term '['
That line gives an intellisense error of Constructor 'Claudia.Message.Message()' is obsolete: Constructors of types with required members are not supported in this version of your compiler.