Skip to content

AllInAI.Sharp.API的使用示例文档。AllInAI.Sharp.API是c#使用的AI模型调用SDK,整合OpenAI,chatGLM,文心千帆,stable-diffusion 等,

License

Notifications You must be signed in to change notification settings

raokun/AllInAI.Sharp.API.Sample

Repository files navigation

AllInAI.Sharp.API.Sample

English | 中文简介

Usage example documentation for AllInAI.Sharp.API. AllInAI.Sharp.API is an SDK that calls language models from various platforms, and it helps users quickly integrate with major models. It has integrated OpenAI, chatGLM, Wenxin Qianfan, Synonymous Qianwen, stable-diffusion, etc. It supports setting reverse proxies and streaming interfaces. The AllInAI SDK integrates unified input and output parameters in the chat and image interfaces, making it easy to call.

Version

* V1.1.5 Added OpenAI Translations API for converting speech to text, specifically for converting speech to English.
* V1.1.4 Added OpenAI Whisper API for converting speech to text.
* V1.1.3 Fixed an issue with the invocation of the Wenxin Qianfan model.
* V1.1.2 Fixed an issue with the Wenxin Qianfan model where the returned result was empty.

Completed models include:

  • OpenAI
  • chatGLM
  • Wenxin Qianfan
  • Synonymous Qianwen
  • stable-diffusion

Usage example

Initiate a chat

  1. Set the basic configurations:

    • key: The model secret key
    • BaseUrl: The proxy address
    • AIType: The model type, corresponds to the Enums.AITypeEnum enumeration
  2. Call the API

  3. chat

AuthOption authOption = new AuthOption() { Key = "sk-***", BaseUrl = "https://api.openai.com", AIType = Enums.AITypeEnum.OpenAi };

ChatService chatService = new ChatService(authOption);
CompletionReq completionReq = new CompletionReq();
List<MessageDto> messages = new List<MessageDto>();
messages.Add(new MessageDto() { Role = "user", Content = "Hello!" });
completionReq.Model = "gpt-3.5-turbo";
completionReq.Messages = messages;
CompletionRes completionRes = await chatService.Completion(completionReq);
  1. image
AuthOption authOption = new AuthOption() {BaseUrl = "http://43.134.164.127:77", AIType = Enums.AITypeEnum.SD };
ImgService imgService = new ImgService(authOption);
Txt2ImgReq imgReq = new Txt2ImgReq();
imgReq.Steps = 20;
imgReq.Size = "1024x1024";
imgReq.N = 1;
imgReq.Prompt = "kitty";
imgReq.ResponseFormat = "b64_json";
ImgRes imgRes = await imgService.Txt2Img(imgReq);

How to contribute

  1. Fork & Clone
  2. Create a branch named Feature/name(your github id)/issuexxx
  3. Commit with a commit message, like "solve issue xxx, add xxx"
  4. Create a Pull Request If you would like to contribute, feel free to submit Pull Requests or give us Issues.

Donation

If you find this project helpful, you can buy raokun a coffee to show support. raokun's open-source contribution relies on your support and encouragement.

WeChat

Alipay

About

AllInAI.Sharp.API的使用示例文档。AllInAI.Sharp.API是c#使用的AI模型调用SDK,整合OpenAI,chatGLM,文心千帆,stable-diffusion 等,

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages