Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update LMStudio API Endpoint and added model name support #4732

Merged
merged 10 commits into from
Dec 27, 2024
14 changes: 8 additions & 6 deletions dotnet/src/AutoGen/LMStudioConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,20 @@ namespace AutoGen;
/// </summary>
public class LMStudioConfig : ILLMConfig
{
public LMStudioConfig(string host, int port)
public LMStudioConfig(string host, int port, string modelName)
kimmywork marked this conversation as resolved.
Show resolved Hide resolved
{
this.Host = host;
this.Port = port;
this.Uri = new Uri($"http://{host}:{port}");
this.Uri = new Uri($"http://{host}:{port}/v1");
this.ModelName = modelName;
}

public LMStudioConfig(Uri uri)
public LMStudioConfig(Uri uri, string modelName)
kimmywork marked this conversation as resolved.
Show resolved Hide resolved
{
this.Uri = uri;
this.Host = uri.Host;
this.Port = uri.Port;
this.ModelName = modelName;
}

public string Host { get; }
Expand All @@ -33,15 +35,15 @@ public LMStudioConfig(Uri uri)

public Uri Uri { get; }

public string ModelName { get; }

internal ChatClient CreateChatClient()
{
var client = new OpenAIClient(new ApiKeyCredential("api-key"), new OpenAIClientOptions
{
Endpoint = this.Uri,
});

// model name doesn't matter for LM Studio

return client.GetChatClient("model-name");
return client.GetChatClient(this.ModelName);
}
}