Pieces.Extensions.AI
0.1.3-beta
dotnet add package Pieces.Extensions.AI --version 0.1.3-beta
NuGet\Install-Package Pieces.Extensions.AI -Version 0.1.3-beta
<PackageReference Include="Pieces.Extensions.AI" Version="0.1.3-beta" />
paket add Pieces.Extensions.AI --version 0.1.3-beta
#r "nuget: Pieces.Extensions.AI, 0.1.3-beta"
// Install Pieces.Extensions.AI as a Cake Addin #addin nuget:?package=Pieces.Extensions.AI&version=0.1.3-beta&prerelease // Install Pieces.Extensions.AI as a Cake Tool #tool nuget:?package=Pieces.Extensions.AI&version=0.1.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 Pieces Long-Term Memory to your AI conversation.
Features
The Pieces.Extensions.AI package offers the following key features:
IChatClient
implementation- Ability to add files, folders, assets, and local context via the
ChatOptions.AdditionalProperties
- Ability to select the model via the
ChatOptions.AdditionalProperties
Installation
To get started with the Pieces.Extensions.AI, follow these steps:
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:
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 want 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 created 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. |
LongTermMemory |
bool |
false |
Should this conversation include Pieces Long-Term Memory. |
LongTermMemoryTimeSpan |
TimeSpan? |
null |
The time span to use for the Pieces Long-Term Memory window. |
Product | Versions 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. |
-
net8.0
- JsonSubTypes (>= 2.0.1)
- Microsoft.Extensions.AI (>= 9.0.0-preview.9.24507.7)
- Microsoft.Extensions.AI.Abstractions (>= 9.0.0-preview.9.24507.7)
- Microsoft.Extensions.Caching.Memory (>= 8.0.0)
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.Hosting (>= 8.0.0)
- Microsoft.Extensions.Logging (>= 8.0.0)
- Microsoft.Extensions.ServiceDiscovery (>= 8.0.0)
- Newtonsoft.Json (>= 13.0.3)
- Pieces.OS.Client (>= 0.1.3-beta)
- Polly (>= 8.1.0)
- RestSharp (>= 112.0.0)
- System.ComponentModel.Annotations (>= 5.0.0)
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.3-beta | 37 | 10/26/2024 |
0.1.2-beta | 33 | 10/21/2024 |
0.1.1-beta | 65 | 10/18/2024 |
0.0.11-beta | 58 | 10/18/2024 |
0.0.3-beta | 43 | 10/16/2024 |
0.0.2-beta | 39 | 10/16/2024 |
0.0.1-beta | 38 | 10/15/2024 |