Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reactivate test #190

Merged
merged 1 commit into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 8 additions & 15 deletions src/OllamaSharp/OllamaToolAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
namespace OllamaSharp;

/// <summary>
/// Specifies that the class or method is a tool for Ollama.
/// OllamaSharp will generate an implementation of this class or method with the name suffix -Tool.
/// If your method is named "GetWeather", the generated class will be named "GetWeatherTool".
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
public class OllamaToolAttribute : Attribute
{
/// <summary>
/// Initializes a new instance of the <see cref="OllamaToolAttribute"/> class.
/// </summary>
public OllamaToolAttribute() { }
}

//// Extension-Klasse, um im Execute() auf IMethodSymbol zuzugreifen
//// (Sinnvoll: an passender Stelle in Execute() "fixen")
//public static class GeneratorExtensions
//{
// public static void FixCandidateMethods(this OllamaToolGenerator.SyntaxReceiver receiver, Compilation compilation)
// {
// for (int i = 0; i < receiver.CandidateMethods.Count; i++)
// {
// // Falls wir den Placeholder null! gesetzt hatten, hier „reparieren“:
// // Nicht in diesem Minimal-Beispiel gezeigt,
// // weil wir das Symbolmatching gleich direkt beim Visit machen könnten.
// }
// }
//}
26 changes: 13 additions & 13 deletions test/AbstractionMapperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,19 +240,19 @@ public void Maps_Messages_With_Tools()

var chatRequest = AbstractionMapper.ToOllamaSharpChatRequest(chatMessages, options, stream: true, JsonSerializerOptions.Default);

//var tool = chatRequest.Tools.Single();
//tool.Function.Description.Should().Be("Gets the current weather for a current location");
//tool.Function.Name.Should().Be("get_weather");
//tool.Function.Parameters.Properties.Should().HaveCount(2);
//tool.Function.Parameters.Properties["city"].Description.Should().Be("The city to get the weather for");
//tool.Function.Parameters.Properties["city"].Enum.Should().BeNull();
//tool.Function.Parameters.Properties["city"].Type.Should().Be("string");
//tool.Function.Parameters.Properties["unit"].Description.Should().Be("The unit to calculate the current temperature to");
//tool.Function.Parameters.Properties["unit"].Enum.Should().BeNull();
//tool.Function.Parameters.Properties["unit"].Type.Should().Be("string");
//tool.Function.Parameters.Required.Should().BeEquivalentTo("city");
//tool.Function.Parameters.Type.Should().Be("object");
//tool.Type.Should().Be("function");
var tool = (Tool)chatRequest.Tools.Single();
tool.Function.Description.Should().Be("Gets the current weather for a current location");
tool.Function.Name.Should().Be("get_weather");
tool.Function.Parameters.Properties.Should().HaveCount(2);
tool.Function.Parameters.Properties["city"].Description.Should().Be("The city to get the weather for");
tool.Function.Parameters.Properties["city"].Enum.Should().BeNull();
tool.Function.Parameters.Properties["city"].Type.Should().Be("string");
tool.Function.Parameters.Properties["unit"].Description.Should().Be("The unit to calculate the current temperature to");
tool.Function.Parameters.Properties["unit"].Enum.Should().BeNull();
tool.Function.Parameters.Properties["unit"].Type.Should().Be("string");
tool.Function.Parameters.Required.Should().BeEquivalentTo("city");
tool.Function.Parameters.Type.Should().Be("object");
tool.Type.Should().Be("function");
}

[Test]
Expand Down
Loading