-
Notifications
You must be signed in to change notification settings - Fork 1
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
Asynchronous Chat #1
Comments
Hello, First and foremost, thank you for your interest in this project. Your request is both insightful and greatly appreciated. I’ll make sure to add it to my list of pending tasks. Currently, I am waiting for Mistral.AI to release the API extension for agent creation, which is a critical piece that I am eagerly anticipating. In the meantime, if you’re looking to quickly establish an asynchronous mode, you could implement a "temporary" solution as follows: Create methods: procedure MyClass.DoOnWorkStart(Sender: TObject);
…
procedure MyClass.DoOnWorkEnd(Sender: TObject);
…
procedure MyClass.DoOnChat(Sender: TObject);
… Using the first Chat (non-Stream) example, we can quickly create an asynchronous task as follows: // system.Threading;
var Task: ITask := TTask.Create(
procedure()
begin
TThread.Synchronize(TThread.Current,
procedure
begin
var Chat := MistralAI.Chat.Create(
procedure (Params: TChatParams)
begin
Params.Model('mistral-tiny');
Params.Messages([TChatMessagePayload.User(Memo2.Text)]);
Params.MaxTokens(1024);
end);
try
for var Choice in Chat.Choices do
Memo1.Lines.Add(Choice.Message.Content);
DoOnChat(Chat);
finally
Chat.Free;
end;
DoOnWorkEnd(Self);
end);
end);
DoOnWorkStart(Self);
Task.Start;
I am aware that this is only a draft solution. I will dedicate more time to it as soon as I have finished the Wrapper for Delphi, which will allow the use of Anthropic APIs for its models. Best regards, |
Hello, A new version has been released to handle asynchronous chat (streamed and non-streamed). Best regards |
Hello,
First, I would like to express my sincere thanks for sharing your source code.
Currently, I'm using the HemulGM wrapper for OpenAI, and your code will be invaluable as I integrate Mistral into my tests. With the HemulGM code, implementing asynchronous chat functionality is straightforward, as events are triggered when the result is ready. Specifically, these events include:
Can we imagine implementing something similar on your side?
Best regards,
The text was updated successfully, but these errors were encountered: