Skip to content

Commit 27b5c81

Browse files
authored
Merge pull request #33 from A-Baji/dev
prep for 2.0.0 release
2 parents 8d25017 + 496cbe2 commit 27b5c81

File tree

5 files changed

+44
-49
lines changed

5 files changed

+44
-49
lines changed

CHANGELOG.md

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,37 @@
22

33
Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) convention.
44

5-
## [2.0.0] - TBD
5+
## [2.0.0] - 06-15-2023
66

77
### Added
8-
- A changelog
9-
- An openAI image generation command
10-
- The gpt3.5 model to the openai command and made it the default
11-
- A chatGPT command with chat history functionality
12-
- Custom emoji support for custom models.
138

14-
### Fixed
15-
- Upgrading the packaged executable version now properly applies any new features to existing, non-custom cogs
9+
- a changelog
10+
- an openAI image generation command
11+
- the gpt3.5 model to the openai command and made it the default
12+
- a chatGPT command with chat history functionality
13+
- custom emoji support for custom models.
1614

17-
### Changed
15+
### Fixed
1816

19-
- Made prompt bolding for custom model completions a discord command parameter
17+
- upgrading the packaged executable version now properly applies any new features to existing, non-custom cogs
18+
- bug where two stars would appear for blank prompts for custom model completions
2019

21-
### Fixed
20+
### Changed
2221

