|
|
|
@ -9,6 +9,8 @@ public class OpenAISdkTest
|
|
|
|
|
private IOptionsMonitor<OllamaServerOption> _ollamaOptionsMonitor;
|
|
|
|
|
private OpenAIClient _defaultOpenAIClient;
|
|
|
|
|
private ChatClient _singtonChatClient;
|
|
|
|
|
private OpenAIClient _uiUiApiClient;
|
|
|
|
|
private OpenAIClient _zipuApiClient;
|
|
|
|
|
|
|
|
|
|
public OpenAISdkTest
|
|
|
|
|
(
|
|
|
|
@ -17,13 +19,18 @@ public class OpenAISdkTest
|
|
|
|
|
IOptionsMonitor<OllamaServerOption> ollamaOptionsMonitor,
|
|
|
|
|
|
|
|
|
|
//使用了FromKeyedServices特性,所以需要使用IKeyedServiceCollection注册服务
|
|
|
|
|
[FromKeyedServices("OpenAIChatClient")]ChatClient singtonChatClient
|
|
|
|
|
[FromKeyedServices("OpenAIChatClient")]ChatClient singtonChatClient,
|
|
|
|
|
|
|
|
|
|
[FromKeyedServices("UiUiAPIClient")]OpenAIClient uiUiApiClient,
|
|
|
|
|
[FromKeyedServices("ZipuAPIClient")]OpenAIClient zipuApiClient
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
_output = outputHelper;
|
|
|
|
|
_defaultOpenAIClient = defaultOpenAIClient;
|
|
|
|
|
_ollamaOptionsMonitor = ollamaOptionsMonitor;
|
|
|
|
|
_singtonChatClient = singtonChatClient;
|
|
|
|
|
_uiUiApiClient = uiUiApiClient;
|
|
|
|
|
_zipuApiClient = zipuApiClient;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 使用客户端库
|
|
|
|
@ -999,4 +1006,28 @@ public class OpenAISdkTest
|
|
|
|
|
return $"31 {unit}";
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 其它平台测试
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void UiUiAPI_Test()
|
|
|
|
|
{
|
|
|
|
|
var chatClient = _uiUiApiClient.GetChatClient("gpt-3.5-turbo");
|
|
|
|
|
|
|
|
|
|
var r = chatClient.CompleteChat("你好");
|
|
|
|
|
|
|
|
|
|
_output.WriteLine(r.Value.Content.First().Text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void Zipu_Test()
|
|
|
|
|
{
|
|
|
|
|
var chatClient = _zipuApiClient.GetChatClient("GLM-4.5-Flash");
|
|
|
|
|
|
|
|
|
|
var r = chatClient.CompleteChat("你好");
|
|
|
|
|
|
|
|
|
|
_output.WriteLine(r.Value.Content.First().Text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|