mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-06-27 14:36:27 +00:00
removed weather demo tool
This commit is contained in:
parent
f8ba55bcd9
commit
9b638b8a5a
@ -170,7 +170,6 @@ internal sealed class Program
|
||||
builder.Services.AddMudMarkdownClipboardService<MarkdownClipboardService>();
|
||||
builder.Services.AddSingleton<SettingsManager>();
|
||||
builder.Services.AddSingleton<ToolSettingsService>();
|
||||
builder.Services.AddSingleton<IToolImplementation, GetCurrentWeatherTool>();
|
||||
builder.Services.AddSingleton<IToolImplementation, ReadWebPageTool>();
|
||||
builder.Services.AddSingleton<IToolImplementation, SearXNGWebSearchTool>();
|
||||
builder.Services.AddSingleton<ToolRegistry>();
|
||||
|
||||
@ -1,46 +0,0 @@
|
||||
using System.Text.Json;
|
||||
using AIStudio.Tools.PluginSystem;
|
||||
|
||||
namespace AIStudio.Tools.ToolCallingSystem.ToolCallingImplementations;
|
||||
|
||||
public sealed class GetCurrentWeatherTool : IToolImplementation
|
||||
{
|
||||
private static string TB(string fallbackEN) => I18N.I.T(fallbackEN, typeof(GetCurrentWeatherTool).Namespace, nameof(GetCurrentWeatherTool));
|
||||
|
||||
public string ImplementationKey => "get_current_weather";
|
||||
|
||||
public string Icon => Icons.Material.Filled.Cloud;
|
||||
|
||||
public IReadOnlySet<string> SensitiveTraceArgumentNames => new HashSet<string>(StringComparer.Ordinal);
|
||||
|
||||
public string GetDisplayName() => TB("Current Weather");
|
||||
|
||||
public string GetDescription() => TB("Use this demo tool to retrieve the current weather for a given city and state. It is primarily meant to demonstrate tool calling and tool settings in AI Studio.");
|
||||
|
||||
public string GetSettingsFieldLabel(string fieldName, ToolSettingsFieldDefinition fieldDefinition) => fieldName switch
|
||||
{
|
||||
"demoLabel" => TB("Demo Label"),
|
||||
_ => TB(fieldDefinition.Title),
|
||||
};
|
||||
|
||||
public string GetSettingsFieldDescription(string fieldName, ToolSettingsFieldDefinition fieldDefinition) => fieldName switch
|
||||
{
|
||||
"demoLabel" => TB("Required demo setting for validating tool settings in tests. It does not affect the weather result."),
|
||||
_ => TB(fieldDefinition.Description),
|
||||
};
|
||||
|
||||
public Task<ToolExecutionResult> ExecuteAsync(JsonElement arguments, ToolExecutionContext context, CancellationToken token = default)
|
||||
{
|
||||
var city = arguments.TryGetProperty("city", out var cityValue) ? cityValue.GetString() ?? string.Empty : string.Empty;
|
||||
var state = arguments.TryGetProperty("state", out var stateValue) ? stateValue.GetString() ?? string.Empty : string.Empty;
|
||||
var unit = arguments.TryGetProperty("unit", out var unitValue) ? unitValue.GetString() ?? string.Empty : string.Empty;
|
||||
|
||||
if (unit is not ("celsius" or "fahrenheit"))
|
||||
throw new ArgumentException($"Invalid unit '{unit}'.");
|
||||
|
||||
return Task.FromResult(new ToolExecutionResult
|
||||
{
|
||||
TextContent = $"The weather in {city}, {state} is 85 degrees {unit}. It is partly cloudy with highs in the 90's.",
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1,53 +0,0 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "get_current_weather",
|
||||
"implementationKey": "get_current_weather",
|
||||
"visibleIn": {
|
||||
"chat": true,
|
||||
"assistants": true
|
||||
},
|
||||
"settingsSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"demoLabel": {
|
||||
"type": "string",
|
||||
"secret": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"demoLabel"
|
||||
]
|
||||
},
|
||||
"function": {
|
||||
"name": "get_current_weather",
|
||||
"description": "Get the current weather in a given location.",
|
||||
"strict": true,
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"city": {
|
||||
"type": "string",
|
||||
"description": "The city to find the weather for, e.g. 'San Francisco'."
|
||||
},
|
||||
"state": {
|
||||
"type": "string",
|
||||
"description": "The two-letter abbreviation for the state, e.g. 'CA'."
|
||||
},
|
||||
"unit": {
|
||||
"type": "string",
|
||||
"description": "The unit to fetch the temperature in.",
|
||||
"enum": [
|
||||
"celsius",
|
||||
"fahrenheit"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"city",
|
||||
"state",
|
||||
"unit"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user