Skip to content

Commit

Permalink
Merge branch 'Kav-K:main' into google-perspective
Browse files Browse the repository at this point in the history
  • Loading branch information
Paillat-dev authored Dec 31, 2023
2 parents 067863c + 53ed671 commit 4e79f18
Show file tree
Hide file tree
Showing 23 changed files with 762 additions and 173 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/black-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
password: ${{ secrets.SSH_PASS }}
port: 22
source: gpt3discord.py
target: /home/kaveen/GPTDiscord
target: /home/GPTDiscord
- name: copy file via ssh password
uses: appleboy/scp-action@master
with:
Expand All @@ -47,7 +47,7 @@ jobs:
password: ${{ secrets.SSH_PASS }}
port: 22
source: conversation_starter_pretext.txt
target: /home/kaveen/GPTDiscord
target: /home/GPTDiscord
- name: copy file via ssh password
uses: appleboy/scp-action@master
with:
Expand All @@ -56,44 +56,44 @@ jobs:
password: ${{ secrets.SSH_PASS }}
port: 22
source: image_optimizer_pretext.txt
target: /home/kaveen/GPTDiscord/
target: /home/GPTDiscord/
- name: Copy via ssh
uses: garygrossgarten/github-action-scp@release
with:
local: cogs
remote: /home/kaveen/GPTDiscord/cogs
remote: /home/GPTDiscord/cogs
host: lab.kaveenk.dev
username: root
password: ${{ secrets.SSH_PASS }}
- name: Copy via ssh
uses: garygrossgarten/github-action-scp@release
with:
local: models
remote: /home/kaveen/GPTDiscord/models
remote: /home/GPTDiscord/models
host: lab.kaveenk.dev
username: root
password: ${{ secrets.SSH_PASS }}
- name: Copy via ssh
uses: garygrossgarten/github-action-scp@release
with:
local: openers
remote: /home/kaveen/GPTDiscord/openers
remote: /home/GPTDiscord/openers
host: lab.kaveenk.dev
username: root
password: ${{ secrets.SSH_PASS }}
- name: Copy via ssh
uses: garygrossgarten/github-action-scp@release
with:
local: services
remote: /home/kaveen/GPTDiscord/services
remote: /home/GPTDiscord/services
host: lab.kaveenk.dev
username: root
password: ${{ secrets.SSH_PASS }}
- name: Restart bot!
uses: fifsky/ssh-action@master
with:
command: |
cd /home/kaveen/GPTDiscord
cd /home/GPTDiscord
kill -9 $(cat bot.pid)
rm bot.pid
screen -dmS GPTBot python3.9 gpt3discord.py
Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<h1 align="center"> GPT Discord</h1>
<p align="center">An all-in-one GPT-3 interface for Discord. ChatGPT-style conversations, image generation, AI-moderation, custom indexes/knowledgebase, youtube summarizer, and more!</p>
<p align="center">An all-in-one GPT-3 interface for Discord. ChatGPT-style conversations, image generation, AI-moderation, custom indexes/knowledgebase, youtube summarizer, and more!</p>

