vericudebuget commited on
Commit
7edfb69
·
verified ·
1 Parent(s): ec21d03

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -13,7 +13,6 @@ def format_prompt(message, history):
13
  return prompt
14
 
15
  def generate(prompt, history, system_prompt, theme, temperature=0.9, max_new_tokens=9048, top_p=0.95, repetition_penalty=1.0):
16
-
17
  temperature = max(float(temperature), 1e-2)
18
  top_p = float(top_p)
19
 
@@ -35,6 +34,16 @@ def generate(prompt, history, system_prompt, theme, temperature=0.9, max_new_tok
35
  yield output
36
  return output
37
 
 
 
 
 
 
 
 
 
 
 
38
  additional_inputs = [
39
  gr.Textbox(label="System Prompt", max_lines=1, interactive=True),
40
  gr.Slider(label="Temperature", value=0.9, minimum=0.0, maximum=1.0, step=0.05, interactive=True, info="Higher values produce more diverse outputs"),
@@ -44,15 +53,6 @@ additional_inputs = [
44
  gr.Dropdown(label="Theme", choices=["Default", "Base", "Glass", "Monochrome", "Soft"], interactive=True, info="Select a theme for the app")
45
  ]
46
 
47
-
48
- theme_mapping = {
49
- "Base": gr.themes.Base(),
50
- "Default": gr.themes.Default(),
51
- "Glass": gr.themes.Glass(),
52
- "Monochrome": gr.themes.Monochrome(),
53
- "Soft": gr.themes.Soft()
54
- }
55
-
56
  gr.ChatInterface(
57
  fn=generate,
58
  chatbot=gr.Chatbot(show_label=True, show_share_button=True, show_copy_button=True, likeable=True, layout="panel"),
@@ -60,5 +60,5 @@ gr.ChatInterface(
60
  title="ConvoLite",
61
  description="Remember! The AI might give incorrect information about people, locations, history, etc...",
62
  concurrency_limit=20,
63
- theme=theme_mapping[additional_inputs[-1].value] # Use the selected theme
64
  ).launch(show_api=False)
 
13
  return prompt
14
 
15
  def generate(prompt, history, system_prompt, theme, temperature=0.9, max_new_tokens=9048, top_p=0.95, repetition_penalty=1.0):
 
16
  temperature = max(float(temperature), 1e-2)
17
  top_p = float(top_p)
18
 
 
34
  yield output
35
  return output
36
 
37
+ def get_theme(theme_name):
38
+ theme_mapping = {
39
+ "Base": gr.themes.Base(),
40
+ "Default": gr.themes.Default(),
41
+ "Glass": gr.themes.Glass(),
42
+ "Monochrome": gr.themes.Monochrome(),
43
+ "Soft": gr.themes.Soft()
44
+ }
45
+ return theme_mapping.get(theme_name, gr.themes.Glass())
46
+
47
  additional_inputs = [
48
  gr.Textbox(label="System Prompt", max_lines=1, interactive=True),
49
  gr.Slider(label="Temperature", value=0.9, minimum=0.0, maximum=1.0, step=0.05, interactive=True, info="Higher values produce more diverse outputs"),
 
53
  gr.Dropdown(label="Theme", choices=["Default", "Base", "Glass", "Monochrome", "Soft"], interactive=True, info="Select a theme for the app")
54
  ]
55
 
 
 
 
 
 
 
 
 
 
56
  gr.ChatInterface(
57
  fn=generate,
58
  chatbot=gr.Chatbot(show_label=True, show_share_button=True, show_copy_button=True, likeable=True, layout="panel"),
 
60
  title="ConvoLite",
61
  description="Remember! The AI might give incorrect information about people, locations, history, etc...",
62
  concurrency_limit=20,
63
+ theme=get_theme(additional_inputs[-1].value) # Use the selected theme
64
  ).launch(show_api=False)