nacujapj7 commited on
Commit
777d688
1 Parent(s): 506ffe2

chore: update themes and result

Browse files
Files changed (1) hide show
  1. app.py +23 -32
app.py CHANGED
@@ -3,7 +3,7 @@ from typing import Iterable
3
  import gradio as Gradio
4
 
5
  from gradio.themes.utils import colors, fonts, sizes
6
- from gradio.themes.base import Base
7
 
8
  from llama_cpp import Llama
9
  from huggingface_hub import hf_hub_download
@@ -16,35 +16,7 @@ ins = '''<|im_start|>user
16
  <|im_start|>assistant
17
  '''
18
 
19
- theme = Gradio.themes.Monochrome(
20
- primary_hue="purple",
21
- secondary_hue="blue",
22
- neutral_hue="neutral",
23
- radius_size=Gradio.themes.sizes.radius_sm,
24
- font=[Gradio.themes.GoogleFont("Space Grotesk"), "ui-sans-serif", "system-ui", "sans-serif"],
25
- )
26
-
27
- def generate(instruction):
28
- prompt = ins.format(question=instruction)
29
- response = llm(prompt, stop=['<|im_start|>user', '<|im_end|>'])
30
- result = response['choices'][0]['text']
31
- return instruction
32
-
33
- examples = [
34
- "How do dogs bark?",
35
- "Why are apples red?",
36
- "How do I make a campfire?",
37
- "Why do cats love to chirp at something?"
38
- ]
39
-
40
- def process_example(args):
41
- for x in generate(args):
42
- pass
43
- return x
44
-
45
- css = ".generating {visibility: hidden}"
46
-
47
- class BlueTheme(Base):
48
  def __init__(
49
  self,
50
  *,
@@ -90,9 +62,28 @@ class BlueTheme(Base):
90
  input_shadow_focus="*shadow_drop_lg",
91
  )
92
 
93
-
94
  custom_theme = BlueTheme()
95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  with Gradio.Blocks(theme=custom_theme, analytics_enabled=False, css=css) as demo:
97
  with Gradio.Column():
98
  Gradio.Markdown(
@@ -102,7 +93,7 @@ with Gradio.Blocks(theme=custom_theme, analytics_enabled=False, css=css) as demo
102
 
103
  with Gradio.Tabs():
104
  with Gradio.Tab(label="Prompt"):
105
- usr_prompt = Gradio.components.Textbox(placeholder="Why do cats meow?", label="Prompt", info="What things do you want to ask CogniForge?");
106
 
107
  with Gradio.Tab(label="Configuration (disabled)"):
108
  top_p = Gradio.components.Slider(value=0.4, maximum=1, interactive=True, label="Top-P (Nucleus sampling)", info="Represents the token diversity threshold for CogniForge.");
 
3
  import gradio as Gradio
4
 
5
  from gradio.themes.utils import colors, fonts, sizes
6
+ from gradio.themes import Base
7
 
8
  from llama_cpp import Llama
9
  from huggingface_hub import hf_hub_download
 
16
  <|im_start|>assistant
17
  '''
18
 
19
+ class BlueTheme(Gradio.themes.Soft):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  def __init__(
21
  self,
22
  *,
 
62
  input_shadow_focus="*shadow_drop_lg",
63
  )
64
 
 
65
  custom_theme = BlueTheme()
66
 
67
+ def generate(instruction):
68
+ prompt = ins.format(question=instruction)
69
+ response = llm(prompt, stop=['<|im_start|>user', '<|im_end|>'])
70
+ result = response['choices'][0]['text']
71
+ return result
72
+
73
+ examples = [
74
+ "How do dogs bark?",
75
+ "Why are apples red?",
76
+ "How do I make a campfire?",
77
+ "Why do cats love to chirp at something?"
78
+ ]
79
+
80
+ def process_example(args):
81
+ for x in generate(args):
82
+ pass
83
+ return x
84
+
85
+ css = ".generating {visibility: hidden}"
86
+
87
  with Gradio.Blocks(theme=custom_theme, analytics_enabled=False, css=css) as demo:
88
  with Gradio.Column():
89
  Gradio.Markdown(
 
93
 
94
  with Gradio.Tabs():
95
  with Gradio.Tab(label="Prompt"):
96
+ usr_prompt = Gradio.components.Textbox(placeholder="Why do cats meow?", label="Prompt", info="What things do you want to ask the chat assistant?");
97
 
98
  with Gradio.Tab(label="Configuration (disabled)"):
99
  top_p = Gradio.components.Slider(value=0.4, maximum=1, interactive=True, label="Top-P (Nucleus sampling)", info="Represents the token diversity threshold for CogniForge.");