Merge pull request #516 from iceljc/features/add-text-completion
add open ai text completion
This commit is contained in:
commit
7b1169df7e
|
|
@ -85,9 +85,6 @@
|
||||||
<Content Include="data\agents\01dcc3e5-0af7-49e6-ad7a-a760bd12dc4b\instruction.liquid">
|
<Content Include="data\agents\01dcc3e5-0af7-49e6-ad7a-a760bd12dc4b\instruction.liquid">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="data\agents\01dcc3e5-0af7-49e6-ad7a-a760bd12dc4b\functions.json">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</Content>
|
|
||||||
<Content Include="data\agents\01dcc3e5-0af7-49e6-ad7a-a760bd12dc4b\functions\human_intervention_needed.json">
|
<Content Include="data\agents\01dcc3e5-0af7-49e6-ad7a-a760bd12dc4b\functions\human_intervention_needed.json">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ using BotSharp.Abstraction.Infrastructures.Enums;
|
||||||
using BotSharp.Abstraction.Routing.Models;
|
using BotSharp.Abstraction.Routing.Models;
|
||||||
using BotSharp.Abstraction.Routing.Planning;
|
using BotSharp.Abstraction.Routing.Planning;
|
||||||
using BotSharp.Abstraction.Routing.Settings;
|
using BotSharp.Abstraction.Routing.Settings;
|
||||||
using System.Drawing;
|
|
||||||
|
|
||||||
namespace BotSharp.Core.Routing;
|
namespace BotSharp.Core.Routing;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
[
|
|
||||||
{
|
|
||||||
"name": "human_intervention_needed",
|
|
||||||
"description": "If user wants to speak to human customer service.",
|
|
||||||
"parameters": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"reason": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "why customer needs customer service."
|
|
||||||
},
|
|
||||||
"summary": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "the whole conversation summary with important information"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [ "reason", "summary" ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
using BotSharp.Abstraction.Plugins;
|
using BotSharp.Abstraction.Plugins;
|
||||||
using BotSharp.Abstraction.Settings;
|
using BotSharp.Abstraction.Settings;
|
||||||
using BotSharp.Plugin.AzureOpenAI.Providers;
|
using BotSharp.Plugin.AzureOpenAI.Providers.Chat;
|
||||||
|
using BotSharp.Plugin.AzureOpenAI.Providers.Image;
|
||||||
|
using BotSharp.Plugin.AzureOpenAI.Providers.Text;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
||||||
namespace BotSharp.Platform.AzureAi;
|
namespace BotSharp.Platform.AzureAi;
|
||||||
|
|
@ -24,6 +26,7 @@ public class AzureOpenAiPlugin : IBotSharpPlugin
|
||||||
});
|
});
|
||||||
|
|
||||||
services.AddScoped<ITextCompletion, TextCompletionProvider>();
|
services.AddScoped<ITextCompletion, TextCompletionProvider>();
|
||||||
|
services.AddScoped<ITextCompletion, OpenAiTextCompletionProvider>();
|
||||||
services.AddScoped<IChatCompletion, ChatCompletionProvider>();
|
services.AddScoped<IChatCompletion, ChatCompletionProvider>();
|
||||||
services.AddScoped<IChatCompletion, OpenAiChatCompletionProvider>();
|
services.AddScoped<IChatCompletion, OpenAiChatCompletionProvider>();
|
||||||
services.AddScoped<IImageGeneration, ImageGenerationProvider>();
|
services.AddScoped<IImageGeneration, ImageGenerationProvider>();
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Azure.AI.OpenAI" Version="2.0.0-beta.2" />
|
<PackageReference Include="Azure.AI.OpenAI" Version="2.0.0-beta.2" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace BotSharp.Plugin.AzureOpenAI.Models;
|
||||||
|
|
||||||
|
public class OpenAiTextCompletionRequest : TextCompletionRequest
|
||||||
|
{
|
||||||
|
[JsonPropertyName("model")]
|
||||||
|
public string Model { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace BotSharp.Plugin.AzureOpenAI.Models;
|
||||||
|
|
||||||
|
public class TextCompletionRequest
|
||||||
|
{
|
||||||
|
|
||||||
|
[JsonPropertyName("prompt")]
|
||||||
|
public string Prompt { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[JsonPropertyName("max_tokens")]
|
||||||
|
public int MaxTokens { get; set; } = 256;
|
||||||
|
|
||||||
|
[JsonPropertyName("temperature")]
|
||||||
|
public float Temperature { get; set; } = 0;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace BotSharp.Plugin.AzureOpenAI.Models;
|
||||||
|
|
||||||
|
public class TextCompletionResponse
|
||||||
|
{
|
||||||
|
[JsonPropertyName("id")]
|
||||||
|
public string Id { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("choices")]
|
||||||
|
public IEnumerable<TexCompletionChoice> Choices { get; set; } = new List<TexCompletionChoice>();
|
||||||
|
|
||||||
|
[JsonPropertyName("usage")]
|
||||||
|
public TexCompletionUsage Usage { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TexCompletionChoice
|
||||||
|
{
|
||||||
|
[JsonPropertyName("text")]
|
||||||
|
public string Text { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("finish_reason")]
|
||||||
|
public string FinishReason { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TexCompletionUsage
|
||||||
|
{
|
||||||
|
[JsonPropertyName("prompt_tokens")]
|
||||||
|
public int PromptTokens { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("completion_tokens")]
|
||||||
|
public int CompletionTokens { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("total_tokens")]
|
||||||
|
public int TotalTokens { get; set; }
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
using OpenAI.Chat;
|
using OpenAI.Chat;
|
||||||
|
|
||||||
namespace BotSharp.Plugin.AzureOpenAI.Providers;
|
namespace BotSharp.Plugin.AzureOpenAI.Providers.Chat;
|
||||||
|
|
||||||
public class ChatCompletionProvider : IChatCompletion
|
public class ChatCompletionProvider : IChatCompletion
|
||||||
{
|
{
|
||||||
|
|
@ -12,7 +12,7 @@ public class ChatCompletionProvider : IChatCompletion
|
||||||
|
|
||||||
public virtual string Provider => "azure-openai";
|
public virtual string Provider => "azure-openai";
|
||||||
|
|
||||||
public ChatCompletionProvider(AzureOpenAiSettings settings,
|
public ChatCompletionProvider(AzureOpenAiSettings settings,
|
||||||
ILogger<ChatCompletionProvider> logger,
|
ILogger<ChatCompletionProvider> logger,
|
||||||
IServiceProvider services)
|
IServiceProvider services)
|
||||||
{
|
{
|
||||||
|
|
@ -79,7 +79,7 @@ public class ChatCompletionProvider : IChatCompletion
|
||||||
}
|
}
|
||||||
|
|
||||||
// After chat completion hook
|
// After chat completion hook
|
||||||
foreach(var hook in contentHooks)
|
foreach (var hook in contentHooks)
|
||||||
{
|
{
|
||||||
await hook.AfterGenerated(responseMessage, new TokenStatsModel
|
await hook.AfterGenerated(responseMessage, new TokenStatsModel
|
||||||
{
|
{
|
||||||
|
|
@ -94,8 +94,8 @@ public class ChatCompletionProvider : IChatCompletion
|
||||||
return responseMessage;
|
return responseMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> GetChatCompletionsAsync(Agent agent,
|
public async Task<bool> GetChatCompletionsAsync(Agent agent,
|
||||||
List<RoleDialogModel> conversations,
|
List<RoleDialogModel> conversations,
|
||||||
Func<RoleDialogModel, Task> onMessageReceived,
|
Func<RoleDialogModel, Task> onMessageReceived,
|
||||||
Func<RoleDialogModel, Task> onFunctionExecuting)
|
Func<RoleDialogModel, Task> onFunctionExecuting)
|
||||||
{
|
{
|
||||||
|
|
@ -142,8 +142,8 @@ public class ChatCompletionProvider : IChatCompletion
|
||||||
var funcContextIn = new RoleDialogModel(AgentRole.Function, text)
|
var funcContextIn = new RoleDialogModel(AgentRole.Function, text)
|
||||||
{
|
{
|
||||||
CurrentAgentId = agent.Id,
|
CurrentAgentId = agent.Id,
|
||||||
FunctionName = value.FunctionCall.FunctionName,
|
FunctionName = value.FunctionCall?.FunctionName,
|
||||||
FunctionArgs = value.FunctionCall.FunctionArguments
|
FunctionArgs = value.FunctionCall?.FunctionArguments
|
||||||
};
|
};
|
||||||
|
|
||||||
// Somethings LLM will generate a function name with agent name.
|
// Somethings LLM will generate a function name with agent name.
|
||||||
|
|
@ -177,7 +177,7 @@ public class ChatCompletionProvider : IChatCompletion
|
||||||
if (choice.FinishReason == ChatFinishReason.FunctionCall)
|
if (choice.FinishReason == ChatFinishReason.FunctionCall)
|
||||||
{
|
{
|
||||||
Console.Write(choice.FunctionCallUpdate?.FunctionArgumentsUpdate);
|
Console.Write(choice.FunctionCallUpdate?.FunctionArgumentsUpdate);
|
||||||
|
|
||||||
await onMessageReceived(new RoleDialogModel(AgentRole.Assistant, choice.FunctionCallUpdate?.FunctionArgumentsUpdate));
|
await onMessageReceived(new RoleDialogModel(AgentRole.Assistant, choice.FunctionCallUpdate?.FunctionArgumentsUpdate));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -325,7 +325,7 @@ public class ChatCompletionProvider : IChatCompletion
|
||||||
|
|
||||||
prompt += "\r\n[CONVERSATION]";
|
prompt += "\r\n[CONVERSATION]";
|
||||||
verbose = string.Join("\r\n", messages
|
verbose = string.Join("\r\n", messages
|
||||||
.Where(x => (x as SystemChatMessage) == null)
|
.Where(x => x as SystemChatMessage == null)
|
||||||
.Select(x =>
|
.Select(x =>
|
||||||
{
|
{
|
||||||
var fnMessage = x as FunctionChatMessage;
|
var fnMessage = x as FunctionChatMessage;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace BotSharp.Plugin.AzureOpenAI.Providers;
|
namespace BotSharp.Plugin.AzureOpenAI.Providers.Chat;
|
||||||
|
|
||||||
public class OpenAiChatCompletionProvider : ChatCompletionProvider
|
public class OpenAiChatCompletionProvider : ChatCompletionProvider
|
||||||
{
|
{
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
using OpenAI.Images;
|
using OpenAI.Images;
|
||||||
|
|
||||||
namespace BotSharp.Plugin.AzureOpenAI.Providers;
|
namespace BotSharp.Plugin.AzureOpenAI.Providers.Image;
|
||||||
|
|
||||||
public class ImageGenerationProvider : IImageGeneration
|
public class ImageGenerationProvider : IImageGeneration
|
||||||
{
|
{
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace BotSharp.Plugin.AzureOpenAI.Providers;
|
namespace BotSharp.Plugin.AzureOpenAI.Providers.Image;
|
||||||
|
|
||||||
public class OpenAiImageGenerationProvider : ImageGenerationProvider
|
public class OpenAiImageGenerationProvider : ImageGenerationProvider
|
||||||
{
|
{
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
using BotSharp.Abstraction.MLTasks.Settings;
|
||||||
|
using BotSharp.Plugin.AzureOpenAI.Models;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Net.Mime;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
|
namespace BotSharp.Plugin.AzureOpenAI.Providers.Text;
|
||||||
|
|
||||||
|
public class OpenAiTextCompletionProvider : TextCompletionProvider
|
||||||
|
{
|
||||||
|
private readonly IServiceProvider _services;
|
||||||
|
private readonly ILogger<OpenAiTextCompletionProvider> _logger;
|
||||||
|
|
||||||
|
public override string Provider => "openai";
|
||||||
|
|
||||||
|
public OpenAiTextCompletionProvider(AzureOpenAiSettings settings,
|
||||||
|
ILogger<OpenAiTextCompletionProvider> logger,
|
||||||
|
IServiceProvider services) : base(settings, logger, services)
|
||||||
|
{
|
||||||
|
_services = services;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task<TextCompletionResponse> GetTextCompletion(string apiUrl, string apiKey, string prompt, float temperature, int maxTokens = 256)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var http = _services.GetRequiredService<IHttpClientFactory>();
|
||||||
|
using var httpClient = http.CreateClient();
|
||||||
|
AddHeader(httpClient, apiKey);
|
||||||
|
|
||||||
|
var request = new OpenAiTextCompletionRequest
|
||||||
|
{
|
||||||
|
Model = _model,
|
||||||
|
Prompt = prompt,
|
||||||
|
MaxTokens = maxTokens,
|
||||||
|
Temperature = temperature
|
||||||
|
};
|
||||||
|
var data = JsonSerializer.Serialize(request, _jsonOptions);
|
||||||
|
var httpRequest = new HttpRequestMessage
|
||||||
|
{
|
||||||
|
Method = HttpMethod.Post,
|
||||||
|
RequestUri = new Uri(apiUrl),
|
||||||
|
Content = new StringContent(data, Encoding.UTF8, MediaTypeNames.Application.Json)
|
||||||
|
};
|
||||||
|
var rawResponse = await httpClient.SendAsync(httpRequest);
|
||||||
|
rawResponse.EnsureSuccessStatusCode();
|
||||||
|
|
||||||
|
var responseStr = await rawResponse.Content.ReadAsStringAsync();
|
||||||
|
var response = JsonSerializer.Deserialize<TextCompletionResponse>(responseStr, _jsonOptions);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError($"Error when {Provider}-{_model} generating text... {ex.Message}");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string BuildApiUrl(LlmModelSetting modelSetting)
|
||||||
|
{
|
||||||
|
var endpoint = modelSetting.Endpoint.EndsWith("/") ?
|
||||||
|
modelSetting.Endpoint.Substring(0, modelSetting.Endpoint.Length - 1) : modelSetting.Endpoint;
|
||||||
|
return endpoint ?? string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void AddHeader(HttpClient httpClient, string apiKey)
|
||||||
|
{
|
||||||
|
httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,148 @@
|
||||||
|
using BotSharp.Abstraction.MLTasks.Settings;
|
||||||
|
using BotSharp.Plugin.AzureOpenAI.Models;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Net.Mime;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
|
namespace BotSharp.Plugin.AzureOpenAI.Providers.Text;
|
||||||
|
|
||||||
|
public class TextCompletionProvider : ITextCompletion
|
||||||
|
{
|
||||||
|
private readonly IServiceProvider _services;
|
||||||
|
private readonly ILogger<TextCompletionProvider> _logger;
|
||||||
|
private readonly AzureOpenAiSettings _settings;
|
||||||
|
protected string _model;
|
||||||
|
|
||||||
|
protected readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
||||||
|
PropertyNameCaseInsensitive = true,
|
||||||
|
WriteIndented = true,
|
||||||
|
AllowTrailingCommas = true,
|
||||||
|
};
|
||||||
|
|
||||||
|
public virtual string Provider => "azure-openai";
|
||||||
|
|
||||||
|
public TextCompletionProvider(
|
||||||
|
AzureOpenAiSettings settings,
|
||||||
|
ILogger<TextCompletionProvider> logger,
|
||||||
|
IServiceProvider services)
|
||||||
|
{
|
||||||
|
_services = services;
|
||||||
|
_logger = logger;
|
||||||
|
_settings = settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<string> GetCompletion(string text, string agentId, string messageId)
|
||||||
|
{
|
||||||
|
var contentHooks = _services.GetServices<IContentGeneratingHook>().ToList();
|
||||||
|
|
||||||
|
// Before chat completion hook
|
||||||
|
var agent = new Agent()
|
||||||
|
{
|
||||||
|
Id = agentId,
|
||||||
|
};
|
||||||
|
var message = new RoleDialogModel(AgentRole.User, text)
|
||||||
|
{
|
||||||
|
CurrentAgentId = agentId,
|
||||||
|
MessageId = messageId
|
||||||
|
};
|
||||||
|
|
||||||
|
Task.WaitAll(contentHooks.Select(hook =>
|
||||||
|
hook.BeforeGenerating(agent,
|
||||||
|
new List<RoleDialogModel>
|
||||||
|
{
|
||||||
|
message
|
||||||
|
})).ToArray());
|
||||||
|
|
||||||
|
var state = _services.GetRequiredService<IConversationStateService>();
|
||||||
|
var temperature = float.Parse(state.GetState("temperature", "0.0"));
|
||||||
|
|
||||||
|
var settingsService = _services.GetRequiredService<ILlmProviderService>();
|
||||||
|
var modelSetting = settingsService.GetSetting(Provider, _model);
|
||||||
|
var apiUrl = BuildApiUrl(modelSetting);
|
||||||
|
var apiKey = modelSetting.ApiKey;
|
||||||
|
var response = await GetTextCompletion(apiUrl, apiKey, text, temperature);
|
||||||
|
|
||||||
|
// OpenAI
|
||||||
|
var completion = "";
|
||||||
|
foreach (var t in response.Choices)
|
||||||
|
{
|
||||||
|
completion += t?.Text ?? string.Empty;
|
||||||
|
};
|
||||||
|
|
||||||
|
// After chat completion hook
|
||||||
|
var responseMessage = new RoleDialogModel(AgentRole.Assistant, completion)
|
||||||
|
{
|
||||||
|
CurrentAgentId = agentId,
|
||||||
|
MessageId = messageId
|
||||||
|
};
|
||||||
|
Task.WaitAll(contentHooks.Select(hook =>
|
||||||
|
hook.AfterGenerated(responseMessage, new TokenStatsModel
|
||||||
|
{
|
||||||
|
Prompt = text,
|
||||||
|
Provider = Provider,
|
||||||
|
Model = _model,
|
||||||
|
PromptCount = response.Usage?.PromptTokens ?? default,
|
||||||
|
CompletionCount = response.Usage?.CompletionTokens ?? default
|
||||||
|
})).ToArray());
|
||||||
|
|
||||||
|
return completion.Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetModelName(string model)
|
||||||
|
{
|
||||||
|
_model = model;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual async Task<TextCompletionResponse> GetTextCompletion(string apiUrl, string apiKey, string prompt, float temperature, int maxTokens = 256)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var http = _services.GetRequiredService<IHttpClientFactory>();
|
||||||
|
using var httpClient = http.CreateClient();
|
||||||
|
AddHeader(httpClient, apiKey);
|
||||||
|
|
||||||
|
var request = new TextCompletionRequest
|
||||||
|
{
|
||||||
|
Prompt = prompt,
|
||||||
|
MaxTokens = maxTokens,
|
||||||
|
Temperature = temperature
|
||||||
|
};
|
||||||
|
var data = JsonSerializer.Serialize(request, _jsonOptions);
|
||||||
|
var httpRequest = new HttpRequestMessage
|
||||||
|
{
|
||||||
|
Method = HttpMethod.Post,
|
||||||
|
RequestUri = new Uri(apiUrl),
|
||||||
|
Content = new StringContent(data, Encoding.UTF8, MediaTypeNames.Application.Json)
|
||||||
|
};
|
||||||
|
var rawResponse = await httpClient.SendAsync(httpRequest);
|
||||||
|
rawResponse.EnsureSuccessStatusCode();
|
||||||
|
|
||||||
|
var responseStr = await rawResponse.Content.ReadAsStringAsync();
|
||||||
|
var response = JsonSerializer.Deserialize<TextCompletionResponse>(responseStr, _jsonOptions);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError($"Error when {Provider}-{_model} generating text... {ex.Message}");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual string BuildApiUrl(LlmModelSetting modelSetting)
|
||||||
|
{
|
||||||
|
var url = string.Empty;
|
||||||
|
var endpoint = modelSetting.Endpoint.EndsWith("/") ?
|
||||||
|
modelSetting.Endpoint.Substring(0, modelSetting.Endpoint.Length - 1) : modelSetting.Endpoint;
|
||||||
|
|
||||||
|
url = $"{endpoint}/openai/deployments/{_model}/completions?api-version={modelSetting.Version}";
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void AddHeader(HttpClient httpClient, string apiKey)
|
||||||
|
{
|
||||||
|
httpClient.DefaultRequestHeaders.Add("api-key", $"{apiKey}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,89 +0,0 @@
|
||||||
using OpenAI.Chat;
|
|
||||||
|
|
||||||
namespace BotSharp.Plugin.AzureOpenAI.Providers;
|
|
||||||
|
|
||||||
public class TextCompletionProvider : ITextCompletion
|
|
||||||
{
|
|
||||||
private readonly IServiceProvider _services;
|
|
||||||
private readonly AzureOpenAiSettings _settings;
|
|
||||||
private string _model;
|
|
||||||
public string Provider => "azure-openai";
|
|
||||||
|
|
||||||
public TextCompletionProvider(IServiceProvider services,
|
|
||||||
AzureOpenAiSettings settings)
|
|
||||||
{
|
|
||||||
_services = services;
|
|
||||||
_settings = settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<string> GetCompletion(string text, string agentId, string messageId)
|
|
||||||
{
|
|
||||||
var contentHooks = _services.GetServices<IContentGeneratingHook>().ToList();
|
|
||||||
|
|
||||||
// Before chat completion hook
|
|
||||||
var agent = new Agent()
|
|
||||||
{
|
|
||||||
Id = agentId,
|
|
||||||
};
|
|
||||||
var message = new RoleDialogModel(AgentRole.User, text)
|
|
||||||
{
|
|
||||||
CurrentAgentId = agentId,
|
|
||||||
MessageId = messageId
|
|
||||||
};
|
|
||||||
|
|
||||||
Task.WaitAll(contentHooks.Select(hook =>
|
|
||||||
hook.BeforeGenerating(agent,
|
|
||||||
new List<RoleDialogModel>
|
|
||||||
{
|
|
||||||
message
|
|
||||||
})).ToArray());
|
|
||||||
|
|
||||||
var client = ProviderHelper.GetClient(Provider, _model, _services);
|
|
||||||
var chatClient = client.GetChatClient(_model);
|
|
||||||
|
|
||||||
var messages = new List<ChatMessage>()
|
|
||||||
{
|
|
||||||
new UserChatMessage(text)
|
|
||||||
};
|
|
||||||
|
|
||||||
var state = _services.GetRequiredService<IConversationStateService>();
|
|
||||||
var temperature = float.Parse(state.GetState("temperature", "0.0"));
|
|
||||||
var completionOptions = new ChatCompletionOptions()
|
|
||||||
{
|
|
||||||
MaxTokens = 256,
|
|
||||||
Temperature = temperature
|
|
||||||
};
|
|
||||||
|
|
||||||
var response = await chatClient.CompleteChatAsync(messages, completionOptions);
|
|
||||||
|
|
||||||
// OpenAI
|
|
||||||
var completion = "";
|
|
||||||
foreach (var t in response.Value.Content)
|
|
||||||
{
|
|
||||||
completion += t?.Text ?? string.Empty;
|
|
||||||
};
|
|
||||||
|
|
||||||
// After chat completion hook
|
|
||||||
var responseMessage = new RoleDialogModel(AgentRole.Assistant, completion)
|
|
||||||
{
|
|
||||||
CurrentAgentId = agentId,
|
|
||||||
MessageId = messageId
|
|
||||||
};
|
|
||||||
Task.WaitAll(contentHooks.Select(hook =>
|
|
||||||
hook.AfterGenerated(responseMessage, new TokenStatsModel
|
|
||||||
{
|
|
||||||
Prompt = text,
|
|
||||||
Provider = Provider,
|
|
||||||
Model = _model,
|
|
||||||
PromptCount = response.Value.Usage.InputTokens,
|
|
||||||
CompletionCount = response.Value.Usage.OutputTokens
|
|
||||||
})).ToArray());
|
|
||||||
|
|
||||||
return completion.Trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetModelName(string model)
|
|
||||||
{
|
|
||||||
_model = model;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -22,9 +22,6 @@
|
||||||
<Content Include="data\agents\87c458fc-ec5f-40ae-8ed6-05dda8a07523\agent.json">
|
<Content Include="data\agents\87c458fc-ec5f-40ae-8ed6-05dda8a07523\agent.json">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="data\agents\87c458fc-ec5f-40ae-8ed6-05dda8a07523\functions.json">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</Content>
|
|
||||||
<Content Include="data\agents\87c458fc-ec5f-40ae-8ed6-05dda8a07523\instruction.liquid">
|
<Content Include="data\agents\87c458fc-ec5f-40ae-8ed6-05dda8a07523\instruction.liquid">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
[
|
|
||||||
|
|
||||||
]
|
|
||||||
|
|
@ -12,7 +12,6 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="data\agents\beda4c12-e1ec-4b4b-b328-3df4a6687c4f\agent.json" />
|
<None Remove="data\agents\beda4c12-e1ec-4b4b-b328-3df4a6687c4f\agent.json" />
|
||||||
<None Remove="data\agents\beda4c12-e1ec-4b4b-b328-3df4a6687c4f\functions.json" />
|
|
||||||
<None Remove="data\agents\beda4c12-e1ec-4b4b-b328-3df4a6687c4f\functions\get_table_columns.json" />
|
<None Remove="data\agents\beda4c12-e1ec-4b4b-b328-3df4a6687c4f\functions\get_table_columns.json" />
|
||||||
<None Remove="data\agents\beda4c12-e1ec-4b4b-b328-3df4a6687c4f\functions\lookup_dictionary.json" />
|
<None Remove="data\agents\beda4c12-e1ec-4b4b-b328-3df4a6687c4f\functions\lookup_dictionary.json" />
|
||||||
<None Remove="data\agents\beda4c12-e1ec-4b4b-b328-3df4a6687c4f\functions\sql_insert.json" />
|
<None Remove="data\agents\beda4c12-e1ec-4b4b-b328-3df4a6687c4f\functions\sql_insert.json" />
|
||||||
|
|
@ -28,9 +27,6 @@
|
||||||
<Content Include="data\agents\beda4c12-e1ec-4b4b-b328-3df4a6687c4f\instruction.liquid">
|
<Content Include="data\agents\beda4c12-e1ec-4b4b-b328-3df4a6687c4f\instruction.liquid">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="data\agents\beda4c12-e1ec-4b4b-b328-3df4a6687c4f\functions.json">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</Content>
|
|
||||||
<Content Include="data\agents\beda4c12-e1ec-4b4b-b328-3df4a6687c4f\templates\lookup_dictionary.liquid">
|
<Content Include="data\agents\beda4c12-e1ec-4b4b-b328-3df4a6687c4f\templates\lookup_dictionary.liquid">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
|
|
||||||
|
|
@ -1,158 +0,0 @@
|
||||||
[
|
|
||||||
{
|
|
||||||
"name": "get_table_columns",
|
|
||||||
"description": "Get related table columns and foreign key informations",
|
|
||||||
"parameters": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"table": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "table name"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [ "table" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "sql_insert",
|
|
||||||
"description": "Insert query is generated if the record doesn't exist.",
|
|
||||||
"parameters": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"sql_statement": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "INSERT SQL statement. The value should use the parameter name like @field."
|
|
||||||
},
|
|
||||||
"reason": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "reason"
|
|
||||||
},
|
|
||||||
"table": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "related table"
|
|
||||||
},
|
|
||||||
"parameters": {
|
|
||||||
"type": "array",
|
|
||||||
"description": "a list of parameters in the statement match with the variables",
|
|
||||||
"items": {
|
|
||||||
"type": "object",
|
|
||||||
"description": "{name:'', value:''}",
|
|
||||||
"properties": {
|
|
||||||
"name": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "field name"
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "real value inferred by the context"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [ "name", "value" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"return_field": {
|
|
||||||
"type": "object",
|
|
||||||
"description": "the name and alias for the return field",
|
|
||||||
"properties": {
|
|
||||||
"name": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "field name"
|
|
||||||
},
|
|
||||||
"alias": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "meaningful field alias"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [ "name", "alias" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [ "sql_statement", "reason", "table", "parameters", "return_field" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "sql_select",
|
|
||||||
"description": "Get the specific value from table",
|
|
||||||
"parameters": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"sql_statement": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "SQL statement with SELECT"
|
|
||||||
},
|
|
||||||
"reason": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "reason"
|
|
||||||
},
|
|
||||||
"table": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "related table"
|
|
||||||
},
|
|
||||||
"parameters": {
|
|
||||||
"type": "array",
|
|
||||||
"description": "data criteria for the query",
|
|
||||||
"items": {
|
|
||||||
"type": "object",
|
|
||||||
"description": "the name and value for the parameter",
|
|
||||||
"properties": {
|
|
||||||
"name": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "field name"
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "real value inferred by the context"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [ "name", "value" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"return_field": {
|
|
||||||
"type": "object",
|
|
||||||
"description": "the name and alias for the return field",
|
|
||||||
"properties": {
|
|
||||||
"name": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "field in the table"
|
|
||||||
},
|
|
||||||
"alias": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "meaningful field alias"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [ "name", "value" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [ "sql_statement", "reason", "table", "parameters", "return_field" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "lookup_dictionary",
|
|
||||||
"description": "Get id from dictionary table by keyword if tool or solution mentioned this approach",
|
|
||||||
"parameters": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"table": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "table name"
|
|
||||||
},
|
|
||||||
"keyword": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "table name"
|
|
||||||
},
|
|
||||||
"reason": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "the reason why you need to call lookup_dictionary"
|
|
||||||
},
|
|
||||||
"columns": {
|
|
||||||
"type": "array",
|
|
||||||
"description": "columns",
|
|
||||||
"items": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "column"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [ "table", "keyword", "reason", "columns" ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
@ -24,7 +24,6 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\agent.json" />
|
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\agent.json" />
|
||||||
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions.json" />
|
|
||||||
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\change_checkbox.json" />
|
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\change_checkbox.json" />
|
||||||
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\change_list_value.json" />
|
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\change_list_value.json" />
|
||||||
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\check_radio_button.json" />
|
<None Remove="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions\check_radio_button.json" />
|
||||||
|
|
@ -49,9 +48,6 @@
|
||||||
<Content Include="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\agent.json">
|
<Content Include="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\agent.json">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\functions.json">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</Content>
|
|
||||||
<Content Include="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\instruction.liquid">
|
<Content Include="data\agents\f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b\instruction.liquid">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
|
|
||||||
|
|
@ -1,246 +0,0 @@
|
||||||
[
|
|
||||||
{
|
|
||||||
"name": "open_browser",
|
|
||||||
"description": "open a browser",
|
|
||||||
"parameters": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"url": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "website url starts with https://"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [ "url" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "close_browser",
|
|
||||||
"description": "Close browser",
|
|
||||||
"parameters": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
},
|
|
||||||
"required": []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "go_to_page",
|
|
||||||
"description": "go to another page",
|
|
||||||
"parameters": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"url": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "page url start with https://"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [ "url" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "scroll_page",
|
|
||||||
"description": "Scroll page down or up",
|
|
||||||
"parameters": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"direction": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "down, up, left, right"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [ "direction" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "take_screenshot",
|
|
||||||
"description": "Tak screenshot to show current page screen",
|
|
||||||
"parameters": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
},
|
|
||||||
"required": []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "click_button",
|
|
||||||
"description": "Click a button in a web page.",
|
|
||||||
"parameters": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"element_name": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "the html element name."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [ "element_name" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "extract_data_from_page",
|
|
||||||
"description": "Extract data from current web page.",
|
|
||||||
"parameters": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"question": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "the information user wants to know"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [ "question" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "input_user_text",
|
|
||||||
"description": "Input non-sensitive text in current web page.",
|
|
||||||
"parameters": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"element_text": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "text or placeholder shown in the element."
|
|
||||||
},
|
|
||||||
"input_text": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "non-sensitive text user provided."
|
|
||||||
},
|
|
||||||
"press_enter": {
|
|
||||||
"type": "boolean",
|
|
||||||
"description": "whether to press Enter key"
|
|
||||||
},
|
|
||||||
"attribute_name": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "attribute name in the element"
|
|
||||||
},
|
|
||||||
"attribute_value": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "attribute value in the element"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [ "element_text", "input_text" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "change_list_value",
|
|
||||||
"description": "Update value from dropdown list or radio button",
|
|
||||||
"parameters": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"element_name": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "the html selection element name."
|
|
||||||
},
|
|
||||||
"update_value": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "the value in the list."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [ "element_name", "update_value" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "input_user_password",
|
|
||||||
"description": "Input password in current web page",
|
|
||||||
"parameters": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"password": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "user password"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [ "password" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "change_checkbox",
|
|
||||||
"description": "Check or uncheck checkbox",
|
|
||||||
"parameters": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"element_text": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "the element title"
|
|
||||||
},
|
|
||||||
"update_value": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "check or uncheck"
|
|
||||||
},
|
|
||||||
"match_rule": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "text matching rule: EndWith, StartWith, Contains, Match"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [ "element_text", "update_value", "match_rule" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "click_element",
|
|
||||||
"description": "Click or check an element contains some text",
|
|
||||||
"parameters": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"element_type": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "the element tag name"
|
|
||||||
},
|
|
||||||
"element_text": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "text or placeholder shown in the element."
|
|
||||||
},
|
|
||||||
"attribute_name": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "attribute name in the element"
|
|
||||||
},
|
|
||||||
"attribute_value": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "attribute value in the element"
|
|
||||||
},
|
|
||||||
"match_rule": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "text matching rule: EndWith, StartWith, Contains, Match"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [ "element_type", "element_text", "match_rule" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "check_radio_button",
|
|
||||||
"description": "Check value in a radio button",
|
|
||||||
"parameters": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"element_text": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "the element title"
|
|
||||||
},
|
|
||||||
"update_value": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "the value in the radio button."
|
|
||||||
},
|
|
||||||
"match_rule": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "text matching rule: EndWith, StartWith, Contains, Match"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [ "update_value", "element_text", "match_rule" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "send_http_request",
|
|
||||||
"description": "Send http request to remote server",
|
|
||||||
"parameters": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"url": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "page url start with https://"
|
|
||||||
},
|
|
||||||
"payload": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "request body"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [ "url", "payload" ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
@ -23,18 +23,15 @@
|
||||||
<None Remove="data\agents\8970b1e5-d260-4e2c-90b1-f1415a257c18\agent.json" />
|
<None Remove="data\agents\8970b1e5-d260-4e2c-90b1-f1415a257c18\agent.json" />
|
||||||
<None Remove="data\agents\8970b1e5-d260-4e2c-90b1-f1415a257c18\templates\task.place_pizza_order.liquid" />
|
<None Remove="data\agents\8970b1e5-d260-4e2c-90b1-f1415a257c18\templates\task.place_pizza_order.liquid" />
|
||||||
<None Remove="data\agents\b284db86-e9c2-4c25-a59e-4649797dd130\agent.json" />
|
<None Remove="data\agents\b284db86-e9c2-4c25-a59e-4649797dd130\agent.json" />
|
||||||
<None Remove="data\agents\b284db86-e9c2-4c25-a59e-4649797dd130\functions.json" />
|
|
||||||
<None Remove="data\agents\b284db86-e9c2-4c25-a59e-4649797dd130\functions\get_order_status.json" />
|
<None Remove="data\agents\b284db86-e9c2-4c25-a59e-4649797dd130\functions\get_order_status.json" />
|
||||||
<None Remove="data\agents\b284db86-e9c2-4c25-a59e-4649797dd130\instruction.liquid" />
|
<None Remove="data\agents\b284db86-e9c2-4c25-a59e-4649797dd130\instruction.liquid" />
|
||||||
<None Remove="data\agents\c2b57a74-ae4e-4c81-b3ad-9ac5bff982bd\agent.json" />
|
<None Remove="data\agents\c2b57a74-ae4e-4c81-b3ad-9ac5bff982bd\agent.json" />
|
||||||
<None Remove="data\agents\c2b57a74-ae4e-4c81-b3ad-9ac5bff982bd\functions.json" />
|
|
||||||
<None Remove="data\agents\c2b57a74-ae4e-4c81-b3ad-9ac5bff982bd\functions\get_pizza_price.json" />
|
<None Remove="data\agents\c2b57a74-ae4e-4c81-b3ad-9ac5bff982bd\functions\get_pizza_price.json" />
|
||||||
<None Remove="data\agents\c2b57a74-ae4e-4c81-b3ad-9ac5bff982bd\functions\get_pizza_types.json" />
|
<None Remove="data\agents\c2b57a74-ae4e-4c81-b3ad-9ac5bff982bd\functions\get_pizza_types.json" />
|
||||||
<None Remove="data\agents\c2b57a74-ae4e-4c81-b3ad-9ac5bff982bd\functions\place_an_order.json" />
|
<None Remove="data\agents\c2b57a74-ae4e-4c81-b3ad-9ac5bff982bd\functions\place_an_order.json" />
|
||||||
<None Remove="data\agents\c2b57a74-ae4e-4c81-b3ad-9ac5bff982bd\instruction.liquid" />
|
<None Remove="data\agents\c2b57a74-ae4e-4c81-b3ad-9ac5bff982bd\instruction.liquid" />
|
||||||
<None Remove="data\agents\c2b57a74-ae4e-4c81-b3ad-9ac5bff982bd\responses\func.get_pizza_price.0.liquid" />
|
<None Remove="data\agents\c2b57a74-ae4e-4c81-b3ad-9ac5bff982bd\responses\func.get_pizza_price.0.liquid" />
|
||||||
<None Remove="data\agents\fe8c60aa-b114-4ef3-93cb-a8efeac80f75\agent.json" />
|
<None Remove="data\agents\fe8c60aa-b114-4ef3-93cb-a8efeac80f75\agent.json" />
|
||||||
<None Remove="data\agents\fe8c60aa-b114-4ef3-93cb-a8efeac80f75\functions.json" />
|
|
||||||
<None Remove="data\agents\fe8c60aa-b114-4ef3-93cb-a8efeac80f75\functions\make_payment.json" />
|
<None Remove="data\agents\fe8c60aa-b114-4ef3-93cb-a8efeac80f75\functions\make_payment.json" />
|
||||||
<None Remove="data\agents\fe8c60aa-b114-4ef3-93cb-a8efeac80f75\instruction.liquid" />
|
<None Remove="data\agents\fe8c60aa-b114-4ef3-93cb-a8efeac80f75\instruction.liquid" />
|
||||||
<None Remove="data\users\10d12798-08fb-4aa6-977b-5dd94d82dbfe\user.json" />
|
<None Remove="data\users\10d12798-08fb-4aa6-977b-5dd94d82dbfe\user.json" />
|
||||||
|
|
@ -53,18 +50,12 @@
|
||||||
<Content Include="data\agents\b284db86-e9c2-4c25-a59e-4649797dd130\agent.json">
|
<Content Include="data\agents\b284db86-e9c2-4c25-a59e-4649797dd130\agent.json">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="data\agents\b284db86-e9c2-4c25-a59e-4649797dd130\functions.json">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</Content>
|
|
||||||
<Content Include="data\agents\b284db86-e9c2-4c25-a59e-4649797dd130\instruction.liquid">
|
<Content Include="data\agents\b284db86-e9c2-4c25-a59e-4649797dd130\instruction.liquid">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="data\agents\c2b57a74-ae4e-4c81-b3ad-9ac5bff982bd\agent.json">
|
<Content Include="data\agents\c2b57a74-ae4e-4c81-b3ad-9ac5bff982bd\agent.json">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="data\agents\c2b57a74-ae4e-4c81-b3ad-9ac5bff982bd\functions.json">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</Content>
|
|
||||||
<Content Include="data\agents\c2b57a74-ae4e-4c81-b3ad-9ac5bff982bd\instruction.liquid">
|
<Content Include="data\agents\c2b57a74-ae4e-4c81-b3ad-9ac5bff982bd\instruction.liquid">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
|
@ -74,9 +65,6 @@
|
||||||
<Content Include="data\agents\fe8c60aa-b114-4ef3-93cb-a8efeac80f75\agent.json">
|
<Content Include="data\agents\fe8c60aa-b114-4ef3-93cb-a8efeac80f75\agent.json">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="data\agents\fe8c60aa-b114-4ef3-93cb-a8efeac80f75\functions.json">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</Content>
|
|
||||||
<Content Include="data\agents\fe8c60aa-b114-4ef3-93cb-a8efeac80f75\instruction.liquid">
|
<Content Include="data\agents\fe8c60aa-b114-4ef3-93cb-a8efeac80f75\instruction.liquid">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
[
|
|
||||||
{
|
|
||||||
"name": "get_order_status",
|
|
||||||
"description": "get order status like delivery remaining time",
|
|
||||||
"parameters": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"order_number": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "order number."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": ["order_number"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
||||||
[
|
|
||||||
{
|
|
||||||
"name": "get_pizza_price",
|
|
||||||
"description": "call this function to get the pizza price",
|
|
||||||
"parameters": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"pizza_type": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "The pizza type."
|
|
||||||
},
|
|
||||||
"quantity": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "quantity of pizza."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": ["pizza_type", "quantity"]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "get_pizza_types",
|
|
||||||
"description": "get all pizza types",
|
|
||||||
"parameters": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {},
|
|
||||||
"required": []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "place_an_order",
|
|
||||||
"description": "Place an order when user has confirmed the pizza type and quantity.",
|
|
||||||
"parameters": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"pizza_type": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "The pizza type."
|
|
||||||
},
|
|
||||||
"quantity": {
|
|
||||||
"type": "number",
|
|
||||||
"description": "quantity of pizza."
|
|
||||||
},
|
|
||||||
"unit_price": {
|
|
||||||
"type": "number",
|
|
||||||
"description": "unit price"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": ["pizza_type", "quantity", "unit_price"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
[
|
|
||||||
{
|
|
||||||
"name": "make_payment",
|
|
||||||
"description": "call this function to make payment",
|
|
||||||
"parameters": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"order_number": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "order number."
|
|
||||||
},
|
|
||||||
"total_amount": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "total amount."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": ["order_number", "total_amount"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
Loading…
Reference in a new issue