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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions dotnet/src/AutoGen/LMStudioConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,28 @@ 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");
if (modelName == null)
{
throw new ArgumentNullException("modelName is a required property for LMStudioConfig and cannot be null");
}
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;
if (modelName == null)
{
throw new ArgumentNullException("modelName is a required property for LMStudioConfig and cannot be null");
}
this.ModelName = modelName;
}

public string Host { get; }
Expand All @@ -33,15 +43,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);
}
}
Loading