microsoft / autogen

A programming framework for agentic AI 🤖
https://microsoft.github.io/autogen/
Creative Commons Attribution 4.0 International
30.04k stars 4.38k forks source link

[.Net][Feature Request]: Support custom HttpClient #2614

Closed xuzeyu91 closed 3 months ago

xuzeyu91 commented 3 months ago

Is your feature request related to a problem? Please describe.

I hope to customize HttpClient similar to Semantic Kernel

Describe the solution you'd like

Similar to this

     var assistantAgent = new GPTAgent(
         name: "assistant",
         systemMessage: "You are an assistant that help user to do some tasks.",
         config: gpt35,
         httpclient:httpclient)
         .RegisterPrintMessage();

Additional context

No response

LittleLittleCloud commented 3 months ago

@xuzeyu91 Could you tell us why you want to pass a httpclient? Is that for retry policy/connect to third party openai, etc...

xuzeyu91 commented 3 months ago

Could you tell us why you want to pass a httpclient? Is that for retry policy/connect to third party openai, etc...

This will be of great help to us, such as viewing the Prompt for analyzing requests, printing input-output response logs, and connecting to third party openai

LittleLittleCloud commented 3 months ago

@xuzeyu91

Thanks, maybe consider using OpenAIChatAgent, which accepts an OpenAIClient in it's constructor and you can pass your http client when creating OpenAIClient

You can check the example here

GPTAgent also uses OpenAIChatAgent, in fact GPTAgent is equivalent to OpenAIChatAgent + OpenAI Message Connector + FunctionCall Middleware, so you can achieve the same behavior of using OpenAIChatAgent in your code

xuzeyu91 commented 3 months ago

Thank you.

LittleLittleCloud commented 3 months ago

@xuzeyu91 Does my answer works for you, could I close this issue as completed?

xuzeyu91 commented 3 months ago

Does my answer works for you, could I close this issue as completed?

Thank you, no problem