vericudebuget commited on
Commit
6498ae3
·
verified ·
1 Parent(s): 6e3edde

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -16
app.py CHANGED
@@ -1,13 +1,5 @@
1
- import gradio as gr
2
- from gradio.themes import GoogleFont
3
-
4
- # Define the theme with Montserrat font
5
- theme = gr.themes.Default(
6
- font=[GoogleFont("Montserrat"), "Arial", "sans-serif"],
7
- font_mono=[GoogleFont("Montserrat"), "Courier New", "monospace"]
8
- )
9
-
10
  from huggingface_hub import InferenceClient
 
11
  import datetime
12
 
13
  # Initialize the InferenceClient
@@ -33,17 +25,17 @@ def generate(prompt, history, system_prompt, temperature=0.9, max_new_tokens=904
33
  seed=42,
34
  )
35
 
36
- # Get current time
37
  now = datetime.datetime.now()
38
  formatted_time = now.strftime("%H:%M:%S, %B %d, %Y")
39
  system_prompt = f"System time: {formatted_time}"
40
 
41
  formatted_prompt = format_prompt(f"{system_prompt}, {prompt}", history)
42
  stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
 
43
  output = ""
44
  for response in stream:
45
  output += response.token.text
46
- yield output
47
 
48
  additional_inputs = [
49
  gr.Textbox(label="System Prompt", max_lines=1, interactive=True),
@@ -53,10 +45,10 @@ additional_inputs = [
53
  gr.Slider(label="Repetition penalty", value=1.2, minimum=1.0, maximum=2.0, step=0.05, interactive=True, info="Penalize repeated tokens")
54
  ]
55
 
56
- with gr.Blocks(theme=theme) as demo:
57
  gr.ChatInterface(
58
  fn=generate,
59
- chatbot=gr.Chatbot(show_label=True, show_share_button=False, show_copy_button=True, likeable=True, layout="panel", height="auto", autofocus="True"),
60
  additional_inputs=additional_inputs,
61
  title="ConvoLite",
62
  submit_btn="➢",
@@ -65,6 +57,4 @@ with gr.Blocks(theme=theme) as demo:
65
  clear_btn="Clear (New chat)",
66
  stop_btn="Stop ▢",
67
  concurrency_limit=20,
68
- )
69
-
70
- demo.launch(show_api=False)
 
 
 
 
 
 
 
 
 
 
1
  from huggingface_hub import InferenceClient
2
+ import gradio as gr
3
  import datetime
4
 
5
  # Initialize the InferenceClient
 
25
  seed=42,
26
  )
27
 
 
28
  now = datetime.datetime.now()
29
  formatted_time = now.strftime("%H:%M:%S, %B %d, %Y")
30
  system_prompt = f"System time: {formatted_time}"
31
 
32
  formatted_prompt = format_prompt(f"{system_prompt}, {prompt}", history)
33
  stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
34
+
35
  output = ""
36
  for response in stream:
37
  output += response.token.text
38
+ yield output
39
 
40
  additional_inputs = [
41
  gr.Textbox(label="System Prompt", max_lines=1, interactive=True),
 
45
  gr.Slider(label="Repetition penalty", value=1.2, minimum=1.0, maximum=2.0, step=0.05, interactive=True, info="Penalize repeated tokens")
46
  ]
47
 
48
+ with gr.Blocks(theme=gr.themes.Soft()) as demo:
49
  gr.ChatInterface(
50
  fn=generate,
51
+ chatbot=gr.Chatbot(show_label=True, show_share_button=False, show_copy_button=True, likeable=True, layout="panel", fill_height="True", autofocus="True"),
52
  additional_inputs=additional_inputs,
53
  title="ConvoLite",
54
  submit_btn="➢",
 
57
  clear_btn="Clear (New chat)",
58
  stop_btn="Stop ▢",
59
  concurrency_limit=20,
60
+ ).launch(show_api=False)