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

Bug: Ollama connector does not send the tools/agents/functions list #9682

Closed
raffaeler opened this issue Nov 13, 2024 · 3 comments · Fixed by #9718
Closed

Bug: Ollama connector does not send the tools/agents/functions list #9682

raffaeler opened this issue Nov 13, 2024 · 3 comments · Fixed by #9718
Assignees
Labels
bug Something isn't working .NET Issue or Pull requests regarding .NET code

Comments

@raffaeler
Copy link

Describe the bug
I am using Semantic Kernel with Ollama and llama 3.2.

When I use the Ollama connector, the functions are not added to http request.
The same code and prompt using Azure OpenAI works correctly.

To Reproduce
OllamaFunctionCalling sample.

Expected behavior
I expect the functions being called.

Platform

  • OS: Windows 11
  • IDE: VS2022
  • Language: C# / .NET 9
  • Source: 1.28 alpha / preview

Details
I tried the same prompt on GPT and then on Ollama hosted locally.
When I use Ollama I specify the following settings:

KernelFunction[] functions = kernel.Plugins
                .SelectMany(p => p).ToArray();
FunctionChoiceBehavior functionOptions = FunctionChoiceBehavior.Required(functions, true); 

OllamaPromptExecutionSettings ollamaPromptExecutionSettings =
    new()
    {
        FunctionChoiceBehavior = functionOptions,
        ModelId = modelName,
        //...
    }

I also tried FunctionChoiceBehavior.Auto() wit no success.

I then passed my own HttpClient with a handler which logs all the http traffic. This is the result:

{"model":"llama3.2","messages":[{"role":"system","content":"","images":null,"tool_calls":null},{"role":"user","content":"What's the weather like in Genoa right now?","images":null,"tool_calls":null}],"options":{"temperature":0.85,"top_p":0.9},"stream":true,"tools":null,"CustomHeaders":{}}
@raffaeler raffaeler added the bug Something isn't working label Nov 13, 2024
@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code triage labels Nov 13, 2024
@github-actions github-actions bot changed the title Bug: Ollama connector does not send the tools/agents/functions .Net: Bug: Ollama connector does not send the tools/agents/functions Nov 13, 2024
@raffaeler raffaeler changed the title .Net: Bug: Ollama connector does not send the tools/agents/functions Bug: Ollama connector does not send the tools/agents/functions list Nov 13, 2024
@raffaeler
Copy link
Author

BTW what are the capabilities of this connector? It looks like it does not support multimodality.
In other words, a new prompt contains the image but the http message does not.

@shethaadit
Copy link
Contributor

shethaadit commented Nov 15, 2024

Hi @markwallace-microsoft / @RogerBarreto, I will work on this and try to raise PR soon. :)

github-merge-queue bot pushed a commit that referenced this issue Nov 19, 2024
…cutionSettings. (#9718)

### Description

This PR addresses a bug in `OllamaPromptExecutionSettings` where the
`FunctionChoiceBehavior` state was not properly restored during the
conversion process from `PromptExecutionSettings`. Specifically, the
internal state of `FunctionChoiceBehavior`, including its list of
associated functions, was lost during serialization and deserialization.

### Motivation and Context

**Why is this change required?**
The lack of proper state restoration led to missing function definitions
in HTTP requests when using the Ollama connector, causing failures in
scenarios that rely on function calls.

**What problem does it solve?**
This change ensures that the `FunctionChoiceBehavior` is fully restored
when converting execution settings, maintaining the expected behavior
for function calls in the Ollama connector.

**What scenario does it contribute to?**
This fix enables consistent and reliable function calling with the
Ollama connector, ensuring that defined functions are included in
requests and operate as expected.

**Related Issues**
This change fixes the issue described in the bug report, improving
usability and reliability when working with function behaviors in
Semantic Kernel integrations.

### Contribution Checklist

- [Y] The code builds clean without any errors or warnings
- [Y] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [Y] All unit tests pass, and I have added new tests where possible
- [Y] I didn't break anyone :)

Fixes #9682

---------

Co-authored-by: Adit Sheth <[email protected]>
Co-authored-by: Mark Wallace <[email protected]>
@github-project-automation github-project-automation bot moved this from Bug to Sprint: Done in Semantic Kernel Nov 19, 2024
@nonoc
Copy link

nonoc commented Dec 10, 2024

Any news about that?
Thanks

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
Projects
Archived in project
5 participants