23-
- Bug where two stars would appear for blank prompts for custom model completions
22+
- made prompt bolding for custom model completions a discord command parameter
23+
- updated modelizer to version [2.0.0](https://github.com/A-Baji/discordAI-modelizer/releases/tag/2.0.0)
2424

2525
## [1.3.2] - 02-22-2023
2626

2727
### Changed
2828

29-
- Update modelizer to version [1.2.2](https://github.com/A-Baji/discordAI-modelizer/compare/1.2.1...1.2.2)
29+
- updated modelizer to version [1.2.2](https://github.com/A-Baji/discordAI-modelizer/releases/tag/1.2.2)
3030

3131
## [1.3.1] - 02-19-2023
3232

3333
### Changed
3434

35-
- Update modelizer to version [1.2.1](https://github.com/A-Baji/discordAI-modelizer/compare/1.2.0...1.2.1)
35+
- updated modelizer to version [1.2.1](https://github.com/A-Baji/discordAI-modelizer/releases/tag/1.2.1)
3636

3737
## [1.3.0] - 02-17-2023
3838

@@ -45,40 +45,41 @@ Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and
4545

4646
### Changed
4747

48-
- Update modelizer to version [1.2.0](https://github.com/A-Baji/discordAI-modelizer/compare/1.1.0...1.2.0)
48+
- updated modelizer to version [1.2.0](https://github.com/A-Baji/discordAI-modelizer/releases/tag/1.2.0)
4949

5050
## [1.2.1] - 02-12-2023
5151

5252
### Added
5353

54-
- Option to provide a different openai key to the customai command
54+
- option to provide a different openai key to the customai command
5555

5656
## [1.2.0] - 02-11-2023
5757

5858
### Changed
5959

60-
- Update modelizer to version [1.1.0](https://github.com/A-Baji/discordAI-modelizer/compare/1.0.1...1.1.0)
60+
- updated modelizer to version [1.1.0](https://github.com/A-Baji/discordAI-modelizer/releases/tag/1.1.0)
6161

6262
## [1.1.1] - 02-11-2023
6363

6464
### Added
6565

66-
- Pin modelizer to version [1.1.0](https://github.com/A-Baji/discordAI-modelizer/compare/1.0.0...1.0.1)
66+
- pinned modelizer to version [1.1.0](https://github.com/A-Baji/discordAI-modelizer/releases/tag/1.0.1)
6767

6868
### Changed
6969

70-
- Switched from using `os.path` to `pathlib`
70+
- switched from using `os.path` to `pathlib`
7171

7272
## [1.1.0] - 01-29-2023
7373

7474
### Changed
7575

76-
- Modified readme
76+
- modified readme
7777

78+
[2.0.0]: https://github.com/A-Baji/discordAI/compare/1.3.2...2.0.0
7879
[1.3.2]: https://github.com/A-Baji/discordAI/compare/1.3.1...1.3.2
7980
[1.3.1]: https://github.com/A-Baji/discordAI/compare/1.3.0...1.3.1
8081
[1.3.0]: https://github.com/A-Baji/discordAI/compare/1.2.1...1.3.0
8182
[1.2.1]: https://github.com/A-Baji/discordAI/compare/1.2.0...1.2.1
8283
[1.2.0]: https://github.com/A-Baji/discordAI/compare/1.1.1...1.2.0
8384
[1.1.1]: https://github.com/A-Baji/discordAI/compare/1.1.0...1.1.1
84-
[1.1.0]: https://github.com/A-Baji/discordAI/releases/tag/1.1.0
85+
[1.1.0]: https://github.com/A-Baji/discordAI/compare/1.0.0...1.1.0

discordai/bot/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
def start_bot(config, sync=False):
3030
bot.config = config
3131
bot.chat_messages = {}
32-
bot.chat_init = {}
3332
bot.emoji_map = {}
3433

3534
@bot.event

discordai/bot/cogs/chatgpt.py

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ def __init__(self, bot):
4949
description="Generate an chatGPT completion",
5050
)
5151
@app_commands.describe(
52-
prompt="The prompt to pass to chatGPT: Default=\"\"",
52+
prompt="The prompt to pass to chatGPT",
5353
role=" system | user | asssistant: Default=user",
5454
temp="What sampling temperature to use. Higher values means more risks: Min=0 Max=1 Default=1",
5555
presence_penalty="Number between -2.0 and 2.0. Positive values will encourage new topics: Min=-2 Max=2 Default=0",
5656
frequency_penalty="Number between -2.0 and 2.0. Positive values will encourage new words: Min=-2 Max=2 Default=0")
57-
async def chatgpt(self, context: Context, prompt: str = "", role: Roles = Roles.user, temp: float = 1.0,
57+
async def chatgpt(self, context: Context, prompt: str, role: Roles = Roles.user, temp: float = 1.0,
5858
presence_penalty: float = 0.0, frequency_penalty: float = 0.0):
5959
openai.api_key = self.bot.config["openai_key"]
6060
model = "gpt-3.5-turbo"
@@ -63,7 +63,7 @@ async def chatgpt(self, context: Context, prompt: str = "", role: Roles = Roles.
6363
freqPen = min(max(frequency_penalty, -2), 2)
6464

6565
if context.guild.id not in self.bot.chat_messages:
66-
self.bot.chat_messages[context.guild.id] = [{"role": "system", "content": self.bot.chat_init[context.guild.id]}] if context.guild.id in self.bot.chat_init and self.bot.chat_init[context.guild.id] else []
66+
self.bot.chat_messages[context.guild.id] = []
6767
self.bot.chat_messages[context.guild.id].append({"role": role.value, "content": prompt})
6868
messages = self.bot.chat_messages[context.guild.id]
6969

@@ -88,7 +88,7 @@ async def chatgpt(self, context: Context, prompt: str = "", role: Roles = Roles.
8888
presence_penalty=freqPen,
8989
max_tokens=325 if 325 <= 4096-token_cost else token_cost
9090
)
91-
await context.send(f"{prompt}\n{response['choices'][0]['message']['content']}{warning.value}"[:2000])
91+
await context.send(f"{prompt}\n\n{response['choices'][0]['message']['content']}{warning.value}"[:2000])
9292
self.bot.chat_messages[context.guild.id].append(response['choices'][0]['message'])
9393
except Exception as error:
9494
print(f"Failed to generate valid response for prompt: {prompt}\nError: {error}")
@@ -97,32 +97,27 @@ async def chatgpt(self, context: Context, prompt: str = "", role: Roles = Roles.
9797
)
9898

9999
@commands.hybrid_command(
100-
name="resetchat",
100+
name="chatreset",
101101
description="Resets the chat history for chatGPT completions",
102102
)
103-
async def resetchat(self, context):
104-
self.bot.chat_messages[context.guild.id] = [{"role": "system", "content": self.bot.chat_init[context.guild.id]}] if context.guild.id in self.bot.chat_init and self.bot.chat_init[context.guild.id] else []
103+
async def chatreset(self, context):
104+
self.bot.chat_messages[context.guild.id] = []
105105
await context.send("Chat history has been reset")
106106

107107
@commands.hybrid_command(
108-
name="setchatinit",
109-
description="Set the initialization message, a guide for the AI on how to respond to future chat messages",
108+
name="chatinit",
109+
description="Initialize chatGPT with an instructional message",
110110
)
111-
@app_commands.describe(message="The init message for chatGPT completions. Omit to reset")
112-
async def setchatinit(self, context, message: str = ""):
113-
self.bot.chat_init[context.guild.id] = message
114-
if message:
115-
if context.guild.id in self.bot.chat_messages:
116-
if self.bot.chat_messages[context.guild.id] and self.bot.chat_messages[context.guild.id][0]["role"] == "system":
117-
self.bot.chat_messages[context.guild.id][0] = {"role": "system", "content": self.bot.chat_init[context.guild.id]}
118-
else:
119-
self.bot.chat_messages[context.guild.id] = [{"role": "system", "content": self.bot.chat_init[context.guild.id]}] + self.bot.chat_messages[context.guild.id]
120-
await context.send("Chat init message has been set")
111+
@app_commands.describe(message="The initialization message")
112+
async def chatinit(self, context, message: str):
113+
if context.guild.id in self.bot.chat_messages:
114+
if self.bot.chat_messages[context.guild.id] and self.bot.chat_messages[context.guild.id][0]["role"] == "system":
115+
self.bot.chat_messages[context.guild.id][0] = {"role": "system", "content": message}
116+
else:
117+
self.bot.chat_messages[context.guild.id] = [{"role": "system", "content": message}] + self.bot.chat_messages[context.guild.id]
121118
else:
122-
if context.guild.id in self.bot.chat_messages:
123-
if self.bot.chat_messages[context.guild.id] and self.bot.chat_messages[context.guild.id][0]["role"] == "system":
124-
self.bot.chat_messages[context.guild.id].pop(0)
125-
await context.send("Chat init message has been reset")
119+
self.bot.chat_messages[context.guild.id] = [{"role": "system", "content": message}]
120+
await context.send(f"ChatGPT has been initialized with \"{message}\"")
126121

127122
async def setup(bot):
128123
await bot.add_cog(ChatGPT(bot))

discordai/bot/cogs/openai.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ def __init__(self, bot):
2929
description="Generate an openAI completion",
3030
)
3131
@app_commands.describe(
32-
prompt="The prompt to pass to openAI: Default=\"\"",
32+
prompt="The prompt to pass to openAI",
3333
model=" chatgpt | davinci | curie | babbage | ada: Default=chatgpt",
3434
temp="What sampling temperature to use. Higher values means more risks: Min=0 Max=1 Default=1",
3535
presence_penalty="Number between -2.0 and 2.0. Positive values will encourage new topics: Min=-2 Max=2 Default=0",
3636
frequency_penalty="Number between -2.0 and 2.0. Positive values will encourage new words: Min=-2 Max=2 Default=0")
37-
async def openai(self, context: Context, prompt: str = "", model: Models = Models.chatgpt, temp: float = 1.0,
37+
async def openai(self, context: Context, prompt: str, model: Models = Models.chatgpt, temp: float = 1.0,
3838
presence_penalty: float = 0.0, frequency_penalty: float = 0.0):
3939
openai.api_key = self.bot.config["openai_key"]
4040
temp = min(max(temp, 0), 1)
@@ -61,7 +61,7 @@ async def openai(self, context: Context, prompt: str = "", model: Models = Model
6161
frequency_penalty=presPen,
6262
presence_penalty=freqPen,
6363
max_tokens=325,
64-
echo=True if prompt else False
64+
echo=True
6565
)
6666
await context.send(response["choices"][0]["text"][:2000])
6767
except Exception as error:

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ discord.py
22
openai
33
tiktoken
44
appdirs
5-
discordai_modelizer @ git+https://github.com/A-Baji/discordAI-modelizer.git@1.2.2
5+
discordai_modelizer @ git+https://github.com/A-Baji/discordAI-modelizer.git@2.0.0

0 commit comments

Comments
 (0)