Skip to content

GroqSharp is a C# client library that makes it easy to interact with GroqCloud. It's designed to provide a simple and flexible interface, allowing you to seamlessly integrate the Groq service into your C# applications.

License

Notifications You must be signed in to change notification settings

Sarel-Esterhuizen/GroqSharp

Repository files navigation

GroqSharp

NuGet Badge Build and Test Publish to NuGet

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.

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.

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 GroqSharp

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:

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.

About

GroqSharp is a C# client library that makes it easy to interact with GroqCloud. It's designed to provide a simple and flexible interface, allowing you to seamlessly integrate the Groq service into your C# applications.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages