Yess
Some checks failed
Mirror to Gitea / git-sync (push) Has been cancelled

This commit is contained in:
2026-03-28 00:26:55 +02:00
parent ea2d84f5cc
commit ae0994409a
15 changed files with 660 additions and 94 deletions

View File

@@ -1,20 +1,14 @@
using Avalonia.Controls;
using Avalonia.Controls;
using System.Collections.Generic;
using System.Text.Json;
using VisionAsist.SDK;
namespace ModuleWeather;
public class WeatherModule : IModule
{
public static string port;
public WeatherModule()
{
}
public string Name => "Модуль компиляции ардуино";
public string[] GetCommands() => new[] { "погода", "поверни на *", "верни *" };
public string Name => "WeatherModule";
public string Description => "Модуль для получения данных о погоде";
public void Settings(object[] args)
{
// args[0] — это родительское окно из Ядра
@@ -33,21 +27,76 @@ public class WeatherModule : IModule
else win.Show();
}
public object Execute(string command)
public List<ToolDefinition> GetTools()
{
switch (command)
return new List<ToolDefinition>
{
case "погода":
return "Погода хорошая!";
default:
return "Команда не найдена";
new ToolDefinition
{
Name = "get_weather",
Description = "Получает текущую погоду для указанного города",
ParametersSchema = JsonSerializer.Serialize(new
{
type = "object",
properties = new
{
city = new { type = "string", description = "Название города на русском языке" }
},
required = new[] { "city" }
})
},
new ToolDefinition
{
Name = "get_qnh",
Description = "Получает текущее давление над уровнем моря для указанного города",
ParametersSchema = JsonSerializer.Serialize(new
{
type = "object",
properties = new
{
city = new { type = "string", description = "Название города на русском языке" }
},
required = new[] { "city" }
})
}
};
}
public string Execute(string toolName, string argumentsJson)
{
if (toolName == "get_weather")
{
try
{
var args = JsonDocument.Parse(argumentsJson);
if (args.RootElement.TryGetProperty("city", out var cityElement))
{
string city = cityElement.GetString() ?? "неизвестном городе";
return $"Погода в {city} сейчас отличная, солнечно, +25 градусов!";
}
}
catch
{
return "Ошибка при обработке аргументов погоды";
}
}
else if (toolName == "get_qnh")
{
try
{
var args = JsonDocument.Parse(argumentsJson);
if (args.RootElement.TryGetProperty("city", out var cityElement))
{
string city = cityElement.GetString() ?? "неизвестном городе";
return $"Давление над уровнем моря в {city} сейчас 1020 мм рт. ст!";
}
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
return "Инструмент не найден";
}
}

View File

@@ -5,9 +5,9 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<!-- ВОТ ЭТА СТРОЧКА: она заставит компилятор создать Module.dll -->
<AssemblyName>Module</AssemblyName>
<AssemblyName>ModuleWeather</AssemblyName>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
</PropertyGroup>
<ItemGroup>
@@ -39,7 +39,6 @@
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.3.12" />
<PackageReference Include="Avalonia.Desktop" Version="11.3.12" />
<PackageReference Include="System.IO.Ports" Version="11.0.0-preview.2.26159.112" />
</ItemGroup>
</Project>