How to customize chat client with additional functionality #2704
-
|
Hi, I am trying to move my direct OpenAI calls to the Responses API to an agent. The issue that I have is that I am currently using two pieces of functionality that OpenAI provides that are not part of the standard OpenAI chat agent in the Agent Framework - direct calling of an MCP server by OpenAI, and the use of prompt templates inside of OpenAI. I ended up writing my own IChatClient that converts Agent Framework calls into direct OpenAI calls, and then translates the responses back, but I am worried I am going to forget to copy over something. Is there another way to extend the current OpenAI chat client? Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
This is supported, eg you can put a HostedMcpServerTool into your tools collection.
Meaning you want to set some additional properties on the ResponseCreationOptioms? You can use the RawRepresentationFactory property to create the ResponseCreationOptioms you want to seed the IChatClient with. It'll use yours instead of creating one fresh, and you can populate on that instance whatever you want. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks Stephen, I managed to make it work, with some modifications.
In case anyone else is interested, here is the code: |
Beta Was this translation helpful? Give feedback.
This is supported, eg you can put a HostedMcpServerTool into your tools collection.
Meaning you want to set some additional properties on the ResponseCreationOptioms? You can use the RawRepresentationFactory property to create the ResponseCreationOptioms you want to seed the IChatClient with. It'll use yours instead of creating one fresh, and you can populate on that instance whatever you want.