Spaces:
Paused
Paused
robinroy03
commited on
Commit
•
81b3bc3
1
Parent(s):
c74400e
[bug fix] app.py
Browse files
app.py
CHANGED
@@ -115,103 +115,17 @@ async def on_message(message):
|
|
115 |
print(e)
|
116 |
await message.reply("An error occurred. Retry again.")
|
117 |
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
# @bot.event
|
147 |
-
# async def on_message(message):
|
148 |
-
# url_llm = 'https://robinroy03-fury-bot.hf.space'
|
149 |
-
# url_embedding = 'https://robinroy03-fury-embeddings-endpoint.hf.space'
|
150 |
-
# url_db = 'https://robinroy03-fury-db-endpoint.hf.space'
|
151 |
-
|
152 |
-
# PROMPT = """
|
153 |
-
# You are a senior developer. Answer the users question based on the context provided.
|
154 |
-
|
155 |
-
# Question: {question}
|
156 |
-
|
157 |
-
# Context: {context}
|
158 |
-
# """
|
159 |
-
|
160 |
-
# user_question = message.content.replace("<@1243428204124045385>", "")
|
161 |
-
|
162 |
-
# user_question_embedding = requests.post(url_embedding + "/embedding", json={"text": user_question})
|
163 |
-
# user_question_embedding = json.loads(user_question_embedding.text)['output']
|
164 |
-
# print(user_question_embedding)
|
165 |
-
|
166 |
-
# user_question_retrived_db_context = requests.post(url_db + "/query", json={"embeddings": user_question_embedding})
|
167 |
-
# user_question_retrived_db_context = json.loads(user_question_retrived_db_context.text)['matches'][0]['metadata']['text']
|
168 |
-
# print(user_question_retrived_db_context)
|
169 |
-
|
170 |
-
# PROMPT = PROMPT.format(question=user_question, context=user_question_retrived_db_context)
|
171 |
-
# print(PROMPT)
|
172 |
-
|
173 |
-
# obj = {
|
174 |
-
# # 'user': message.author.id,
|
175 |
-
# 'model': 'phi3',
|
176 |
-
# 'prompt': PROMPT,
|
177 |
-
# 'stream': False
|
178 |
-
# }
|
179 |
-
|
180 |
-
# if (message.author != bot.user) and (bot.user.mentioned_in(message)):
|
181 |
-
# await message.reply(content="Your message was received, it'll take around 10 seconds for FURY to process an answer.")
|
182 |
-
|
183 |
-
# try:
|
184 |
-
# return_obj = requests.post(url_llm + "/api/generate", json=obj)
|
185 |
-
# return_json = json.loads(return_obj.text)
|
186 |
-
# await message.reply(content=return_json['response'] + "\n\n" + user_question_retrived_db_context, view=Like_Dislike())
|
187 |
-
# except requests.exceptions.RequestException as e:
|
188 |
-
# print(e)
|
189 |
-
# await message.reply(content="Sorry something internally went wrong. Retry again.")
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
bot.run(token)
|
203 |
-
|
204 |
-
# def run_bot():
|
205 |
-
# bot.run(token)
|
206 |
-
# threading.Thread(target=run_bot).start()
|
207 |
|
208 |
|
209 |
# ------------------------------------------------------------------------------------------------------------------------------
|
210 |
|
211 |
-
|
212 |
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
|
217 |
-
|
|
|
115 |
print(e)
|
116 |
await message.reply("An error occurred. Retry again.")
|
117 |
|
118 |
+
def run_bot():
|
119 |
+
bot.run(token)
|
120 |
+
threading.Thread(target=run_bot).start()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
|
122 |
|
123 |
# ------------------------------------------------------------------------------------------------------------------------------
|
124 |
|
125 |
+
import gradio as gr
|
126 |
|
127 |
+
demo = gr.Blocks()
|
128 |
+
with demo:
|
129 |
+
gr.HTML("The bot is working..")
|
130 |
|
131 |
+
demo.queue().launch()
|