Pieces.Extensions.AI 0.0.3-beta

This is a prerelease version of Pieces.Extensions.AI.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Pieces.Extensions.AI --version 0.0.3-beta                
NuGet\Install-Package Pieces.Extensions.AI -Version 0.0.3-beta                
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="Pieces.Extensions.AI" Version="0.0.3-beta" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Pieces.Extensions.AI --version 0.0.3-beta                
#r "nuget: Pieces.Extensions.AI, 0.0.3-beta"                
#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 Pieces.Extensions.AI as a Cake Addin
#addin nuget:?package=Pieces.Extensions.AI&version=0.0.3-beta&prerelease

// Install Pieces.Extensions.AI as a Cake Tool
#tool nuget:?package=Pieces.Extensions.AI&version=0.0.3-beta&prerelease                

Pieces.Extensions.AI - an implementation of Microsoft.Extensions.AI using Pieces

The Pieces.Extensions.AI package is an implementation of Microsoft.Extensions.AI using Pieces to provide support for multiple LLMs, as well as adding context such as snippets, files, folders, and live context to your AI conversation.

Features

The Pieces.Extensions.AI package offers the following key features:

  1. IChatClient implementation
  2. Ability to add files, folders, assets, and local context via the ChatOptions.AdditionalProperties
  3. Ability to select the model via the ChatOptions.AdditionalProperties

Installation

To get started with the Pieces.Extensions.AI, follow these steps:

  1. Download Pieces OS: Pieces OS serves as the primary backend service, providing essential functionality for the SDK. Download the appropriate version for your operating system:

  2. Install the SDK: Use nuget to install the Pieces OS Client SDK package:

    dotnet add package Pieces.Extensions.AI --prerelease
    

Pieces.Extensions.AI Examples

There is an example project using the Pieces.Extensions.AI package in the Extensions.Example project. This example is a console app containing a range of different examples, each commented out. To run these examples, uncomment the one you wan to run, then run dotnet run from the Extensions.Example project.

Quickstart

The Microsoft.Extensions.AI.IChatClient interface is implemented in the PiecesChatClient object. Create an instance of this using a IPiecesClient:

using Microsoft.Extensions.AI;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Pieces.Extensions.AI;
using Pieces.OS.Client;

// Set up logging
var services = new ServiceCollection();
services.AddLogging(builder => builder.AddConsole());
var serviceProvider = services.BuildServiceProvider();
var logger = serviceProvider.GetRequiredService<ILogger<Program>>();

// Create the Pieces client
IPiecesClient client = new PiecesClient(logger);
var assets = await client.GetAssetsAsync().ConfigureAwait(false);

IChatClient chatClient = new PiecesChatClient(client, chatName: "A new chat", logger: logger);

When you use the chat client, a new conversation is create in Pieces, and each time you call chatClient.CompleteAsync or chatClient.CompleteStreamingAsync, the same conversation is continued - assuming that the original chat messages have not changed. If this happens, a new conversation is created.

You can configure the chat with the following ChatOptions settings:

Setting Type Default Description
modelId string GPT-4o The Id of the model. This can be set using the model Ids from the Pieces.OS.Client SDK. If not set, the current model for the Pieces Client used to create this is used.

You can also set the following in the ChatOptions.AdditionalProperties dictionary:

Setting Type Default Description
PersistChat bool true Should the conversation be saved in Pieces> If this is false, after each chat message, the conversation is deleted and a new one started.
AssetIds IEnumerable<string>? null A list of asset Ids to add as context to this conversation.
Files IEnumerable<string>? null A list of file paths to add as context to this conversation.
Folders IEnumerable<string>? null A list of folder paths to add as context to this conversation.
LiveContext bool false Should this conversation include live context.
LiveContextTimeSpan TimeSpan? null The time span to use for the live context window.
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.1.4-beta 42 11/14/2024
0.1.3-beta 54 10/26/2024
0.1.2-beta 41 10/21/2024
0.1.1-beta 71 10/18/2024
0.0.11-beta 64 10/18/2024
0.0.3-beta 50 10/16/2024
0.0.2-beta 46 10/16/2024
0.0.1-beta 44 10/15/2024