Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -53,6 +53,40 @@ async def uptime(ctx):
|
|
53 |
embed.set_footer(text="Created by Cosmos")
|
54 |
|
55 |
await ctx.send(embed=embed)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
@bot.command()
|
58 |
async def verse(ctx):
|
|
|
53 |
embed.set_footer(text="Created by Cosmos")
|
54 |
|
55 |
await ctx.send(embed=embed)
|
56 |
+
|
57 |
+
session_count = 0
|
58 |
+
|
59 |
+
@bot.command()
|
60 |
+
async def ai(ctx, *, input_text: str):
|
61 |
+
"""Ask our AI model a question. (Session resets every 10 messages!)"""
|
62 |
+
global session_count # Access the global variable
|
63 |
+
|
64 |
+
# Increment session count
|
65 |
+
session_count += 1
|
66 |
+
|
67 |
+
try:
|
68 |
+
# Check if it's time to start a new session
|
69 |
+
if session_count % 10 == 0:
|
70 |
+
# Start a new session by passing a unique session hash
|
71 |
+
client = get_client(session=str(datetime.datetime.now()))
|
72 |
+
else:
|
73 |
+
# Use the existing session
|
74 |
+
client = get_client()
|
75 |
+
|
76 |
+
# Make a request to the /chat endpoint
|
77 |
+
result = client.predict(
|
78 |
+
input_text,
|
79 |
+
0.9, # Temperature value between 0.0 and 1.0
|
80 |
+
2000, # Max new tokens value between 64 and 4096
|
81 |
+
0.9, # Top-p (nucleus sampling) value between 0.0 and 1.0
|
82 |
+
1.2, # Repetition penalty value between 1.0 and 2.0
|
83 |
+
api_name="/chat"
|
84 |
+
)
|
85 |
+
|
86 |
+
# Send the AI's response
|
87 |
+
await ctx.send(result)
|
88 |
+
except Exception as e:
|
89 |
+
await ctx.send(f"An error occurred: {str(e)}")
|
90 |
|
91 |
@bot.command()
|
92 |
async def verse(ctx):
|