Skip to content

YemenOpenSource/Deepseek.Asp.Client

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deepseek.ASP.Client

Deepseek.ASPClient is a lightweight ASP.NET wrapper for the Deepseek AI API, designed to simplify AI-driven text processing in .NET applications.

Features

  • ✅ Simple and fluent API
  • ✅ Supports Dependency Injection
  • ✅ Built-in error handling
  • ✅ Uses HttpClient best practices
  • ✅ Asynchronous and thread-safe

Installation

You can install the package via NuGet:

dotnet add package Deepseek.ASPClient

Usage Example

using Deepseek.ASPClient;

var client = new DeepseekClient("your-api-key");
var response = await client.GenerateResponseAsync("Hello Deepseek!");
Console.WriteLine(response.Choices[0].Message.Content);

Dependency Injection Example (ASP.NET Core)

// In Program.cs or Startup.cs
services.AddSingleton<IDeepseekClient>(provider =>
    new DeepseekClient(Configuration["Deepseek:ApiKey"]));

// In a Controller
public class AiController : Controller
{
    private readonly IDeepseekClient _client;

    public AiController(IDeepseekClient client)
    {
        _client = client;
    }

    public async Task<IActionResult> Generate(string prompt)
    {
        try
        {
            var response = await _client.GenerateResponseAsync(prompt);
            return Ok(response.Choices.First().Message.Content);
        }
        catch (DeepseekException ex)
        {
            return StatusCode((int)ex.StatusCode, ex.Message);
        }
    }
}

API Methods

Method Description
Task<DeepseekResponse> GenerateResponseAsync(DeepseekRequest request) Generates a response based on a structured request.
Task<DeepseekResponse> GenerateResponseAsync(string prompt) Generates a response from a simple text prompt.

Exception Handling

All API errors are wrapped inside DeepseekException. Handle exceptions as follows:

try
{
    var response = await client.GenerateResponseAsync("Hello Deepseek!");
    Console.WriteLine(response.Choices[0].Message.Content);
}
catch (DeepseekException ex)
{
    Console.WriteLine($"Error: {ex.Message}");
}

Contributing

We welcome contributions! To contribute:

  1. Fork the repository.
  2. Create a feature branch (git checkout -b feature-name).
  3. Commit your changes (git commit -m "Added new feature").
  4. Push to the branch (git push origin feature-name).
  5. Open a Pull Request.

Reporting Issues

If you encounter any issues, please create an issue on GitHub: Report an Issue

License

This project is licensed under the MIT License. See LICENSE for details.

Author

Created by Anwar Al-Hitar.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%