idan shenfeld commited on
Commit
d2680fa
·
1 Parent(s): 590f42f

change dependencies

Browse files
Files changed (1) hide show
  1. app/app.py +4 -22
app/app.py CHANGED
@@ -15,7 +15,7 @@ from feedback import save_feedback, scheduler
15
  from gradio.components.chatbot import Option
16
  from huggingface_hub import InferenceClient
17
  from pandas import DataFrame
18
- from transformers import pipeline, AutoTokenizer, CohereForCausalLM
19
 
20
 
21
  BASE_MODEL = os.getenv("MODEL", "CohereForAI/aya-expanse-8b")
@@ -46,7 +46,7 @@ def create_inference_client(
46
  """
47
  if ZERO_GPU:
48
  tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL)
49
- model = CohereForCausalLM.from_pretrained(BASE_MODEL, load_in_8bit=True)
50
  return {
51
  "pipeline": pipeline(
52
  "text-generation",
@@ -116,23 +116,9 @@ def load_languages() -> dict[str, str]:
116
  with open(languages_path, "r", encoding="utf-8") as f:
117
  return json.load(f)
118
 
119
- def update_language_clients():
120
- """Update the global LANGUAGES and LANGUAGES_TO_CLIENT dictionaries"""
121
- global LANGUAGES, LANGUAGES_TO_CLIENT
122
- LANGUAGES = load_languages()
123
- # Create new clients for any new languages
124
- for lang in LANGUAGES.keys():
125
- if lang not in LANGUAGES_TO_CLIENT:
126
- LANGUAGES_TO_CLIENT[lang] = create_inference_client()
127
- # Remove clients for languages that no longer exist
128
- for lang in list(LANGUAGES_TO_CLIENT.keys()):
129
- if lang not in LANGUAGES:
130
- del LANGUAGES_TO_CLIENT[lang]
131
 
132
  # Initial load
133
- LANGUAGES = {}
134
- LANGUAGES_TO_CLIENT = {}
135
- update_language_clients()
136
 
137
  # User agreement text
138
  USER_AGREEMENT = """
@@ -564,9 +550,6 @@ def save_new_language(lang_name, system_prompt):
564
  except Exception as e:
565
  print(f"Error updating local backup: {e}")
566
 
567
- # Update the in-memory language dictionaries
568
- update_language_clients()
569
-
570
  # Update the dropdown choices
571
  new_choices = list(LANGUAGES.keys())
572
 
@@ -619,7 +602,7 @@ with gr.Blocks(css=css) as demo:
619
  gr.Markdown("# Welcome to FeeL")
620
  with gr.Group(elem_classes=["user-agreement-container"]):
621
  gr.Markdown(USER_AGREEMENT)
622
- consent_btn = gr.Button("Next")
623
 
624
  # Main application interface (initially hidden)
625
  with gr.Group(visible=False) as main_app:
@@ -765,7 +748,6 @@ with gr.Blocks(css=css) as demo:
765
  )
766
 
767
  def on_app_load():
768
- update_language_clients()
769
  return str(uuid.uuid4())
770
 
771
  demo.load(
 
15
  from gradio.components.chatbot import Option
16
  from huggingface_hub import InferenceClient
17
  from pandas import DataFrame
18
+ from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM
19
 
20
 
21
  BASE_MODEL = os.getenv("MODEL", "CohereForAI/aya-expanse-8b")
 
46
  """
47
  if ZERO_GPU:
48
  tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL)
49
+ model = AutoModelForCausalLM.from_pretrained(BASE_MODEL, load_in_8bit=True)
50
  return {
51
  "pipeline": pipeline(
52
  "text-generation",
 
116
  with open(languages_path, "r", encoding="utf-8") as f:
117
  return json.load(f)
118
 
 
 
 
 
 
 
 
 
 
 
 
 
119
 
120
  # Initial load
121
+ LANGUAGES = load_languages()
 
 
122
 
123
  # User agreement text
124
  USER_AGREEMENT = """
 
550
  except Exception as e:
551
  print(f"Error updating local backup: {e}")
552
 
 
 
 
553
  # Update the dropdown choices
554
  new_choices = list(LANGUAGES.keys())
555
 
 
602
  gr.Markdown("# Welcome to FeeL")
603
  with gr.Group(elem_classes=["user-agreement-container"]):
604
  gr.Markdown(USER_AGREEMENT)
605
+ consent_btn = gr.Button("I agree")
606
 
607
  # Main application interface (initially hidden)
608
  with gr.Group(visible=False) as main_app:
 
748
  )
749
 
750
  def on_app_load():
 
751
  return str(uuid.uuid4())
752
 
753
  demo.load(