Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

Function calling #53

Closed
savikko opened this issue Feb 29, 2024 · 9 comments
Closed

Function calling #53

savikko opened this issue Feb 29, 2024 · 9 comments
Assignees

Comments

@savikko
Copy link

savikko commented Feb 29, 2024

Hi!

What is the way to call (Mistral Large) functions with this client?

I did not find even any mentions about functions on API documentation (https://docs.mistral.ai/api/#operation/createChatCompletion)

@jfhenon
Copy link

jfhenon commented Feb 29, 2024

Hi!

What is the way to call (Mistral Large) functions with this client?

I did not find even any mentions about functions on API documentation (https://docs.mistral.ai/api/#operation/createChatCompletion)

+1

@savikko
Copy link
Author

savikko commented Mar 1, 2024

And regarding Azure Mistral Large, they say this:

Does Mistral Large on Azure support function calling and Json output?

The Mistral Large model can do function calling and generate Json output, but support for those features will roll out soon on the Azure platform.

@thibautvdu
Copy link

Anyone using La Plateforme with javascript successfully tried function calling ?

According to the typescript definitions of this package at the moment, the function calling would be only available with streaming (client.chatStream), but I cannot get it to work either way (streaming or async).

Using mistral-large-latest, it seems that the model is aware fo which function it should call, but tool_calls is always empty and the model output "[Function Call: 'get-cart']" straight into the content.

Request call :

      const completions = this.mistralClient.chatStream({
        model: targetModel,
        messages: [this.getPrompt(), ...messages],
        tools: this.getTools(),
        responseFormat: {
          type: "text" as ResponseFormats,
        },
      });

      let content = "";
      for await (const completionChunk of completions) {
        const choice = completionChunk.choices[0];
        content += choice.delta.content || "";
        if (choice.delta.tool_calls) {
          toolCalls = choice.delta.tool_calls;
        }
      }

Answer :

dashboard:dev: Received completion {
dashboard:dev:   content: `{"answer": "Bien sûr, laissez-moi vous montrer le contenu de votre panier. 💰›’\\n\\n[Function Call: 'get-cart']", "thoughts": "I need to call the 'get-cart' function to retrieve the current items in the user's cart."}`,
dashboard:dev:   toolCalls: undefined
dashboard:dev: }

@lucas-vitrus
Copy link

+1

Same issue, no tools on the javascript client.

@johannbuscail
Copy link

Any update on this ?

@briannezhad
Copy link

+1

@JamieLee0510
Copy link

JamieLee0510 commented May 3, 2024

Anyone using La Plateforme with javascript successfully tried function calling ?

According to the typescript definitions of this package at the moment, the function calling would be only available with streaming (client.chatStream), but I cannot get it to work either way (streaming or async).

Using mistral-large-latest, it seems that the model is aware fo which function it should call, but tool_calls is always empty and the model output "[Function Call: 'get-cart']" straight into the content.

Request call :

      const completions = this.mistralClient.chatStream({
        model: targetModel,
        messages: [this.getPrompt(), ...messages],
        tools: this.getTools(),
        responseFormat: {
          type: "text" as ResponseFormats,
        },
      });
      }

Maybe could try setting the toolChoice option to valueany?
I could use function_call in my cases, especially by model mistral-large-latest

@fuegoio
Copy link
Contributor

fuegoio commented May 8, 2024

Hi everyone! Thanks all for your contribution and apologize for the delay of answer.

Function calling is properly working on the JS client, in normal and streaming mode. The latest release (0.2.0) should fix the typescript definitions.

We are aware of model issues (not related to this client) when having function calls after some text for example. We would appreciate a lot reproductible example of those issues. @thibautvdu @lucas-vitrus @briannezhad @johannbuscail do you have examples of prompt + tools that you give to the model where it answers badly?

@fuegoio fuegoio self-assigned this May 8, 2024
@GaspardBT
Copy link
Contributor

Thanks for reporting this issue. We have deprecated this package in favor of mistralai/client-ts, which is the new official Mistral client, compatible with both TypeScript and JavaScript.

You can find all installation information here.

This change is effective starting with version 1.0.0 of the npm package.

Let us know if your issue persists with the new package by opening an issue there.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants