Repository navigation
Tools not being included and outbound request #383
|
I am using the source generator mechanism. The outbound request does not contain my custom tool definition. ","stream":true,"tools":[{}],"CustomHeaders":{}}". My assumption is that it would include the tool definition in the outbound request. |
Replies: 2 comments 1 reply
|
A couple of things are worth checking before assuming the source generator isn't working.
The "tools":[{}]Try inspecting the generated files under the project's generated sources (or enable emitting compiler-generated files) to confirm that
You're currently doing: var tools = new List<object> { new CollectionTools() };
await foreach (var message in chat.SendAsync(prompt, tools))If
Could you share which version of OllamaSharp you're using? There have been changes around tool calling across releases, so this could be a version-specific issue rather than a problem with your code.
If possible, could you also provide:
That additional information would help determine whether this is a source generator issue, a serialization issue, or simply an API usage mismatch. If this solves your problem, feel free to mark it as the accepted answer so others can find it easily. |
|
Thanks for the response. I eventually got things working but did not use the attribute/generator. |
A couple of things are worth checking before assuming the source generator isn't working.
The
[OllamaTool]attribute relies on the source generator to produce the tool schema. If the generator isn't running (or the generated files aren't being included), you'll end up with an emptytoolspayload such as:"tools":[{}]Try inspecting the generated files under the project's generated sources (or enable emitting compiler-generated files) to confirm that
CollectionToolsactually has a generated tool definition.You're currently doing: