Skip to content

Commit

Permalink
Merge pull request #259 from Hikari-Haru/instruction-setting
Browse files Browse the repository at this point in the history
System instruction setting and text file prompt for ask
  • Loading branch information
Kav-K authored Apr 17, 2023
2 parents 7a18411 + d064234 commit 5107343
Show file tree
Hide file tree
Showing 17 changed files with 299 additions and 86 deletions.
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)

# Overview
A robust, all-in-one GPT3 interface for Discord. Chat just like ChatGPT right inside Discord! Generate beautiful AI art using DALL-E 2! Automatically moderate your server using AI! Upload documents, videos, and files to get AI-assisted insights! A thorough integration with permanent conversation memory powered by [Pinecone](https://www.pinecone.io/), automatic request retry, fault tolerance and reliability for servers of any scale, and much more.
A robust, all-in-one GPT interface for Discord. Chat just like ChatGPT right inside Discord! Generate beautiful AI art using DALL-E 2! Automatically moderate your server using AI! Upload documents, videos, and files to get AI-assisted insights! A thorough integration with permanent conversation memory powered by [Pinecone](https://www.pinecone.io/), automatic request retry, fault tolerance and reliability for servers of any scale, and much more.

SUPPORT SERVER FOR BOT SETUP: https://discord.gg/WvAHXDMS7Q (You can try out the bot here also in a limited fashion)

Expand Down Expand Up @@ -50,23 +50,23 @@ SUPPORT SERVER FOR BOT SETUP: https://discord.gg/WvAHXDMS7Q (You can try out the

- **GPT4 API Integration** - GPT-4 is fully supported by our bot, if you're off the waitlist, you can put in your organization ID in the environment file and it will work out of the box and allow you to select gpt-4 models in /system settings and etc!

- **AI-Assisted Google Search** - Use GPT3 to browse the internet, you can search the internet for a query and GPT3 will look at the top websites for you automatically and formulate an answer to your query! You can also ask follow-up questions, this is kinda like BingGPT, but much better lol!
- **AI-Assisted Google Search** - Use GPT to browse the internet, you can search the internet for a query and GPT will look at the top websites for you automatically and formulate an answer to your query! You can also ask follow-up questions, this is kinda like BingGPT, but much better lol!
<p align="center"/>
<img src="https://i.imgur.com/YxkS0S5.png"/>
</p>

- **CUSTOM INDEXES** - You can now upload files to your discord server and use them as a source of knowledge when asking GPT3 questions. You can also use webpage links as context, images, full documents, csvs, powerpoints, audio files, and even **youtube videos**! Read more in the 'Custom Indexes' section below. Here's an example below with a youtube video:
- **CUSTOM INDEXES** - You can now upload files to your discord server and use them as a source of knowledge when asking GPT questions. You can also use webpage links as context, images, full documents, csvs, powerpoints, audio files, and even **youtube videos**! Read more in the 'Custom Indexes' section below. Here's an example below with a youtube video:

<p align="center"/>
<img src="https://i.imgur.com/H98UXad.png"/>
</p>

# Features
- **Directly prompt GPT3 with `/gpt ask <prompt>`**
- **Directly prompt GPT with `/gpt ask <prompt>`**

- **Have long term, permanent conversations with the bot, just like chatgpt, with `/gpt converse`** - Conversations happen in threads that get automatically cleaned up!

- **Custom Indexes** - Use your own files, pdfs, txt files, websites, discord channel content as context when asking GPT3 questions!
- **Custom Indexes** - Use your own files, pdfs, txt files, websites, discord channel content as context when asking GPT questions!

- **AI-Assisted Google Search** - Speaks for itself!

Expand All @@ -78,11 +78,13 @@ SUPPORT SERVER FOR BOT SETUP: https://discord.gg/WvAHXDMS7Q (You can try out the

- **DeepL Translations** - Translate text with DeepL. `/translate <text>`

- **Redo Requests** - A simple button after the GPT3 response or DALL-E generation allows you to redo the initial prompt you asked. You can also redo conversation messages by just editing your message!
- **Redo Requests** - A simple button after the GPT response or DALL-E generation allows you to redo the initial prompt you asked. You can also redo conversation messages by just editing your message!

- **Automatic AI-Based Server Moderation** - Moderate your server automatically with AI!

- **Auto-retry on API errors** - Automatically resend failed requests to OpenAI's APIs!

- Set context-based pre-instructions per-user and per-channel

- Automatically re-send your prompt and update the response in place if you edit your original prompt!

Expand All @@ -102,9 +104,9 @@ These commands are grouped, so each group has a prefix but you can easily tab co

`/help` - Display help text for the bot

### (Chat)GPT3 Commands
### (Chat)GPT Commands

`/gpt ask <prompt> <temp> <top_p> <frequency penalty> <presence penalty>` Ask the GPT3 Davinci 003 model a question. Optional overrides available
`/gpt ask <prompt> <temp> <top_p> <frequency penalty> <presence penalty>` Ask the GPT Davinci 003 model a question. Optional overrides available

`/gpt edit <instruction> <input> <temp> <top_p>` Use the bot to edit text using the given instructions for how to do it, currently an alpha openai feature so results might vary. Editing is currently free

Expand All @@ -127,6 +129,8 @@ These commands are grouped, so each group has a prefix but you can easily tab co
- `minimal` - Start a conversation with the bot, like ChatGPT, with minimal context (saves tokens)

`/gpt end` - End a conversation with the bot.

`/gpt instruction mode:<set/get/clear> type:<user/channel> <instruction> <instruction_file>` - Set, get, or clear a custom instruction for the bot to use when asking questions.

### DALL-E2 Commands

Expand All @@ -136,7 +140,7 @@ These commands are grouped, so each group has a prefix but you can easily tab co

### Search Commands

`/search query:<prompt> scope:<number of sites to visit> nodes:<how deep gpt3 should think>` - Search the internet with GPT3 assistance!
`/search query:<prompt> scope:<number of sites to visit> nodes:<how deep gpt should think>` - Search the internet with GPT assistance!

- The `scope` defines how many top level websites to visit during the search, capped at 6
- `nodes` defines how many nodes inside the built index after webpage retrieval to use.
Expand Down
75 changes: 68 additions & 7 deletions cogs/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,14 +308,73 @@ async def config(
# GPT commands
#

@add_to_group("gpt")
@discord.slash_command(
name="instruction",
description="Set your own system instruction",
guild_ids=ALLOWED_GUILDS,
)
@discord.option(
name="mode",
description="Set/Get/Clear prompt",
choices=["set", "get", "clear"],
required=True
)
@discord.option(
name="type",
description="Enable for channel or for user",
choices=["user", "channel"],
required=True
)
@discord.option(
name="instruction",
description="The instruction to set",
required=False
)
@discord.option(
name="instruction_file",
description="The instruction to set from a txt file",
input_type=discord.SlashCommandOptionType.attachment,
required=False
)
@discord.option(
name="private",
description="Will only be visible to you",
required=False
)
@discord.guild_only()
async def instruction(
self,
ctx: discord.ApplicationContext,
mode: str,
type: str,
instruction: str,
instruction_file: discord.Attachment,
private: bool,
):
await self.converser_cog.instruction_command(
ctx,
mode,
type,
instruction,
instruction_file,
private
)

@add_to_group("gpt")
@discord.slash_command(
name="ask",
description="Ask GPT3 something!",
description="Ask the bot something!",
guild_ids=ALLOWED_GUILDS,
)
@discord.option(
name="prompt", description="The prompt to send to GPT3", required=True
name="prompt", description="The prompt to send to the model", required=False
)
@discord.option(
name="prompt_file",
description="The prompt file to send to the model. Is added before the prompt, both can be combined",
required=False,
input_type=discord.SlashCommandOptionType.attachment,
)
@discord.option(
name="model",
Expand Down Expand Up @@ -359,6 +418,7 @@ async def ask(
self,
ctx: discord.ApplicationContext,
prompt: str,
prompt_file: discord.Attachment,
model: str,
private: bool,
temperature: float,
Expand All @@ -374,18 +434,19 @@ async def ask(
top_p,
frequency_penalty,
presence_penalty,
prompt_file=prompt_file,
model=model,
)

@add_to_group("gpt")
@discord.slash_command(
name="edit",
description="Ask GPT3 to edit some text!",
description="Ask the bot to edit some text!",
guild_ids=ALLOWED_GUILDS,
)
@discord.option(
name="instruction",
description="How you want GPT3 to edit the text",
description="How you want the bot to edit the text",
required=True,
)
@discord.option(
Expand Down Expand Up @@ -430,7 +491,7 @@ async def edit(
@add_to_group("gpt")
@discord.slash_command(
name="converse",
description="Have a conversation with GPT3",
description="Have a conversation with GPT",
guild_ids=ALLOWED_GUILDS,
)
@discord.option(
Expand Down Expand Up @@ -533,7 +594,7 @@ async def converse(
@add_to_group("gpt")
@discord.slash_command(
name="end",
description="End a conversation with GPT3",
description="End a conversation with GPT",
guild_ids=ALLOWED_GUILDS,
)
@discord.guild_only()
Expand Down Expand Up @@ -1022,7 +1083,7 @@ async def summarize_action(self, ctx, message: discord.Message):
# Search slash commands
@discord.slash_command(
name="search",
description="Search google alongside GPT3 for something",
description="Search google alongside GPT for something",
guild_ids=ALLOWED_GUILDS,
checks=[Check.check_search_roles()],
)
Expand Down
Loading

0 comments on commit 5107343

Please sign in to comment.