OpenAi_Assistant 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package OpenAi_Assistant --version 1.0.1
NuGet\Install-Package OpenAi_Assistant -Version 1.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="OpenAi_Assistant" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OpenAi_Assistant --version 1.0.1
#r "nuget: OpenAi_Assistant, 1.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 OpenAi_Assistant as a Cake Addin
#addin nuget:?package=OpenAi_Assistant&version=1.0.1

// Install OpenAi_Assistant as a Cake Tool
#tool nuget:?package=OpenAi_Assistant&version=1.0.1

OpenAi_Assistant

https://platform.openai.com/docs/assistants/overview Dotnet SDK for OpenAI Assistants API (Currently Beta) Unofficial. OpenAI doesn't have any official .Net SDK.

Information

Last week the new OpenAI Assistant API became available, i started testing it out and this is the SDK i created for it. Keep in mind the API is still in beta, and this wrapper is far from finished.

  • Accepting Contributions: I welcome contributions from the community to enhance and expand the functionality of this wrapper. Whether you want to add new features, improve existing code, or fix bugs, your contributions are highly appreciated!

How to use

First you create the assistant, then you create the thread, when you have a thread you can add messages to it, when you want a response you need to run the thread and wait for the run operation to be completed, when the run operation completes we can read the response from the ai. Example:

// Best approach would be to load the api key from env vars
var aiService = new OpenAiAssistantService("YOUR-API-KEY"); 

// Create the assistant by passing the parameters, use models from OpenAiModel.<SelectedModel>
// You can pass instructions to the assistant, for example "You are a math tutor".
var assistant = await aiService.CreateAssistant(OpenAiModel.Gpt_3_5_Turbo,"Math tutor", ToolsModel.Code_Interpreter,"You are a math tutor");

// Create the thread that the assistant will run on
var thread =  await aiService.CreateThread();


// Send a new message to the thread with the user role.
var newMsg = await aiService.SendMsgToThread("msg","user");

// Start the run operation
 var run = await aiService.RunAssistant();

// Finally get the response from the assistant
var response = await aiService.GetResponseFromAssistant();

Console.WriteLine(response);


Each object returns an error message if it fails.

For now you can access chatGPT3 turbo and chatGPT4 in the OpenAiModel class:

public class OpenAiModel
{


    /// <summary>
    ///     Most capable GPT-3.5 model and optimized for chat at 1/10th the cost of text-davinci-003. Will be updated with our
    ///     latest model iteration.
    /// </summary>
    public static string Gpt_3_5_Turbo => "gpt-3.5-turbo";

    /// <summary>
    ///     Same capabilities as the standard gpt-3.5-turbo model but with 4 times the context.
    /// </summary>
    public static string Gpt_3_5_Turbo_16k => "gpt-3.5-turbo-16k";


    /// <summary>
    ///     More capable than any GPT-3.5 model, able to do more complex tasks, and optimized for chat. Will be updated with
    ///     our latest model iteration.
    /// </summary>
    public static string Gpt_4 => "gpt-4";

}

ToDo

  • Need to make use of IHttpClientFactory
  • Need to add file support
  • Clean up code
  • Run Steps
Product Compatible and additional computed target framework versions.
.NET 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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.0.4 584 11/12/2023
1.0.3 111 11/11/2023
1.0.2 102 11/11/2023
1.0.1 113 11/9/2023
1.0.0 118 11/8/2023

Fixed bug where assistant did not recieve correct parameters.