[![Docker](https://github.com/Kav-K/GPTDiscord/actions/workflows/build-and-publish-docker.yml/badge.svg)](https://github.com/Kav-K/GPTDiscord/actions/workflows/build-and-publish-docker.yml)
[![PyPi](https://github.com/Kav-K/GPTDiscord/actions/workflows/pypi_upload.yml/badge.svg)](https://github.com/Kav-K/GPTDiscord/actions/workflows/pypi_upload.yml)
Expand All @@ -19,6 +19,8 @@ We support everything from **multi-modality image understanding**, **code interp

Featuring code execution and environment manipulation by [E2B](https://e2b.dev)

We are migrating towards using [QDRANT](https://qdrant.tech/) as our vector database backing, we are moving away from pinecone.

# Overview of Capabilities
![Overview of Features](https://i.imgur.com/BZdORTL.png)
# Table of Contents
Expand Down Expand Up @@ -55,13 +57,13 @@ Custom indexing and Document Q&A<br>
</p>

# Recent Notable Updates
- **GPT-4-Vision support, GPT-4-Turbo, DALLE-3 Support** - Assistant support also coming soon!
-
- **Multi-modality + Drawing** - GPTDiscord now supports images sent to the bot during a conversation made with `/gpt converse`, and the bot can draw images for you and work with you on them!

- **Code Interpreter / Advanced Data Analysis** - Just like ChatGPT, GPTDiscord now has a fully-fledged code execution environment. You can work with GPT to execute your code in an isolated environment, with the ability to even install Python and system packages, and access the internet from the execution environment.

- **GPT-4-Vision support, GPT-4-Turbo, DALLE-3 Support** - Assistant support also coming soon!


- **Multi-modality** - GPTDiscord now supports images sent to the bot during a conversation made with `/gpt converse`!
- **Code Interpreter / Advanced Data Analysis** - Just like ChatGPT, GPTDiscord now has a fully-fledged code execution environment. You can work with GPT to execute your code in an isolated environment, with the ability to even install Python and system packages, and access the internet from the execution environment.


- **Drag And Drop Document Chat** - Chat with your documents by simply dragging and dropping files, or even links into discord chat! `/index chat`
Expand All @@ -70,7 +72,7 @@ Custom indexing and Document Q&A<br>
- **Internet-connected Chat!** - Chat with an instance of GPT3.5 or GPT-4 that's connected to Google and Wolfram Alpha and can browse and access links that you send it!

# Features
- **Multi-modal** with image understanding
- **Multi-modal** with image understanding, you can generate images with DALL-E within multi-modal conversations!
- **Code Interpreter / Advanced Data Analysis**
- Long-term, **permanent conversations** with GPT models
- **Use your own files**, PDFs, text files, websites, Discord channel content as context when asking GPT questions!
Expand Down
2 changes: 1 addition & 1 deletion auto_restarter.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def restart_service():
Restarts the service by running a series of system commands.
"""
commands = [
"cd /home/kaveen/GPTDiscord",
"cd /home/GPTDiscord",
"kill -9 $(cat bot.pid)",
"rm bot.pid",
"screen -dmS GPTBot python3.9 gpt3discord.py",
Expand Down
11 changes: 9 additions & 2 deletions cogs/code_interpreter_service_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,8 @@ async def code_interpreter_chat_command(
self,
ctx: discord.ApplicationContext,
model,
temperature,
top_p,
):
await ctx.defer()
embed_title = f"{ctx.user.name}'s code interpreter conversation with GPT"
Expand Down Expand Up @@ -453,7 +455,12 @@ async def code_interpreter_chat_command(
)
)

llm = ChatOpenAI(model=model, temperature=0, openai_api_key=OPENAI_API_KEY)
llm = ChatOpenAI(
model=model,
temperature=temperature,
top_p=top_p,
openai_api_key=OPENAI_API_KEY,
)

max_token_limit = 29000 if "gpt-4" in model else 7500

Expand Down Expand Up @@ -484,7 +491,7 @@ async def code_interpreter_chat_command(
"using your tools. However, the tools can only install one package at a time, if you need to "
"install multiple packages, call the tools multiple times. Always first display your code to "
"the user BEFORE you execute it using your tools. The user should always explicitly ask you "
"to execute code. Never execute code before showing the user the code first."
"to execute code. Never execute code before showing the user the code first. Your environment has 4GB RAM, 4vCPU, 2.5GB disk storage, keep this in mind when writing code."
),
}

Expand Down
100 changes: 88 additions & 12 deletions cogs/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,12 @@ async def edit(
description="Have a conversation with GPT",
guild_ids=ALLOWED_GUILDS,
)
@discord.option(
name="draw",
description="Allow GPT to draw images with DALL-E",
required=False,
default=False,
)
@discord.option(
name="opener",
description="Which sentence to start with, added after the file",
Expand Down Expand Up @@ -659,6 +665,7 @@ async def edit(
async def converse(
self,
ctx: discord.ApplicationContext,
draw: bool,
opener: str,
opener_file: str,
private: bool,
Expand All @@ -672,6 +679,7 @@ async def converse(
):
await self.converser_cog.converse_command(
ctx,
draw,
opener,
opener_file,
private,
Expand Down Expand Up @@ -832,13 +840,33 @@ async def load_index(
default="gpt-4-1106-preview",
autocomplete=Settings_autocompleter.get_function_calling_models,
)
@discord.option(
name="temperature",
description="The higher the value, the riskier the model will be",
required=False,
input_type=discord.SlashCommandOptionType.number,
max_value=1,
min_value=0,
default=0,
)
@discord.option(
name="top_p",
description="An alternative sampling distribution to temperature",
required=False,
input_type=discord.SlashCommandOptionType.number,
max_value=1,
min_value=0,
default=1,
)
async def talk(
self,
ctx: discord.ApplicationContext,
model: str,
temperature: float = 0,
top_p: float = 1,
):
await ctx.defer()
await self.index_cog.index_chat_command(ctx, model)
await self.index_cog.index_chat_command(ctx, model, temperature, top_p)

@add_to_group("index")
@discord.slash_command(
Expand Down Expand Up @@ -1066,7 +1094,7 @@ async def draw_old(self, ctx: discord.ApplicationContext, prompt: str):
name="style",
description="The style of the generated images, choose between realism/vivid",
required=False,
default="natural",
default="vivid",
autocomplete=Settings_autocompleter.get_dalle3_image_styles,
)
async def draw(
Expand Down Expand Up @@ -1188,17 +1216,39 @@ async def draw_action(self, ctx, message: discord.Message):
default="gpt-4-1106-preview",
autocomplete=Settings_autocompleter.get_function_calling_models,
)
@discord.option(
name="temperature",
description="The higher the value, the riskier the model will be",
required=False,
input_type=discord.SlashCommandOptionType.number,
max_value=1,
min_value=0,
default=0,
)
@discord.option(
name="top_p",
description="An alternative sampling distribution to temperature",
required=False,
input_type=discord.SlashCommandOptionType.number,
max_value=1,
min_value=0,
default=1,
)
async def chat_code(
self,
ctx: discord.ApplicationContext,
model: str,
temperature: float = 0,
top_p: float = 1,
):
if not self.code_interpreter_cog:
await ctx.respond(
"Code interpretation is disabled on this server.", ephemeral=True
)
return
await self.code_interpreter_cog.code_interpreter_chat_command(ctx, model=model)
await self.code_interpreter_cog.code_interpreter_chat_command(
ctx, model=model, temperature=temperature, top_p=top_p
)

"""
Translation commands and actions
Expand Down Expand Up @@ -1315,14 +1365,38 @@ async def summarize_action(self, ctx, message: discord.Message):
default="gpt-4-1106-preview",
autocomplete=Settings_autocompleter.get_function_calling_models,
)
@discord.option(
name="temperature",
description="The higher the value, the riskier the model will be",
required=False,
input_type=discord.SlashCommandOptionType.number,
max_value=1,
min_value=0,
default=0,
)
@discord.option(
name="top_p",
description="An alternative sampling distribution to temperature",
required=False,
input_type=discord.SlashCommandOptionType.number,
max_value=1,
min_value=0,
default=1,
)
async def chat(
self,
ctx: discord.ApplicationContext,
model: str,
search_scope: int = 2,
temperature: float = 0,
top_p: float = 1,
):
await self.search_cog.search_chat_command(
ctx, search_scope=search_scope, model=model
ctx,
search_scope=search_scope,
model=model,
temperature=temperature,
top_p=top_p,
)

# Search slash commands
Expand All @@ -1341,6 +1415,7 @@ async def chat(
input_type=discord.SlashCommandOptionType.integer,
max_value=16,
min_value=1,
default=3,
)
@discord.option(
name="nodes",
Expand All @@ -1349,6 +1424,7 @@ async def chat(
input_type=discord.SlashCommandOptionType.integer,
max_value=8,
min_value=1,
default=4,
)
@discord.option(
name="deep",
Expand All @@ -1361,14 +1437,14 @@ async def chat(
description="Response mode, doesn't work on deep searches",
guild_ids=ALLOWED_GUILDS,
required=False,
default="refine",
default="compact",
choices=["refine", "compact", "tree_summarize"],
)
@discord.option(
name="model",
description="The model to use for the request (querying, not composition)",
required=False,
default="gpt-4-32k",
default="gpt-4-1106-preview",
autocomplete=Settings_autocompleter.get_index_and_search_models,
)
@discord.option(
Expand All @@ -1383,12 +1459,12 @@ async def search(
self,
ctx: discord.ApplicationContext,
query: str,
scope: int,
nodes: int,
deep: bool,
response_mode: str,
model: str,
multistep: bool,
scope: int = 3,
nodes: int = 4,
deep: bool = False,
response_mode: str = "refine",
model: str = "gpt-4-1106-preview",
multistep: bool = False,
):
await self.search_cog.search_command(
ctx,
Expand Down
2 changes: 1 addition & 1 deletion cogs/image_service_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ async def draw_action(self, ctx, message):
message.content,
quality="hd",
image_size="1024x1024",
style="natural",
style="vivid",
from_action=True,
)

Expand Down
8 changes: 5 additions & 3 deletions cogs/index_service_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ async def on_message(self, message):
prompt += (
"\n{System Message: the user has just uploaded the file "
+ str(file.filename)
+ "Unless the user asked a specific question, do not use your tools and instead just acknowledge the upload}"
+ "\n"
)

# Link operations, allow for user link upload, we connect and download the content at the link.
Expand All @@ -180,9 +180,11 @@ async def on_message(self, message):
)
except openai.BadRequestError as e:
traceback.print_exc()
safe_remove_list(self.thread_awaiting_responses, message.channel.id)
await message.reply(
"This model is not supported with connected conversations."
)
return

if chat_result:
if len(chat_result) > 2000:
Expand All @@ -207,8 +209,8 @@ async def on_message(self, message):
)
safe_remove_list(self.thread_awaiting_responses, message.channel.id)

async def index_chat_command(self, ctx, model):
await self.index_handler.start_index_chat(ctx, model)
async def index_chat_command(self, ctx, model, temperature, top_p):
await self.index_handler.start_index_chat(ctx, model, temperature, top_p)
pass

async def rename_user_index_command(self, ctx, user_index, new_name):
Expand Down
Loading

0 comments on commit 4e79f18

Please sign in to comment.