GroqSharpR 1.3.3
dotnet add package GroqSharpR --version 1.3.3
NuGet\Install-Package GroqSharpR -Version 1.3.3
<PackageReference Include="GroqSharpR" Version="1.3.3" />
paket add GroqSharpR --version 1.3.3
#r "nuget: GroqSharpR, 1.3.3"
// Install GroqSharpR as a Cake Addin #addin nuget:?package=GroqSharpR&version=1.3.3 // Install GroqSharpR as a Cake Tool #tool nuget:?package=GroqSharpR&version=1.3.3
GroqSharp
GroqSharp is a community maintained C# client library for interacting with GroqCloud. Designed to provide a simple and flexible interface, it enables seamless integration of Groq services into your C# applications. This fork adds support for the reasoning mode available in the Groq API.
Why GroqSharp?
GroqSharp is designed to simplify your interactions with GroqCloud by offering:
- Fluent API: Configure client options and parameters fluently for convenient setup.
- Structured Responses: Utilize specific JSON response structures for predictable outputs.
- Function Integration: Integrate and manage function calling within your applications.
- Retry Mechanism: Implement configurable retry policies to handle transient errors when working with structured data effectively.
- Streaming Support: Support for streaming responses to process data as it becomes available, providing real-time interaction capabilities.
- Reasoning Format: Use reasoning format to specify how Groq should parse the response from reasoning models before returning.
GroqSharp's function/tool integration support allows developers to extend the functionality of the Groq platform within their applications, making it easier to implement complex workflows and data manipulations directly within chat interfaces.
Getting Started
Installation
Install GroqSharp via NuGet:
dotnet add package GroqSharpR
Environment Setup
For security and flexibility, it is recommended to store your API key in an environment variable. This prevents hardcoding sensitive information in your source code:
var apiKey = Environment.GetEnvironmentVariable("GROQ_API_KEY");
var apiModel = "llama3-70b-8192"; // Or other supported model
var groqClient = new GroqClient(apiKey, apiModel);
Fluent Configuration
Configure your client using a fluent API:
IGroqClient groqClient = new GroqClient(apiKey, apiModel)
.SetTemperature(0.5)
.SetMaxTokens(512)
.SetTopP(1)
.SetStop("NONE")
.SetStructuredRetryPolicy(5); // Retry up to 5 times on failure
Examples
Explore sample projects that demonstrate various capabilities of GroqSharp:
- Chat Basics - Basic chat functionalities.
- Chat Streaming - Streaming responses for dynamic interaction.
- Structured Data - Handling structured JSON responses.
- Structured Poco - Map structured JSON responses to POCOs.
- Tool Integration - Using custom tools for enhanced functionalities.
Contributing
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
License
This library is licensed under the MIT License. See the LICENSE file for more details.
Conclusion
GroqSharp offers a flexible and efficient way to incorporate Groq's capabilities into your C# projects, ensuring secure and configurable interaction management.
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. 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. |
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
- Add ReasoningMode for reasoning models