Synced repo using 'sync_with_huggingface' Github Action
Browse files
app.py
CHANGED
@@ -599,7 +599,7 @@ async def on_reaction_add(reaction, user): # ctx = await bot.get_context(reac
|
|
599 |
#----------------------------------------------------------------------------------------------------------------------------
|
600 |
chathistory = None
|
601 |
falcon_users = []
|
602 |
-
falcon_threads = []
|
603 |
falcon_dictionary = {}
|
604 |
falcon_userid_threadid_dictionary = {}
|
605 |
|
@@ -608,16 +608,21 @@ async def falcon(ctx, *, prompt: str):
|
|
608 |
# todo: need to be careful with these, rework into something simpler
|
609 |
try:
|
610 |
global falcon_users
|
611 |
-
global falcon_threads
|
612 |
global falcon_dictionary
|
613 |
global falcon_userid_threadid_dictionary
|
|
|
|
|
|
|
|
|
614 |
if not ctx.author.bot:
|
615 |
if ctx.channel.id == 1116089829147557999: # initial thread creation inside #falcon
|
616 |
-
if ctx.author.id not in falcon_users: #
|
|
|
617 |
await ctx.message.add_reaction('<a:loading:1114111677990981692>')
|
618 |
thread = await ctx.message.create_thread(name=f'{ctx.author}')
|
619 |
-
falcon_users = [ctx.author.id] + falcon_users
|
620 |
-
falcon_threads = [thread.id] + falcon_threads
|
621 |
await thread.send(f"Thread created")
|
622 |
|
623 |
# initial generation here
|
@@ -635,20 +640,22 @@ async def falcon(ctx, *, prompt: str):
|
|
635 |
with open(full_generation, 'r') as file:
|
636 |
data = json.load(file)
|
637 |
output_text = data[-1][-1] # we output this as the bot
|
|
|
638 |
falcon_dictionary[ctx.author.id] = full_generation # 1234567890: tmp12345678.json
|
639 |
falcon_userid_threadid_dictionary[ctx.author.id] = thread.id
|
|
|
640 |
print(output_text)
|
641 |
await thread.send(f"{output_text}")
|
642 |
await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
|
643 |
-
elif ctx.author.id in falcon_users:
|
644 |
-
|
|
|
645 |
#------------------------------------
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
if ctx.channel.id == thread_id_test:
|
652 |
chathistory = falcon_dictionary[ctx.author.id]
|
653 |
|
654 |
instructions = "The following is a conversation between a highly knowledgeable and intelligent AI assistant, called Falcon, and a human user, called User. In the following interactions, User and Falcon will converse in natural language, and Falcon will answer User's questions. Falcon was built to be respectful, polite and inclusive. Falcon was built by the Technology Innovation Institute in Abu Dhabi. Falcon will never decline to answer a question, and always attempts to give an answer that User would be satisfied with. It knows a lot, and always tells the truth. The conversation begins."
|
@@ -673,6 +680,19 @@ async def falcon(ctx, *, prompt: str):
|
|
673 |
await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
|
674 |
await ctx.message.add_reaction('<:disagree:1098628957521313892>')
|
675 |
#----------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
676 |
'''
|
677 |
@bot.event
|
678 |
async def on_message(message):
|
|
|
599 |
#----------------------------------------------------------------------------------------------------------------------------
|
600 |
chathistory = None
|
601 |
falcon_users = []
|
602 |
+
#falcon_threads = []
|
603 |
falcon_dictionary = {}
|
604 |
falcon_userid_threadid_dictionary = {}
|
605 |
|
|
|
608 |
# todo: need to be careful with these, rework into something simpler
|
609 |
try:
|
610 |
global falcon_users
|
611 |
+
#global falcon_threads # deprecated
|
612 |
global falcon_dictionary
|
613 |
global falcon_userid_threadid_dictionary
|
614 |
+
|
615 |
+
# dict[generation, authorid]
|
616 |
+
# dict[threadid, authorid]
|
617 |
+
|
618 |
if not ctx.author.bot:
|
619 |
if ctx.channel.id == 1116089829147557999: # initial thread creation inside #falcon
|
620 |
+
#if ctx.author.id not in falcon_users: # deprecated
|
621 |
+
if ctx.author.id not in falcon_userid_threadid_dictionary:
|
622 |
await ctx.message.add_reaction('<a:loading:1114111677990981692>')
|
623 |
thread = await ctx.message.create_thread(name=f'{ctx.author}')
|
624 |
+
#falcon_users = [ctx.author.id] + falcon_users # deprecated
|
625 |
+
#falcon_threads = [thread.id] + falcon_threads # deprecated
|
626 |
await thread.send(f"Thread created")
|
627 |
|
628 |
# initial generation here
|
|
|
640 |
with open(full_generation, 'r') as file:
|
641 |
data = json.load(file)
|
642 |
output_text = data[-1][-1] # we output this as the bot
|
643 |
+
|
644 |
falcon_dictionary[ctx.author.id] = full_generation # 1234567890: tmp12345678.json
|
645 |
falcon_userid_threadid_dictionary[ctx.author.id] = thread.id
|
646 |
+
|
647 |
print(output_text)
|
648 |
await thread.send(f"{output_text}")
|
649 |
await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
|
650 |
+
#elif ctx.author.id in falcon_users: # deprecated
|
651 |
+
elif ctx.author.id in falcon_userid_threadid_dictionary:
|
652 |
+
await ctx.reply(f"{ctx.author.mention}, you already have an existing conversation! Use !falconclear in the #falcon channel to start a new one.")
|
653 |
#------------------------------------
|
654 |
+
# post all other generations here
|
655 |
+
#if ctx.channel.id in falcon_threads: # deprecated
|
656 |
+
if ctx.channel.id in falcon_userid_threadid_dictionary:
|
657 |
+
if ctx.channel.id == falcon_userid_threadid_dictionary[ctx.author.id]:
|
658 |
+
await ctx.message.add_reaction('<a:loading:1114111677990981692>')
|
|
|
659 |
chathistory = falcon_dictionary[ctx.author.id]
|
660 |
|
661 |
instructions = "The following is a conversation between a highly knowledgeable and intelligent AI assistant, called Falcon, and a human user, called User. In the following interactions, User and Falcon will converse in natural language, and Falcon will answer User's questions. Falcon was built to be respectful, polite and inclusive. Falcon was built by the Technology Innovation Institute in Abu Dhabi. Falcon will never decline to answer a question, and always attempts to give an answer that User would be satisfied with. It knows a lot, and always tells the truth. The conversation begins."
|
|
|
680 |
await ctx.message.remove_reaction('<a:loading:1114111677990981692>', bot.user)
|
681 |
await ctx.message.add_reaction('<:disagree:1098628957521313892>')
|
682 |
#----------------------------------------------------------------------------------------------------------------------------
|
683 |
+
@bot.command
|
684 |
+
async def falconclear(ctx):
|
685 |
+
if not ctx.author.bot:
|
686 |
+
if ctx.channel.id == 1116089829147557999:
|
687 |
+
if ctx.author.id in falcon_userid_threadid_dictionary:
|
688 |
+
if ctx.author.id in falcon_dictionary:
|
689 |
+
del falcon_userid_threadid_dictionary[ctx.author.id]
|
690 |
+
del falcon_dictionary[ctx.author.id]
|
691 |
+
await ctx.reply(f"{ctx.author.mention}'s conversation has been cleared. Feel free to start a new one!")
|
692 |
+
#----------------------------------------------------------------------------------------------------------------------------
|
693 |
+
|
694 |
+
|
695 |
+
|
696 |
'''
|
697 |
@bot.event
|
698 |
async def on_message(message):
|