* add lmstudio agent to assistant agent

* fix #2609

* update updatelog

* Update Directory.Build.props
This commit is contained in:
Xiaoyun Zhang
2024-05-07 14:37:46 -07:00
committed by GitHub
parent ecc4113a7e
commit f75103f254
7 changed files with 72 additions and 10 deletions

View File

@@ -13,6 +13,15 @@ public class LMStudioConfig : ILLMConfig
this.Host = host;
this.Port = port;
this.Version = version;
this.Uri = new Uri($"http://{host}:{port}/v{version}");
}
public LMStudioConfig(Uri uri)
{
this.Uri = uri;
this.Host = uri.Host;
this.Port = uri.Port;
this.Version = int.Parse(uri.Segments[1].TrimStart('v'));
}
public string Host { get; }
@@ -21,5 +30,5 @@ public class LMStudioConfig : ILLMConfig
public int Version { get; }
public Uri Uri => new Uri($"http://{Host}:{Port}/v{Version}");
public Uri Uri { get; }
}

View File

@@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using AutoGen.LMStudio;
using AutoGen.OpenAI;
namespace AutoGen;
@@ -74,15 +75,25 @@ public class ConversableAgent : IAgent
this.functions = llmConfig?.FunctionContracts;
}
/// <summary>
/// For test purpose only.
/// </summary>
internal IAgent? InnerAgent => this.innerAgent;
private IAgent? CreateInnerAgentFromConfigList(ConversableAgentConfig config)
{
IAgent? agent = null;
foreach (var llmConfig in config.ConfigList ?? Enumerable.Empty<ILLMConfig>())
{
var nextAgent = llmConfig switch
IAgent nextAgent = llmConfig switch
{
AzureOpenAIConfig azureConfig => new GPTAgent(this.Name!, this.systemMessage, azureConfig, temperature: config.Temperature ?? 0),
OpenAIConfig openAIConfig => new GPTAgent(this.Name!, this.systemMessage, openAIConfig, temperature: config.Temperature ?? 0),
LMStudioConfig lmStudioConfig => new LMStudioAgent(
name: this.Name,
config: lmStudioConfig,
systemMessage: this.systemMessage,
temperature: config.Temperature ?? 0),
_ => throw new ArgumentException($"Unsupported config type {llmConfig.GetType()}"),
};

View File

@@ -26,5 +26,9 @@
<ProjectReference Include="..\AutoGen.Core\AutoGen.Core.csproj" />
<ProjectReference Include="..\AutoGen.OpenAI\AutoGen.OpenAI.csproj" />
</ItemGroup>
<ItemGroup>
<InternalsVisibleTo Include="AutoGen.Tests" />
</ItemGroup>
</Project>