Spaces:
Running
Running
Commit
·
798686c
1
Parent(s):
0fed689
multichat
Browse files- app.py +21 -8
- requirements.txt +5 -6
app.py
CHANGED
@@ -6,11 +6,13 @@ import gradio as gr
|
|
6 |
import pandas as pd
|
7 |
from datetime import datetime, timedelta, timezone
|
8 |
#import torch
|
9 |
-
from config import
|
|
|
|
|
10 |
#import replicate
|
11 |
import gspread
|
12 |
from groq import Client
|
13 |
-
|
14 |
|
15 |
# Initialize Google Sheets client
|
16 |
client = init_google_sheets_client()
|
@@ -21,9 +23,19 @@ system_prompts_sheet = sheet.worksheet("System Prompts")
|
|
21 |
# Combine both model dictionaries
|
22 |
all_models = {**groq_model}
|
23 |
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
|
|
|
|
|
|
|
|
|
|
|
27 |
# Load stories from Google Sheets
|
28 |
def load_stories():
|
29 |
stories_data = stories_sheet.get_all_values()
|
@@ -291,7 +303,12 @@ with gr.Blocks() as demo:
|
|
291 |
#aqui armar una ventana x cada modelo seleccionado
|
292 |
chatbot_main_output = gr.Chatbot(label="Chat History", type='messages')
|
293 |
with gr.Row():
|
294 |
-
for model in model_list:
|
|
|
|
|
|
|
|
|
|
|
295 |
aux = gr.Chatbot(label=f"Model {model}", visible=True, type='messages')
|
296 |
chatbot_resp.append(aux)
|
297 |
user_input = gr.Textbox(placeholder="Type your message here...", label="User Input")
|
@@ -317,10 +334,6 @@ with gr.Blocks() as demo:
|
|
317 |
#send_message_button.click(fn=interact, inputs=[chatbot_input, chat_history_json, interaction_count, model_dropdown], outputs=[chatbot_input, chatbot_output, chat_history_json, interaction_count])
|
318 |
#save_button.click(fn=save_comment_score, inputs=[chatbot_output, score_input, comment_input, story_dropdown, user_dropdown, system_prompt_dropdown], outputs=[data_table, comment_input])
|
319 |
|
320 |
-
#multiple story functions
|
321 |
-
#chat_bot_multiple_1 = gr.JSON(value=[], visible=False)
|
322 |
-
#chat_bot_multiple_2 = gr.JSON(value=[], visible=False)
|
323 |
-
#model_checkbox = gr.JSON(value=[], visible=False)
|
324 |
chat_radio.change(fn=change_textbox, inputs=chat_radio, outputs=assistant_user_input)
|
325 |
|
326 |
send_multiple_story_button.click(
|
|
|
6 |
import pandas as pd
|
7 |
from datetime import datetime, timedelta, timezone
|
8 |
#import torch
|
9 |
+
from config import groq_token, groq_model, QUESTION_PROMPT, init_google_sheets_client, huggingface_tokenizer, replicate_model,groq_model, default_model_name, user_names, google_sheets_name, MAX_INTERACTIONS
|
10 |
+
|
11 |
+
#from config import hugging_face_token, replicate_token
|
12 |
#import replicate
|
13 |
import gspread
|
14 |
from groq import Client
|
15 |
+
import random, string
|
16 |
|
17 |
# Initialize Google Sheets client
|
18 |
client = init_google_sheets_client()
|
|
|
23 |
# Combine both model dictionaries
|
24 |
all_models = {**groq_model}
|
25 |
|
26 |
+
def randomize_key_order(aux):
|
27 |
+
keys = list(aux.keys())
|
28 |
+
#Shuffle the list of keys
|
29 |
+
random.shuffle(keys)
|
30 |
+
#Create a new dictionary with shuffled keys
|
31 |
+
return {key: aux[key] for key in keys}
|
32 |
|
33 |
|
34 |
+
alphabet = list(string.ascii_uppercase)
|
35 |
+
|
36 |
+
# Initialize GROQ client
|
37 |
+
groq_clinet = Client(api_key=groq_token)
|
38 |
+
|
39 |
# Load stories from Google Sheets
|
40 |
def load_stories():
|
41 |
stories_data = stories_sheet.get_all_values()
|
|
|
303 |
#aqui armar una ventana x cada modelo seleccionado
|
304 |
chatbot_main_output = gr.Chatbot(label="Chat History", type='messages')
|
305 |
with gr.Row():
|
306 |
+
#for i, model in enumerate(model_list):
|
307 |
+
# label = f"Model {alphabet[i % len(alphabet)]}"
|
308 |
+
# aux = gr.Chatbot(label=label, visible=True, type='messages')
|
309 |
+
# chatbot_resp.append(aux)
|
310 |
+
|
311 |
+
for model in randomize_key_order(model_list):
|
312 |
aux = gr.Chatbot(label=f"Model {model}", visible=True, type='messages')
|
313 |
chatbot_resp.append(aux)
|
314 |
user_input = gr.Textbox(placeholder="Type your message here...", label="User Input")
|
|
|
334 |
#send_message_button.click(fn=interact, inputs=[chatbot_input, chat_history_json, interaction_count, model_dropdown], outputs=[chatbot_input, chatbot_output, chat_history_json, interaction_count])
|
335 |
#save_button.click(fn=save_comment_score, inputs=[chatbot_output, score_input, comment_input, story_dropdown, user_dropdown, system_prompt_dropdown], outputs=[data_table, comment_input])
|
336 |
|
|
|
|
|
|
|
|
|
337 |
chat_radio.change(fn=change_textbox, inputs=chat_radio, outputs=assistant_user_input)
|
338 |
|
339 |
send_multiple_story_button.click(
|
requirements.txt
CHANGED
@@ -1,12 +1,11 @@
|
|
1 |
huggingface_hub==0.25.1
|
2 |
minijinja
|
3 |
-
transformers
|
4 |
-
torch
|
5 |
pandas
|
6 |
gspread
|
7 |
oauth2client
|
8 |
-
accelerate
|
9 |
-
bitsandbytes
|
10 |
replicate
|
11 |
-
groq
|
12 |
-
gradio>=5.0.0
|
|
|
1 |
huggingface_hub==0.25.1
|
2 |
minijinja
|
3 |
+
#transformers
|
4 |
+
#torch
|
5 |
pandas
|
6 |
gspread
|
7 |
oauth2client
|
8 |
+
#accelerate
|
9 |
+
#bitsandbytes
|
10 |
replicate
|
11 |
+
groq
|
|