SpongeEngine.OobaboogaSharp
2.4.0.1
dotnet add package SpongeEngine.OobaboogaSharp --version 2.4.0.1
NuGet\Install-Package SpongeEngine.OobaboogaSharp -Version 2.4.0.1
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="SpongeEngine.OobaboogaSharp" Version="2.4.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SpongeEngine.OobaboogaSharp --version 2.4.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SpongeEngine.OobaboogaSharp, 2.4.0.1"
#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 SpongeEngine.OobaboogaSharp as a Cake Addin #addin nuget:?package=SpongeEngine.OobaboogaSharp&version=2.4.0.1 // Install SpongeEngine.OobaboogaSharp as a Cake Tool #tool nuget:?package=SpongeEngine.OobaboogaSharp&version=2.4.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
OobaboogaSharp
C# client for Oobabooga.
Features
- OpenAI-compatible API support
- Text completion and chat completion
- Streaming responses support
- Character templates and instruction formats
- Built-in error handling and logging
- Cross-platform compatibility
- Full async/await support
Installation
dotnet add package SpongeEngine.OobaboogaSharp
Quick Start
using SpongeEngine.OobaboogaSharp;
using SpongeEngine.OobaboogaSharp.Models.Chat;
using SpongeEngine.OobaboogaSharp.Models.Completion;
// Create client instance
var client = new OobaboogaSharpClient(new OobaboogaSharpClientOptions
{
HttpClient = new HttpClient
{
BaseAddress = new Uri("http://localhost:5000")
}
});
// Simple completion
var response = await client.CompleteAsync(
"Write a short story about a robot:",
new CompletionOptions
{
MaxTokens = 200,
Temperature = 0.7f,
TopP = 0.9f
});
Console.WriteLine(response);
// Chat completion
var messages = new List<ChatMessage>
{
new() { Role = "user", Content = "Write a poem about coding" }
};
var chatResponse = await client.ChatCompleteAsync(
messages,
new ChatCompletionOptions
{
Mode = "instruct",
InstructionTemplate = "Alpaca",
MaxTokens = 200
});
Console.WriteLine(chatResponse.Choices[0].Message.Content);
// Stream chat completion
await foreach (var message in client.StreamChatCompletionAsync(messages))
{
Console.Write(message.Content);
}
Configuration Options
Basic Options
var options = new Options
{
BaseUrl = "http://localhost:5000", // text-generation-webui server URL
ApiKey = "optional_api_key", // Optional API key for authentication
TimeoutSeconds = 120 // Request timeout
};
Chat Completion Options
var options = new ChatCompletionOptions
{
ModelName = "model_name", // Optional
MaxTokens = 200,
Temperature = 0.7f,
TopP = 0.9f,
StopSequences = new[] { "\n" },
Mode = "chat", // "chat" or "instruct"
InstructionTemplate = "Alpaca", // For instruct mode
Character = "Assistant" // Optional character template
};
Text Completion Options
var options = new CompletionOptions
{
ModelName = "model_name", // Optional
MaxTokens = 200,
Temperature = 0.7f,
TopP = 0.9f,
StopSequences = new[] { "\n" }
};
Error Handling
try
{
var response = await client.ChatCompleteAsync(messages, options);
}
catch (Exception ex) when (ex is SpongeEngine.OobaboogaSharp.Models.Common.Exception oobaboogaEx)
{
Console.WriteLine($"Error: {ex.Message}");
Console.WriteLine($"Status code: {oobaboogaEx.StatusCode}");
Console.WriteLine($"Response: {oobaboogaEx.ResponseContent}");
}
Logging
var client = new OobaboogaSharpClient(new OobaboogaSharpClientOptions
{
HttpClient = new HttpClient
{
BaseAddress = new Uri("http://localhost:5000")
},
Logger = LoggerFactory
.Create(builder => builder.AddConsole())
.CreateLogger<OobaboogaSharpClient>()
});
Testing
The library includes both unit and integration tests. Integration tests require a running text-generation-webui server.
To run the tests:
dotnet test
Configure test environment:
Environment.SetEnvironmentVariable("OOBABOOGA_BASE_URL", "http://localhost:5000");
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Support
For issues and feature requests, please use the GitHub issues page.
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 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- Microsoft.Extensions.Caching.Memory (>= 9.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.1)
- Polly (>= 8.5.1)
- SpongeEngine.SpongeLLM.Core (>= 0.1.0)
- System.Linq.Async (>= 6.0.1)
-
net7.0
- Microsoft.Extensions.Caching.Memory (>= 9.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.1)
- Polly (>= 8.5.1)
- SpongeEngine.SpongeLLM.Core (>= 0.1.0)
- System.Linq.Async (>= 6.0.1)
-
net8.0
- Microsoft.Extensions.Caching.Memory (>= 9.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.1)
- Polly (>= 8.5.1)
- SpongeEngine.SpongeLLM.Core (>= 0.1.0)
- System.Linq.Async (>= 6.0.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on SpongeEngine.OobaboogaSharp:
Package | Downloads |
---|---|
SpongeEngine.SpongeLLM
Unified C# client for LLM providers. |
GitHub repositories
This package is not used by any popular GitHub repositories.