This is an example app using the Pieces.Extensions.AI package to show how to build a small application that leverages Pieces Long-Term Memory. This application reminds you of what you were doing over the past few hours.
This application creates the chat client, and sends a message to get the activities over the last few hours using Pieces Long-Term Memory. This is controlled by the ChatOptions
:
var options = new ChatOptions
{
AdditionalProperties = new AdditionalPropertiesDictionary
{
{ PiecesChatClient.LongTermMemoryPropertyName, true},
{ PiecesChatClient.LongTermMemoryTimeSpanPropertyName, TimeSpan.FromHours(6) },
}
};
This uses a single chat message to get what you were doing over the last few hours:
chatMessages.Add(new(ChatRole.User, "Give me a summary of all the activities I was doing over the last few hours"));
As a fun easter egg, depending on the day of the year, this will also add a system prompt to guide the output, such as giving the response like a pirate on international talk like a pirate day, or like Yoda on Star Wars Day.
To run this code, follow these steps:
-
Download Pieces OS: Pieces OS serves as the primary backend service, providing essential functionality for the SDK. If you don't have it installed and running already, download the appropriate version for your operating system:
-
Ensure the Workstream Pattern Engine is running.
-
Build and run the app:
dotnet run