該存儲庫包含一個基於C#的Slack GPT機器人,該機器人使用OpenAI的GPT模型來回答用戶的問題。該實現基於Slack Sockets API,這意味著無需在服務器上託管機器人。該機器人可以在任何機器上運行。
您喜歡這個工具嗎?給我們訪問:) https://prographers.com/
-context
的系統消息appsettings.json
中的OpenAIKey
變量中。注意:使用OpenAI API需要一個付費/試用帳戶。您可以在此處找到有關定價的更多信息。
在運行Slack GPT機器人之前,您需要為Slack Bot配置適當的權限。請按照以下步驟設置必要的權限:
app_mentions:read
:允許機器人閱讀提及事件。chat:write
:允許機器人發送消息。groups:history
:允許機器人在私人渠道中讀取消息。channels:history
:允許機器人在公共渠道中讀取消息。SlackBotToken
。SlackAppToken
的令牌並添加connections:write
範圍。app_mention
事件與app_mentions:read
在切換的“訂閱機器人事件”部分中的範圍。 dotnet run --project Slack-GPT-Socket
或有關如何託管它的更多信息,請參見#Docker。
您可以使用模型的名稱啟動消息,而沒有參數:例如:
@GPT-4 Turbo今天好嗎?
將使用GPT-3.5-Turbo而不是默認GPT-4模型。有關更多別名,請參見GPTCLIENT。
有一些內置參數。使用/gpt help
查看它們。您可以在appsettings.json
文件中修改參數,也可以根據請求進行修改。
有關默認值或appsettings.Example.json
的更多信息,請參見GPTDEFAULTS.CS。
預定義命令
您可以將自己的自定義參數添加到bot中,以最大程度地減少每個已評估的請求的鍵入。為此,請將其定義添加到appsettings.json
中的GptCommands
部分。例如:
"GptCommands" : {
"Commands" : [
{
"Command" : " -refactor " ,
"Description" : " Tells GPT to refactor provided code " ,
"Prompt" : " Given the following code, refactor it to be more readable and maintainable. Please provide code documentation for all members in the code and comments where appropriate. "
},
{
"Command" : " -prographers " ,
"Description" : " A command to add infomation about Prographers " ,
"Prompt" : " Prographers is software-house company that specializes in 3D product configurators. Prographers exists since 2016 and currently hires around 20 people. Prographers solutions focus on Web applications that are used by companies to configure their products. Applications produced are focusing on high-quality graphics and design, resulting in great products that customers awe. Prographers is located in Warsaw, Poland. "
}
}
用法:
@gpt -4-編寫者您對著作作者有什麼了解?
@gpt -4 -refactor
public class Foo { public void Bar() { Console.WriteLine("Hello World"); } }
動態命令
以類似的方式,您可以創建動態命令。為此,請調用/gpt commands add -command "prompt" "description" -global
命令,帶有命令名稱和提示。
-command
如何調用此命令。例如: -prographers
-prompt
將用於此命令的提示。例如: Prographers is software-house company...
-description
命令的描述。例如: A command to add infomation about Prographers
這是可選的。-global
標誌將使所有用戶可用。否則,它將適用於創建它的用戶。使用/gpt commands help
查看有關命令的更多信息。
您可以使用以下命令啟動Docker容器:
docker run -v ./appsettings.json:/app/appsettings.json --restart always ghcr.io/prographers/slack-gpt:latest
您也可以使用docker-compose.yml
文件來啟動脫離的容器。 Docker Compose將自動從GitHub容器註冊表中拉出圖像,並在發生這種情況時啟動容器。它將使用watch望塔來做到這一點。
docker-compose up -d
請記住,將AppSettings.json文件與兩種情況的命令相同的目錄中。
這兩個圖像均未在任何端口上暴露,也無法從外部訪問。訪問容器的唯一方法是通過Slack API。該容器還作為非根用戶運行,無法訪問主機系統。
git clone https://github.com/Prographers/Slack-GPT.git
cd Slack-GPT
dotnet restore
通知消息!
線程支持!
錯誤消息!