Skip to content
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

.Net: Running Semantic Kernel to call the OpenAPI schema failed with the Ollama using mistral:7b. #7026

Open
sophialagerkranspandey opened this issue Jul 1, 2024 Discussed in #6959 · 1 comment
Assignees
Labels
bug Something isn't working .NET Issue or Pull requests regarding .NET code sk team issue A tag to denote issues that where created by the Semantic Kernel team (i.e., not the community)

Comments

@sophialagerkranspandey
Copy link
Contributor

Discussed in #6959

Originally posted by tungyi June 25, 2024
I am trying to call the plugin using the Semantic Kernel. The model in use is mistral:7b with the local Ollama. Both the native plugin and the semantic plugin are working fine, and it appears that mistral:7b is correctly calling my plugin.
However, when I try to call the APIs in the OpenAPI schema with mistral:7b, it failed. Here is the sample code snippet:

  1. Create Connector
var kernel = Kernel.CreateBuilder().AddOpenAIChatCompletion(modelId: "mistral:7b", apiKey: null, endpoint: new Uri("http://XX.XX.XX.XX:11434")).Build();
  1. Import OpenAPI schema.
var apiPluginFile = @"C:/xxxx/swagger.json"; 
await kernel.await kernel.ImportPluginFromOpenApiAsync(
    "jiraPlugin",
    apiPluginFile, new OpenApiFunctionExecutive(
    new OpenApiFunctionExecutionParameters(
        authCallback: tokenProvider.AuthenticateRequestAsync,
        serverUrlOverride: new Uri("http://xxx.xxx.xxx.xxx")
    )
);
  1. Create planner with FunctionCallingStepwisePlanner
var planner = new FunctionCallingStepwisePlanner(
    new FunctionCallingStepwisePlannerOptions
    {
        MaxIterations = 6,
        MaxTokens = 5000,
    }); 
}
  1. Execute the task with ExecuteAsync.
var result = await planner.ExecuteAsync(kernel, "XXXXXXXX");
Console.WriteLine(result.FinalAnswer)

result.FinalAnswer is empty. Looking at result.ChatHistory, I see that mistral:7b doesn't call any restfulAPI in swagger.json for me.

So, I switched the model to Azure Open AI's gpt-4o and found that it successfully called the correct RESTful APIs without any issues!"
I just replace the kernel with the following code:

var kernel = Kernel.CreateBuilder().AddAzureOpenAIChatCompletion(
                        deploymentName: deploy_Name,   // Azure OpenAI Deployment Name
                        endpoint: aoai_Endpoint, // Azure OpenAI Endpoint
                        apiKey: api_Key  // Azure OpenAI Key
                        ).Build();

Is it possible for mistral:7b or any other models to support OpenAPI Schema like gpt-4o?

@markwallace-microsoft markwallace-microsoft added triage bug Something isn't working and removed triage labels Jul 1, 2024
@markwallace-microsoft markwallace-microsoft moved this to Sprint: Planned in Semantic Kernel Jul 1, 2024
@crickman crickman added the .NET Issue or Pull requests regarding .NET code label Jul 12, 2024
@github-actions github-actions bot changed the title Running Semantic Kernel to call the OpenAPI schema failed with the Ollama using mistral:7b. .Net: Running Semantic Kernel to call the OpenAPI schema failed with the Ollama using mistral:7b. Jul 12, 2024
@evchaki evchaki added the sk team issue A tag to denote issues that where created by the Semantic Kernel team (i.e., not the community) label Aug 28, 2024
@Secret0-OchkA
Copy link

in the Mistrall documentation, the model mistral:7b is not in the list of models that can call functions
https://docs.mistral.ai/capabilities/function_calling/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working .NET Issue or Pull requests regarding .NET code sk team issue A tag to denote issues that where created by the Semantic Kernel team (i.e., not the community)
Projects
Status: Sprint: Planned
Development

No branches or pull requests

6 participants