Smith 0.1.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Smith --version 0.1.1
                    
NuGet\Install-Package Smith -Version 0.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Smith" Version="0.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Smith" Version="0.1.1" />
                    
Directory.Packages.props
<PackageReference Include="Smith" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Smith --version 0.1.1
                    
#r "nuget: Smith, 0.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=Smith&version=0.1.1
                    
Install as a Cake Addin
#tool nuget:?package=Smith&version=0.1.1
                    
Install as a Cake Tool

An opinionated meta-package for doing AI agents using Microsoft.Extensions.AI and MCP and dotnet run file.

Example Claude-based agent:

alternate text is missing from this package README image

#:package Smith@0.*

var configuration = new ConfigurationBuilder()
    .AddEnvironmentVariables()
    .AddUserSecrets()
    .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
    .AddIniFile("appsettings.ini", optional: true, reloadOnChange: true)
    .Build();

var services = new ServiceCollection();

services.AddHttpClient("ai").AddStandardResilienceHandler();

services.AddChatClient(services => new Anthropic.AnthropicClient(
    configuration["Claude:Key"] ?? throw new InvalidOperationException("Missing Claude:Key configuration."),
    services.GetRequiredService<IHttpClientFactory>().CreateClient("ai")))
    .UseLogging()
    .UseFunctionInvocation();

var provider = services.BuildServiceProvider();
var history = new List<ChatMessage> { new ChatMessage(ChatRole.System, Prompts.System) };
var chat = provider.GetRequiredService<IChatClient>();
var options = new ChatOptions
{
    ModelId = "claude-sonnet-4-20250514",
    MaxOutputTokens = 1000,
    Temperature = 0.7f,
    Tools = [AIFunctionFactory.Create(() => DateTime.Now, "get_datetime", "Gets the current date and time on the user's local machine.")]
};

AnsiConsole.MarkupLine($":robot: Ready v{ThisAssembly.Info.Version}");
AnsiConsole.Markup($":person_beard: ");
while (true)
{
    var input = Console.ReadLine()?.Trim();
    if (string.IsNullOrEmpty(input))
        continue;

    history.Add(new ChatMessage(ChatRole.User, input));

    try
    {
        var response = await AnsiConsole.Status().StartAsync(":robot: Thinking...",
            ctx => chat.GetResponseAsync(input, options));

        history.AddRange(response.Messages);
        // Try rendering as formatted markup
        try
        {
            if (response.Text is { Length: > 0 })
                AnsiConsole.MarkupLine($":robot: {response.Text}");
        }
        catch (Exception)
        {
            // Fallback to escaped markup text if rendering fails
            AnsiConsole.MarkupInterpolated($":robot: {response.Text}");
        }

        AnsiConsole.WriteLine();
        AnsiConsole.Markup($":person_beard: ");
    }
    catch (Exception e)
    {
        AnsiConsole.WriteException(e);
    }
}

static class Prompts
{
    public const string System =
        """
        Your responses will be rendered using Spectre.Console.AnsiConsole.Write(new Markup(string text))). 
        This means that you can use rich text formatting, colors, and styles in your responses, but you must 
        ensure that the text is valid markup syntax. 
        """;
}

Sponsors

Clarius Org MFB Technologies, Inc. Torutek DRIVE.NET, Inc. Keith Pickford Thomas Bolon Kori Francis Toni Wenzel Uno Platform Reuben Swartz Jacob Foshee alternate text is missing from this package README image Eric Johnson David JENNI Jonathan Charley Wu Ken Bonny Simon Cropp agileworks-eu sorahex Zheyu Shen Vezel ChilliCream 4OTC Vincent Limo Jordan S. Jones domischell Justin Wendlandt Adrian Alonso Michael Hagedorn Matt Frear

Sponsor this project  

Learn more about GitHub Sponsors

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.2.1 41 7/2/2025
0.2.0 42 7/2/2025
0.1.2 116 6/2/2025
0.1.1 116 6/2/2025
0.1.0 117 6/2/2025