TurtleShell 1.1.1
dotnet add package TurtleShell --version 1.1.1
NuGet\Install-Package TurtleShell -Version 1.1.1
<PackageReference Include="TurtleShell" Version="1.1.1" />
paket add TurtleShell --version 1.1.1
#r "nuget: TurtleShell, 1.1.1"
// Install TurtleShell as a Cake Addin #addin nuget:?package=TurtleShell&version=1.1.1 // Install TurtleShell as a Cake Tool #tool nuget:?package=TurtleShell&version=1.1.1
TurtleShell Documentation
See ExampleTurtle https://github.com/john-cornell/TurtleShell/tree/master/ExampleTurtle for simple implementation example
Introduction
TurtleShell provides a versatile framework for engaging with different AI language processing engines. Designed with flexibility and scalability in mind, it allows users to seamlessly switch between different AI platforms, such as Ollama and OpenAI, leveraging unique features from each engine.
Purpose
The primary purpose of TurtleShell is to offer a unified interface for running various AI models. This allows developers to integrate powerful AI functionalities into their applications with minimal setup and effort. The project is particularly useful for applications that require conversational AI capabilities, such as chatbots or virtual assistants.
Architecture Overview
TurtleShell's architecture is centered around the EngineFactory
class, which serves as the entry point for starting and configuring instances of AI engines. The architecture can be broken down into several key components:
- Engine Factory: This serves as a centralized access point to create and configure engine instances.
- Engines: Abstract implementations and specific implementations like Ollama and OpenAI engines are provided.
- Configuration: Built-in support for configuration using
.NET
's configuration framework. - Text Processing: Includes utilities like JSON extraction and prompt formatting for enhanced response processing.
Key Components
EngineFactory
- Purpose:
EngineFactory
initializes AI engines by determining the appropriate type and configuration settings based on the given input parameters. - Usage:
var engineModelId = new EngineModelId(EngineType.OpenAI, OpenAIModelIds.GPT3_5_Turbo);
IEngine engine = EngineFactory.Start(engineModelId, options: new EngineConfigOptions());
Configuration
To add Anthropic or OpenAI API Keys, add a appconfig.json file to your entrypoint project (remember to set the Copy Always or Copy if Newer flag in properties) and add the following:
{
"OpenAI": {
"ApiKey": ""
},
"Anthropic": {
"ApiKey": ""
}
}
EngineModelId
- Purpose: Represents the identity and type of a model being used in an engine.
- Details: Contains
EngineType
andModelId
, helping to specify which AI engine and model to use.
Engine Types
- Ollama: Uses different models like
phi3
,llama3
, etc., accessed via theOllamaEngine
. - OpenAI: Has support for multiple GPT models like GPT-3.5 Turbo and GPT-4, implemented in the
OpenAIGPTEngine
.
IEngine Interface
- Purpose: Defines a common interface for all engine implementations with functionalities to set prompts, make asynchronous calls, and get engine details.
- Example Usage:
engine.SetSystemPrompt("Hello, AI!");
string response = await engine.CallAsync("Tell me a joke.", resetHistory: true);
Configuration Options
- EngineConfigOptions: Provides configurable sections for aspects such as JSON parsing or system prompts settings.
- JSON Parsing:
UseJsonParse
: Enables parsingUsePlainText
: Disables JSON formattingUseJsonFormat
: Enables JSON formatting without parsing
- System Prompt:
- Configures initial system prompts for the AI to follow.
- JSON Parsing:
Text Processing
- JsonExtractor: This utility processes JSON responses from models, ensuring correct formatting and removal of unnecessary content.
Advanced Usage
Switching Models
To switch between different models, simply change the EngineModelId
as follows:
var engineModelId = new EngineModelId(EngineType.Ollama, OllamaModelIds.Llama3_8b);
// Switch to OpenAI
engineModelId = new EngineModelId(EngineType.OpenAI, OpenAIModelIds.GPT4);
Adding Custom Configurations
You can customize engine behavior by modifying EngineConfigOptions
:
var customOptions = new EngineConfigOptions();
customOptions.AddSection(new JsonEngineConfigSection { ParseJson = true });
// Add additional custom configuration
Conclusion
TurtleShell provides a robust solution for integrating various AI capabilities into your applications. By facilitating easy swaps between different AI engines and models, it standardizes how you can deploy conversational AI features across diverse use cases. With its straightforward design and powerful configuration options, TurtleShell will elevate the conversational experiences of your applications.
Product | Versions 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 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net6.0
- Anthropic.SDK (>= 4.5.0)
- Microsoft.Extensions.Configuration (>= 9.0.1)
- Microsoft.Extensions.Configuration.Binder (>= 9.0.1)
- Microsoft.Extensions.Configuration.Json (>= 9.0.1)
- Microsoft.SemanticKernel (>= 1.35.0)
- Newtonsoft.Json (>= 13.0.3)
- OllamaSharp (>= 5.0.6)
-
net8.0
- Anthropic.SDK (>= 4.5.0)
- Microsoft.Extensions.Configuration (>= 9.0.1)
- Microsoft.Extensions.Configuration.Binder (>= 9.0.1)
- Microsoft.Extensions.Configuration.Json (>= 9.0.1)
- Microsoft.SemanticKernel (>= 1.35.0)
- Newtonsoft.Json (>= 13.0.3)
- OllamaSharp (>= 5.0.6)
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 |
---|---|---|
1.1.1 | 68 | 2/9/2025 |