small formatting and variable changes, added readme
This commit is contained in:
parent
a772460827
commit
fb973bbe59
@ -15,6 +15,8 @@ from operator import itemgetter
|
||||
openaikey = config.OPENAI_TOKEN
|
||||
gapikey = config.GIF_TOKEN
|
||||
garfkey = config.GARFBOT_TOKEN
|
||||
txtmodel = "gpt-3.5-turbo"
|
||||
imgmodel = "dall-e-3"
|
||||
|
||||
intents = discord.Intents.default()
|
||||
intents.members = True
|
||||
@ -47,7 +49,7 @@ async def generate_chat_response(question):
|
||||
try:
|
||||
client = AsyncOpenAI(api_key = openaikey)
|
||||
response = await client.chat.completions.create(
|
||||
model="gpt-3.5-turbo",
|
||||
model=txtmodel,
|
||||
messages=[
|
||||
{"role": "system", "content": "Pretend you are sarcastic Garfield."},
|
||||
{"role": "user", "content": f"{question}"}
|
||||
@ -70,7 +72,7 @@ async def generate_image(prompt):
|
||||
try:
|
||||
client = AsyncOpenAI(api_key = openaikey)
|
||||
response = await client.images.generate(
|
||||
model="dall-e-3",
|
||||
model=imgmodel,
|
||||
prompt=prompt,
|
||||
n=1,
|
||||
size="1024x1024"
|
||||
|
@ -5,6 +5,7 @@ import os
|
||||
|
||||
openai.api_key = config.OPENAI_TOKEN
|
||||
jonkey = config.JONBOT_TOKEN
|
||||
model = "gpt-3.5-turbo"
|
||||
|
||||
intents = discord.Intents.default()
|
||||
intents.messages = True
|
||||
@ -13,7 +14,7 @@ client = discord.Client(intents=intents)
|
||||
|
||||
@client.event
|
||||
async def on_ready():
|
||||
print(f"Logged in as {client.user.name} running gpt-3.5-turbo-0613.", flush=True)
|
||||
print(f"Logged in as {client.user.name} running gpt-3.5-turbo.", flush=True)
|
||||
|
||||
@client.event
|
||||
async def on_message(message):
|
||||
@ -23,7 +24,7 @@ async def on_message(message):
|
||||
question = message.content[7:] if message.content.lower().startswith("hey jon") else message.content
|
||||
try:
|
||||
response = openai.ChatCompletion.create(
|
||||
model="gpt-3.5-turbo",
|
||||
model=model,
|
||||
messages=[
|
||||
{"role": "system", "content": "Pretend you are friendly Jon Arbuckle."},
|
||||
{"role": "user", "content": f"{question}"}
|
||||
|
@ -5,6 +5,7 @@ import os
|
||||
|
||||
openai.api_key = config.OPENAI_TOKEN
|
||||
moneykey = config.MONEYBOT_TOKEN
|
||||
model = "gpt-4"
|
||||
|
||||
intents = discord.Intents.default()
|
||||
intents.messages = True
|
||||
@ -13,7 +14,7 @@ client = discord.Client(intents=intents)
|
||||
|
||||
@client.event
|
||||
async def on_ready():
|
||||
print(f"Logged in as {client.user.name} running gpt-3.5-turbo-0613.", flush=True)
|
||||
print(f"Logged in as {client.user.name} running gpt-4.", flush=True)
|
||||
|
||||
@client.event
|
||||
async def on_message(message):
|
||||
@ -23,7 +24,7 @@ async def on_message(message):
|
||||
question = message.content[9:] if message.content.lower().startswith("hey money") else message.content
|
||||
try:
|
||||
response = openai.ChatCompletion.create(
|
||||
model="gpt-4",
|
||||
model=model,
|
||||
messages=[
|
||||
{"role": "system", "content": "Pretend you are eccentric conspiracy theorist Planetside 2 gamer named Dr. Moneypants."},
|
||||
{"role": "user", "content": f"{question} please keep it short with religious undertones"}
|
||||
@ -32,7 +33,7 @@ async def on_message(message):
|
||||
)
|
||||
answer = response['choices'][0]['message']['content']
|
||||
answer = answer.replace("an AI language model", "a man of God")
|
||||
answer = answer.replace("language model", "man of God")
|
||||
answer = answer.replace("language model AI", "man of God")
|
||||
await message.channel.send(answer)
|
||||
except Exception as e:
|
||||
e = str(e)
|
||||
|
20
readme.md
Normal file
20
readme.md
Normal file
@ -0,0 +1,20 @@
|
||||
GarfBot is a discord bot that uses openai generative pre-trained AI models to produce text and images for your personal entertainment and companionship.
|
||||
|
||||
To interact: (not case-sensitive)
|
||||
|
||||
`"hey garfield"`
|
||||
responds with text.
|
||||
|
||||
`"garfpic"`
|
||||
responds with image.
|
||||
|
||||
To get started, clone this repo and create a `config.py` file in GarfBot's root directory. Open your favorite text editor or IDE and add your various API tokens as such:
|
||||
|
||||
```python
|
||||
GARFBOT_TOKEN = "token"
|
||||
JONBOT_TOKEN = "token"
|
||||
MONEYBOT_TOKEN = "token"
|
||||
OPENAI_TOKEN = "token"
|
||||
GIF_TOKEN = "token"
|
||||
```
|
||||
If you want to configure a more secure setup go ahead, feel free to pipe any questions to my email address or /dev/null.
|
Loading…
Reference in New Issue
Block a user