Skip to content

适用于MacOS、Windows、Linux、Android、iOS和浏览器的ChatGPT C#客户端。由Avalonia UI框架提供支持。

License

Notifications You must be signed in to change notification settings

bianchenglequ/ChatGPT

This branch is 1 commit ahead of, 203 commits behind wieslawsoltes/ChatGPT:main.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

23130fe · Apr 4, 2023
Mar 19, 2023
Mar 29, 2023
Mar 29, 2023
Mar 30, 2023
Apr 2, 2023
Mar 19, 2023
Apr 2, 2023
Mar 30, 2023
Mar 21, 2023
Mar 21, 2023
Apr 2, 2023
Apr 2, 2023
Apr 3, 2023
Dec 8, 2022
Dec 5, 2022
Dec 5, 2022
Mar 31, 2023
Mar 31, 2023
Apr 3, 2023
Mar 15, 2023
Feb 4, 2023
Apr 4, 2023
Dec 5, 2022

Repository files navigation

ChatGPT

NuGet NuGet

用于图形用户界面的ChatGPT C#客户端在MacOS、Windows、Linux、Android、iOS和Browser上运行。由[Avalonia UI]提供技术支持(https://avaloniaui.net/)框架。

要使应用程序工作,您需要设置OpenAI API密钥作为OPENAI_API_KEY环境变量或直接在应用程序设置中设置API密钥。

您可以尝试使用浏览器版本的客户端此处.

图像

快捷方式

Main Window

  • Ctrl+Shift+A - 在透明和丙烯酸模糊窗口样式之间切换。
  • Ctrl+Shift+S - 在可见和隐藏窗口状态之间切换。

Message Prompt

  • Enter - 发送prompt。
  • Escape - 取消编辑。
  • F2 - 编辑prompt.
  • Shift+Enter, Alt+Enter - 换行。

Build

1.安装.NET 7.0 2.运行dotnet workload install ios android wasm tools命令 3.项目目录(移动/桌面)中的“dotnet publish-c Release”命令,或桌面仅运行的“dotnet-run”命令

依赖

.NET tool

安装:

dotnet tool install --global ChatGPT.CLI --version 1.0.0-preview.9

卸载:

dotnet tool uninstall --global ChatGPT.CLI

使用

ChatGPT.CLI:
An .NET ChatGPT tool.

Usage:
ChatGPT.CLI [options]

Options:
-f, --inputFiles <inputfiles>              The relative or absolute path to the input files
-d, --inputDirectory <inputdirectory>      The relative or absolute path to the input directory
-o, --outputDirectory <outputdirectory>    The relative or absolute path to the output directory
--outputFiles <outputfiles>                The relative or absolute path to the output files
-p, --pattern <pattern>                    The search string to match against the names of files in the input directory
-r, --recursive                            Recurse into subdirectories of input directory search
-e, --extension <extension>                The output file extension
-s, --settingsFile <settingsfile>          The relative or absolute path to the settings file
--temperature <temperature>                What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
--topP <topp>                              An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.
--presencePenalty <presencepenalty>        Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.
--frequencyPenalty <frequencypenalty>      Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.
--maxTokens <maxtokens>                    The maximum number of tokens to generate in the chat completion.
--apiKey <apikey>                          Override OpenAI api key. By default OPENAI_API_KEY environment variable is used.
--model <model>                            ID of the model to use. See the model endpoint compatibility table for details on which models work with the Chat API.
--directions <directions>                  The system message (directions) helps set the behavior of the assistant. Typically, a conversation is formatted with a system message first, followed by alternating user and assistant messages.
-t, --threads <threads>                    The number of parallel job threads
--quiet                                    Set verbosity level to quiet
--version                                  Show version information
-?, -h, --help                             Show help and usage information

示例

  • 使用 .NET tool chat 命令:

C# to VB

chat -d ./ -e vb -p *.cs --directions "You are C# to VB conversion expert. Convert input code from C# to VB. Write only converted code."

C# to F#

chat -d ./ -e fs -p *.cs --directions "You are C# to F# conversion expert. Convert input code from C# to F#. Write only code."

Refactor C# code

chat -d ./ -e cs -p *.cs --directions "You are C# expert. Refactor C# code to use fluent api. Write only code."

编写API文档

chat -d ./ -e md -p *.cs --directions "You are a technical documentation writer. Write API documentation for C# code. If XML docs are missing write them."
  • 从源码运行

C# to VB

dotnet run -- -d ./ -e vb -p *.cs --directions "You are C# to VB conversion expert. Convert input code from C# to VB. Write only converted code."

C# to F#

dotnet run -- -d ./ -e fs -p *.cs --directions "You are C# to F# conversion expert. Convert input code from C# to F#. Write only code."

编写API文档

