Update app.py
Browse files
app.py
CHANGED
@@ -9,10 +9,12 @@ import gradio as gr
|
|
9 |
from discord import Permissions
|
10 |
from discord.ext import commands
|
11 |
from discord.utils import oauth_url
|
12 |
-
from discord.commands import Option # Import Option for slash commands
|
13 |
|
14 |
import gradio_client as grc
|
15 |
from gradio_client.utils import QueueError
|
|
|
|
|
|
|
16 |
|
17 |
event = Event()
|
18 |
|
@@ -24,7 +26,7 @@ async def wait(job):
|
|
24 |
|
25 |
## GRADIO UI API LINK ##
|
26 |
def get_client(session: Optional[str] = None) -> grc.Client:
|
27 |
-
client = grc.Client("https://cryptoscoutv1-discord-chatbot-
|
28 |
if session:
|
29 |
client.session_hash = session
|
30 |
return client
|
@@ -61,9 +63,16 @@ thread_to_client = {}
|
|
61 |
thread_to_user = {}
|
62 |
|
63 |
## /echo command to return the llm repsonse ##
|
|
|
|
|
|
|
64 |
|
65 |
-
@bot.
|
66 |
-
async def
|
|
|
|
|
|
|
|
|
67 |
if ctx.author.id == bot.user.id:
|
68 |
return
|
69 |
|
@@ -88,7 +97,16 @@ async def cryptotrend(ctx, period: Option(str, "Choose the period", choices=["da
|
|
88 |
except Exception as e:
|
89 |
print(f"{e}")
|
90 |
|
91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
@bot.hybrid_command(name="cshelp", description="Get information on how to use this bot.")
|
93 |
async def help_command(ctx):
|
94 |
help_message = """
|
|
|
9 |
from discord import Permissions
|
10 |
from discord.ext import commands
|
11 |
from discord.utils import oauth_url
|
|
|
12 |
|
13 |
import gradio_client as grc
|
14 |
from gradio_client.utils import QueueError
|
15 |
+
from discord.ext import commands
|
16 |
+
|
17 |
+
|
18 |
|
19 |
event = Event()
|
20 |
|
|
|
26 |
|
27 |
## GRADIO UI API LINK ##
|
28 |
def get_client(session: Optional[str] = None) -> grc.Client:
|
29 |
+
client = grc.Client("https://cryptoscoutv1-discord-chatbot-csv2.hf.space", hf_token=os.getenv("HF_TOKEN"))
|
30 |
if session:
|
31 |
client.session_hash = session
|
32 |
return client
|
|
|
63 |
thread_to_user = {}
|
64 |
|
65 |
## /echo command to return the llm repsonse ##
|
66 |
+
# Assuming get_client, wait, truncate_response, QueueError are defined elsewhere in your code
|
67 |
+
|
68 |
+
bot = commands.Bot(command_prefix="!", intents=discord.Intents.default())
|
69 |
|
70 |
+
@bot.event
|
71 |
+
async def on_ready():
|
72 |
+
print(f"We have logged in as {bot.user}")
|
73 |
+
|
74 |
+
@bot.slash_command(name="cryptosearch", description="Find top trending cryptocurrencies for a specific period.")
|
75 |
+
async def cryptosearch(ctx, period: str = commands.Param(choices=["day", "week", "month"])):
|
76 |
if ctx.author.id == bot.user.id:
|
77 |
return
|
78 |
|
|
|
97 |
except Exception as e:
|
98 |
print(f"{e}")
|
99 |
|
100 |
+
|
101 |
+
|
102 |
+
|
103 |
+
######################## COMMAND #################################
|
104 |
+
|
105 |
+
|
106 |
+
|
107 |
+
|
108 |
+
######### END ####################################
|
109 |
+
|
110 |
@bot.hybrid_command(name="cshelp", description="Get information on how to use this bot.")
|
111 |
async def help_command(ctx):
|
112 |
help_message = """
|