Код: Выделить всё
Error: 2 is greater than the maximum of 1 - 'top_p'
Status: 400 (model_error)
Content:
{
"error": {
"message": "2 is greater than the maximum of 1 - 'top_p'",
"type": "invalid_request_error",
"param": null,
"code": null
}
}
Код: Выделить всё
using Microsoft.Extensions.Configuration;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.OpenAI;
using Kernel = Microsoft.SemanticKernel.Kernel;
var config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json")
.Build();
var azureOpenAISettings = config.GetRequiredSection("AzureOpenAISettings");
var openAIPromptSettings = config.GetRequiredSection("OpenAIPromptSettings");
string model = azureOpenAISettings["OpenAIModel"];
string endpoint = azureOpenAISettings["Endpoint"]; //"your_endpoint_url";
string apiKey = azureOpenAISettings["OpenAIApiKey"]; //"your_api_key";
int temperature;
double topP;
int maxTokens;
int.TryParse(openAIPromptSettings["Temperature"], out temperature);
double.TryParse(openAIPromptSettings["TopP"], out topP);
int.TryParse(openAIPromptSettings["MaxTokens"], out maxTokens);
OpenAIPromptExecutionSettings executionSettings = new OpenAIPromptExecutionSettings()
{
Temperature = temperature,
TopP = topP,
MaxTokens = maxTokens
};
var builder = Kernel.CreateBuilder();
builder.AddAzureOpenAIChatCompletion(model, endpoint, apiKey);
var kernel = builder.Build();
string promptTemplate = @"ChatBot: How can I help you?
User: {{$input}}
---------------------------------------------------
Return data requested by user: ";
var arguments = new KernelArguments() { ["input"] = "Could you please briefly describe how to become a c# developer?" };
var function = kernel.CreateFunctionFromPrompt(promptTemplate, executionSettings);
try
{
Console.WriteLine(await kernel.InvokeAsync(function, arguments));
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
Код: Выделить всё
{
"AzureOpenAISettings": {
"Endpoint": "https://Endpoint",
"OpenAIApiKey": "OpenAIApiKey",
"OpenAIModel": "OpenAIModel",
"OpenAIApiVersion": "2023-03-15-preview",
"ServiceId": "AzureGtp4TurboService"
},
"OpenAIPromptSettings": {
"Temperature": 0.5,
"TopP": 0.2,
"MaxTokens": 200
}
}
Подробнее здесь: https://stackoverflow.com/questions/792 ... of-1-top-p
Мобильная версия