Skip to content

Python: Use a real chat client in Purview chat middleware examples - #10079

Draft
Naveen Chatlapalli (1aifanatic) wants to merge 1 commit into
microsoft:mainfrom
1aifanatic:contrib/python-purview-chat-client-docs
Draft

Naveen Chatlapalli (1aifanatic) wants to merge 1 commit into
microsoft:mainfrom
1aifanatic:contrib/python-purview-chat-client-docs

Conversation

@1aifanatic

Copy link
Copy Markdown
Contributor

Motivation & Context

The PurviewChatPolicyMiddleware docstring and the Purview README's "Store and retention" snippet both build a client with ChatClient(...). agent_framework has no ChatClient, so from agent_framework import ChatClient raises ImportError. The README snippet then assigns client.chat_middleware instead of passing middleware= to the constructor. That works, but it doesn't match the other snippets in the same README.

Description & Review Guide

  • What are the major changes?
    • Docstring: use OpenAIChatClient(middleware=[PurviewChatPolicyMiddleware(...)]), and add the blank line that .. code-block:: needs to render.
    • README: same constructor form. That section is about Responses-style storage, so OpenAIChatClient (Responses API, stores by default) is the client the surrounding text describes.
  • What is the impact of these changes? Documentation only.
  • What do you want reviewers to focus on? Nothing in particular.

I ran both snippets: the client carries PurviewChatPolicyMiddleware in chat_middleware, and the README agent has store=False in its default options.

Related Issue

N/A - trivial change: two documentation snippets are corrected to an existing chat client class.

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

AI assistance details: Claude Code helped find the missing import by executing the docstring examples, make the change, verify the snippets, and draft this description.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 4, 2026 05:36
@agent-framework-automation agent-framework-automation Bot added documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python labels Nov 4, 2026

Copilot AI 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.

🟢 Approval recommended

No active review issues are reported for the documentation-only corrections to the Purview middleware examples.

No open issues 🎉

What changed in this PR

This documentation-only PR corrects Purview chat middleware examples to use the existing OpenAIChatClient class instead of the nonexistent ChatClient.

Changes:

  • Updates both examples to configure Purview middleware through the client constructor.
  • Corrects the docstring import and adds the blank line required for code-block rendering.
File Description
python/​packages/​purview/​README.md Updates the storage and retention example to use OpenAIChatClient(middleware=...).
python/​packages/​purview/​agent_framework_purview/​_middleware.py Corrects the client import, construction, and code-block formatting in the middleware docstring.

Review effort: Balanced

This branch was previously deployed

1 inactive deployment
github-app-auth — a9116f8f Deployed Nov 4, 2026 by 1aifanatic via team_check #8668
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants