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

Microsoft.Extensions.AI has no documentation nor Sample for Tool Usage #5739

Open
JohnGalt1717 opened this issue Dec 12, 2024 · 3 comments
Open

Comments

@JohnGalt1717
Copy link

Description

IChatClient clearly supports tool usage, but there's no documentation that I can find anywhere (I can't find real documentation for Microsoft.Extensions.AI, only the announcement) on this topic, and Copilot and Github Copilot are also clueless on how to use tools properly.

Reproduction Steps

Try and use tools with Microsoft.Extensions.AI.

Expected behavior

There should be a proper documentation page, the announcement should reference it, the nuget package should have that as the package home, and the documentation section should have explicit instructions on how to use tools.

Actual behavior

None of that is available.

Regression?

No response

Known Workarounds

🤷

Configuration

.net 9,

Other information

...

@JohnGalt1717 JohnGalt1717 added bug This issue describes a behavior which is not expected - a bug. untriaged labels Dec 12, 2024
@stephentoub
Copy link
Member

stephentoub commented Dec 12, 2024

No doubt samples and docs can be improved, but you can see tool use examples in the package readme:
https://www.nuget.org/packages/Microsoft.Extensions.AI.Abstractions

in the eshop sample:
https://github.com/dotnet/eShop/blob/main/src/WebApp/Components/Chatbot/ChatState.cs#L41-L47

in the dotnet/Ai-samples, eg
https://github.com/dotnet/ai-samples/blob/main/src/microsoft-extensions-ai/ollama/OllamaExamples/ToolCalling.cs

in the eShopSupport sample, eg
https://github.com/dotnet/eShopSupport/blob/690d0815444539afb120fb9145253e990fbcfb0d/src/Backend/Api/AssistantApi.cs#L56

etc.

In short, set ChatOptions.Tools to the collection of tools you want advertised to the llm. And if you want them automatically invoked by the client when they're requested, add that support to the IChatClient, typically via UseFunctionInvocation.

@stephentoub stephentoub added documentation and removed bug This issue describes a behavior which is not expected - a bug. labels Dec 12, 2024
@stephentoub
Copy link
Member

cc: @LadyNaggaga

@JohnGalt1717
Copy link
Author

The problem is that this is so undiscoverable that even with Copilot doing web searches, it still can't find it, and if it can't find it, no one else will either.

It also doesn't talk about Async, or any instructions on how to get good results from the tools (like meta data for parameters, DescriptionAttribute, JsonSchema) so one is left to stumble around in the dark.

All of the documentation should be in the .net documentation like everything else too.

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

No branches or pull requests

2 participants