克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

ChatGPT

Build Status CI

GitHub release Github All Releases Github Releases

NuGet NuGet

A ChatGPT C# client for graphical user interface runs on MacOS, Windows, Linux, Android, iOS and Browser. Powered by Avalonia UI framework.

To make the app work, you need to set the OpenAI API key as the OPENAI_API_KEY environment variable or set API key directly in app settings.

You can try client using browser version here.

image

Shortcuts

Main Window

  • Ctrl+Shift+A - Toggle between transparent and acrylic blur window style.
  • Ctrl+Shift+S - Toggle between visible and hidden window state.

Message Prompt

  • Enter - Send prompt.
  • Escape - Cancel edit.
  • F2 - Edit prompt.
  • Shift+Enter, Alt+Enter - Insert new line.

Overriding OpenAI api url

var chat = Defaults.Locator.GetService<IChatService>();
chat.SetApiUrl("you api url");

OpenAI ChatGPT web version import

You can import OpenAI ChatGPT web version chats backup created using this script.

Build

  1. Install .NET 7.0
  2. Run dotnet workload install ios android wasm-tools command
  3. dotnet publish -c Release command inside project directory (mobile/desktop) or dotnet run for desktop to just run

Dependencies

.NET tool

Install:

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

Uninstall:

dotnet tool uninstall --global ChatGPT.CLI

Usage

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

Examples

  • Using .NET tool chatgpt command:

C# to VB

chatgpt -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#

chatgpt -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

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

Write API documentation

chatgpt -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."
  • Run from source

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."

Write API documentation

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."

Settings file format

{
    "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

In the build release directory ChatGPT\ChatGptCom\bin\Release\net462\ run following command to register 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

Add 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.

MIT License Copyright (c) Wiesław Šoltés Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

这是基于C#开发的客户端,兼容MacOS、Windows、Linux、Android、iOS系统,支持OpenAI_API_key自定义设置,还有API参数自定义设置。 PC端版本支持快捷键操作,内置了多种对换模式:助理、翻译、开发人员、技术文章作者。 该项目界面美观大气,不管是用于二次开发,还是学习用途,都是非常不错的选择。 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化