Luga 0.2.0

dotnet add package Luga --version 0.2.0                
NuGet\Install-Package Luga -Version 0.2.0                
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="Luga" Version="0.2.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Luga --version 0.2.0                
#r "nuget: Luga, 0.2.0"                
#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.
// Install Luga as a Cake Addin
#addin nuget:?package=Luga&version=0.2.0

// Install Luga as a Cake Tool
#tool nuget:?package=Luga&version=0.2.0                

LUGA - Language Understanding Generative Agents

A Generative AI Agent Management framework for .NET.

Github: luga

Installation

NuGet

dotnet add package Luga

Configuration

  1. Add your OpenAI API key and (optionally) organization ID in appsettings.json or use .NET user secrets:
{
  "OpenAIServiceOptions": {
    "ApiKey": "Your API key goes here",
    "Organization": "Your Organization ID goes here (optional)"
  }
}

For Azure OpenAI

{
  "OpenAIServiceOptions": {
    "ApiKey": "Your API key goes here",
    "Organization": "Your Organization ID goes here",
    "ResourceName": "Your Azure Resource Name goes here",
    "DeploymentId": "Your Azure Deployment ID goes here"
  }
}

Register AI Agents

Register the AI agents using the ConfigureLugaProviders extension method:

services.ConfigureLuga(Provider.OpenAi);

// To use pre-built agents
services.AddLugaAgents()

Inject Services

Inject the required services into your classes:

public class MyClass
{
    private readonly IHtmlTextExtractorAgent _htmlTextExtractorAgent;

    public MyClass(IHtmlTextExtractorAgent htmlTextExtractorAgent)
    {
        _htmlTextExtractorAgent = htmlTextExtractorAgent;
    }
} 

Use AI Agents

Use the AI agents to perform tasks:

var extractedText = await _htmlTextExtractorAgent.Ask("<html><body><p>Hello, World!</p></body></html>");

Build Agents Dynamically

Use the IAgentBuilder builder to build agents dynamically:

var agentBuilder = host.Services.GetRequiredService<IAgentBuilder>();

Agent agent = agentBuilder!
             .WithContext(
                  """
                  You are a GPT-based Language Detection Agent, specifically designed to identify the language of a given text.
                  Your primary function is to analyze the text and return the language it is written in, using ISO 639-1 language codes (e.g., 'en' for English, 'es' for Spanish, 'fr' for French).

                  When you receive a text input, carefully examine its content and determine the language with high accuracy.
                  Use your extensive knowledge of various languages and linguistic patterns to identify the correct language code.
                  Remember, your main goal is to provide accurate and efficient language detection for any text input you receive.
                  """)
             .WithModel(Models.Gpt4)
             .Build();

var response = await agent.Ask(
    message: "Bonjour, comment ça va?",
    output => new
    {
        Language = output
    });

References

This project utilizes Betalgo.OpenAI to communicate with the OpenAI API.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in 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.0 186 5/1/2023
0.1.0 179 4/19/2023
0.1.0-alpha0006 129 5/1/2023