autogen icon indicating copy to clipboard operation
autogen copied to clipboard

[.Net][Feature Request]: Agent as openai-compatible chat service

Open LittleLittleCloud opened this issue 1 year ago • 2 comments

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

Starting an openai-chat-compatible rest service from an arbitrary agent

Describe the solution you'd like

// Server side
IAgent agent;

app.UseAgentAsOpenAIChatCompletionEndpoint(agent) // this will start an OpenAI API at /v1/chat/completions
app.StartAsync();
// client side
// Suppose the service is running at localhost:8080
// We can use `OpenAIChatAgent` to consume that backend
var openaiClient = CreateOpenAIClient(client); // check Example 16 on how to connect to a third-party OpenAI API backend
var openAIAgent = new OpenAIChatAgent(openaiClient, "test", "test")
            .RegisterMessageConnector();

await openAIAgent.SendAsync("Hello");

Additional context

Also cc @ekzhu and @luisquintanilla No response

### Tasks

LittleLittleCloud avatar Apr 26 '24 00:04 LittleLittleCloud

@LittleLittleCloud Great idea!

Would you be able to configure the backend? i.e. OpenAI, Ollama, LMStudio, etc...

luisquintanilla avatar Apr 26 '24 16:04 luisquintanilla

@LittleLittleCloud Great idea!

Would you be able to configure the backend? i.e. OpenAI, Ollama, LMStudio, etc...

Should be? It will work for all ‘IAgent’

LittleLittleCloud avatar Apr 26 '24 16:04 LittleLittleCloud