Skip to content

Add FunctionInvokingChatClient.CurrentContext - #5786

Merged
stephentoub merged 3 commits into
mainfrom
mbuck/expose-invocation-context
Jan 10, 2025
Merged

Add FunctionInvokingChatClient.CurrentContext#5786
stephentoub merged 3 commits into
mainfrom
mbuck/expose-invocation-context

Conversation

@MackinnonBuck

@MackinnonBuckMackinnonBuck commented Jan 9, 2025

Copy link
Copy Markdown
Member

Allows AI functions to access the current FunctionInvokingChatClient.FunctionInvocationContext.

This can be used to access the chat history or terminate the function invocation loop.

Fixes#5705

Microsoft Reviewers: Open in CodeFlow

@MackinnonBuck
MackinnonBuck requested a review from a team as a code ownerJanuary 9, 2025 23:18

@stephentoubstephentoub left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

src/Libraries/Microsoft.Extensions.AI/ChatCompletion/FunctionInvokingChatClient.cs:670

  • Ensure that CurrentContext is reset appropriately after the function invocation to avoid unintended side effects.
CurrentContext = context;

Tip: If you use Visual Studio Code, you can request a review from Copilot before you push from the "Source Control" tab. Learn more

@dotnet-comment-bot

Copy link
Copy Markdown
Collaborator

‼️Found issues‼️

ProjectCoverage TypeExpectedActual
Microsoft.Extensions.Caching.HybridLine8677.82 🔻

🎉 Good job! The coverage increased 🎉
Update MinCodeCoverage in the project files.

ProjectExpectedActual
Microsoft.Extensions.AI8889

Full code coverage report: https://dev.azure.com/dnceng-public/public/_build/results?buildId=912643&view=codecoverage-tab

@dotnet-comment-bot

Copy link
Copy Markdown
Collaborator

‼️Found issues‼️

ProjectCoverage TypeExpectedActual
Microsoft.Extensions.Caching.HybridLine8677.7 🔻

🎉 Good job! The coverage increased 🎉
Update MinCodeCoverage in the project files.

ProjectExpectedActual
Microsoft.Extensions.AI8889

Full code coverage report: https://dev.azure.com/dnceng-public/public/_build/results?buildId=912705&view=codecoverage-tab

@stephentoub
stephentoub merged commit e4ebc9e into mainJan 10, 2025
@stephentoub
stephentoub deleted the mbuck/expose-invocation-context branch January 10, 2025 14:06
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Feb 10, 2025
@jeffhandleyjeffhandley added the area-ai Microsoft.Extensions.AI libraries label Mar 7, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-aiMicrosoft.Extensions.AI libraries

Projects

None yet

Development

Successfully merging this pull request may close these issues.

There doesn't seem to be a way to set the context.Terminate in a AIFunction call

5 participants

@MackinnonBuck@dotnet-comment-bot@stephentoub@jeffhandley