dotnet run -- -d ./ -e md -p *.cs --directions "You are a technical documentation writer. Write API documentation for C# code. If XML docs are missing write them."

配置文件

{
    "temperature": 0.7,
    "top_p": 1,
    "presence_penalty": 0,
    "frequency_penalty": 0,
    "maxTokens": 2000,
    "apiKey": "",
    "model": "gpt-3.5-turbo",
    "directions": "You are a helpful assistant."
}

COM

在发布版本目录中 ChatGPT\ChatGptCom\bin\Release\net462\ 运行以下命令进行注册 ChatGptCom.dll.

32-bit

c:\Windows\Microsoft.NET\Framework\v4.0.30319\regasmm.exe /codebase /tlb ChatGptCom.dll

64-bit

c:\Windows\Microsoft.NET\Framework64\v4.0.30319\regasm.exe /codebase /tlb ChatGptCom.dll

Microsoft Work 2010

添加ChatGPT\ChatGptCom\bin\Release\net462\ChatGptCom.tlb to References using Tools > References... menu in Microsoft Visual Basic for Applications.

Option Explicit

Private WithEvents m_translateSource As Chat
Private WithEvents m_demoSource As Chat
Dim OriginalSelection As Range

Sub TranslateSelection()
    Set OriginalSelection = Selection.Range
    Dim ProcessedText As String
    ProcessedText = OriginalSelection.Text
    m_translateSource.AskAsync "You are a professional translator to English. I will provide text and you will translate it to English.", ProcessedText
End Sub

Sub Translate_Initialize()
    Set m_translateSource = New ChatGptCom.Chat
End Sub

Sub m_translateSource_OnSendCompleted()
    OriginalSelection.Text = m_translateSource.Result
End Sub

Sub Chat_Initialize()
    Set m_demoSource = New ChatGptCom.Chat
End Sub

Sub Chat_Send()
    m_demoSource.AskAsync "You are a professional translator to English.", "To jest rewolucja szutcznej inteligencji! VBA na zawsze!"
End Sub

Sub m_demoSource_OnSendCompleted()
    MsgBox m_demoSource.Result
End Sub

Sub ChatGpt()
    Dim myObj As ChatGptCom.Chat
    Set myObj = New ChatGptCom.Chat
    myObj.AskAsync "You are a professional translato to English.", "Cześć, witamy z Office VBA"
End Sub

Sub GetEnvironmentVariable()
    Dim envVarName As String
    Dim envVarValue As String
    envVarName = "OPENAI_API_KEY"
    envVarValue = Environ(envVarName)
    MsgBox "The value of the " & envVarName & " environment variable is:" & vbCrLf & envVarValue
End Sub

Chat form:

Option Explicit

Private WithEvents m_chatSource As Chat

Private Sub UserForm_Initialize()
    Set m_chatSource = New ChatGptCom.Chat
    m_chatSource.Create "You are a helpful assistant", 2000, "gpt-3.5-turbo"
End Sub

Private Sub SendButton_Click()
    Dim MessageText As String
    MessageText = MessageTextBox.Text
    MessagesListBox.AddItem MessageText
    MessageTextBox.Text = ""
    m_chatSource.MessageAsync MessageText, "user", True
End Sub

Sub m_chatSource_OnSendCompleted()
    Dim MessageText As String
    MessageText = m_chatSource.Result
    MessagesListBox.AddItem MessageText
End Sub

Chat form:

Option Explicit

Private WithEvents m_chatSource As Chat

Private Sub UserForm_Initialize()
    Set m_chatSource = New ChatGptCom.Chat
    m_chatSource.Create "You are a helpful assistant", 2000, "gpt-3.5-turbo"
End Sub

Private Sub SendButton_Click()
    Dim MessageText As String
    MessageText = MessageTextBox.Text
    ChatTextBox.Text = ChatTextBox.Text & vbCrLf & MessageText
    MessageTextBox.Text = ""
    m_chatSource.MessageAsync MessageText, "user", True
End Sub

Sub m_chatSource_OnSendCompleted()
    Dim MessageText As String
    MessageText = m_chatSource.Result
    ChatTextBox.Text = ChatTextBox.Text & vbCrLf & MessageText
End Sub

NuGet

  • ChatGPT - An OpenAI api library for .NET.
  • ChatGPT.Core - An OpenAI client core library for .NET.
  • ChatGPT.UI - An OpenAI client user interface library for .NET.
  • ChatGPT.CLI - An .NET ChatGPT tool.
  • ChatGptCom - An OpenAI api library for .NET COM interop.

Docs

License

ChatGPT is licensed under the MIT license.

About

适用于MacOS、Windows、Linux、Android、iOS和浏览器的ChatGPT C#客户端。由Avalonia UI框架提供支持。

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 98.2%
  • Other 1.8%