ruff format
All checks were successful
Garfbot CI/CD Deployment / Deploy (push) Successful in 15s

This commit is contained in:
2026-06-26 19:24:36 -05:00
parent 284e4f92fe
commit dbbfbd638f
6 changed files with 176 additions and 75 deletions

View File

@@ -46,10 +46,12 @@ client = commands.Bot(
intents=intents,
)
@client.event
async def on_ready():
print(f"Logged in as {client.user.name} running {txtmodel}.", flush=True)
@client.command(name="chat")
async def jonchat(ctx, *, prompt):
if "is this true" in prompt.lower():
@@ -62,6 +64,7 @@ async def jonchat(ctx, *, prompt):
)
await ctx.reply(answer)
@client.event
async def on_message(message):
if message.author == client.user:
@@ -69,9 +72,7 @@ async def on_message(message):
content = message.content.strip()
lower = content.lower()
if lower.startswith("hey jon") or isinstance(
message.channel, discord.DMChannel
):
if lower.startswith("hey jon") or isinstance(message.channel, discord.DMChannel):
ctx = await client.get_context(message)
await jonchat(ctx, prompt=content)
@@ -81,13 +82,14 @@ oai = AsyncOpenAI(
base_url=config.BASE_URL,
)
async def generate_chat(question: str) -> str:
try:
response = await oai.chat.completions.create(
model=txtmodel,
messages=[
{"role": "system", "content": sysprompt},
{"role": "user", "content": question},
{"role": "user", "content": question},
],
max_tokens=400,
temperature=1.2,
@@ -105,15 +107,15 @@ async def generate_chat(question: str) -> str:
return "`JonBot Error: Liz`"
async def jonbot_connect():
while True:
try:
await client.start(jonkey)
except Exception as e:
e = str(e)
logger.error(f"Jonbot couldn't connect! {e}")
await asyncio.sleep(60)
e = str(e)
logger.error(f"Jonbot couldn't connect! {e}")
await asyncio.sleep(60)
if __name__ == "__main__":
asyncio.run(jonbot_connect())