BryanBradfo commited on
Commit
cb1513b
·
1 Parent(s): 7b56054

try with gemma3 27b it

Browse files
Files changed (2) hide show
  1. app.py +55 -0
  2. requirements.txt +1 -0
app.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from huggingface_hub import InferenceClient
3
+
4
+
5
+ client = InferenceClient("google/gemma-3-27b-it")
6
+
7
+
8
+ def answer(
9
+ message,
10
+ historical_information: list[tuple[str, str]],
11
+ system_message,
12
+ max_tokens,
13
+ temperature,
14
+ top_p,
15
+ ):
16
+ messages = [{"role": "system", "content": system_message}]
17
+ for comp in historical_information:
18
+ if comp[0]:
19
+ messages.append({"role": "user", "content": comp[0]})
20
+ if comp[1]:
21
+ messages.append({"role": "assistant", "content": comp[1]})
22
+ messages.append({"role": "user", "content": message})
23
+
24
+ response = ""
25
+ for message in client.chat_completion(
26
+ messages,
27
+ max_tokens=max_tokens,
28
+ stream=True,
29
+ temperature=temperature,
30
+ top_p=top_p,
31
+ ):
32
+ token = message.choices[0].delta.content
33
+ response += token
34
+ yield response
35
+
36
+
37
+ demo = gr.ChatInterface(
38
+ answer,
39
+ additional_inputs=[
40
+ gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
41
+ gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
42
+ gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
43
+ gr.Slider(
44
+ minimum=0.1,
45
+ maximum=1.0,
46
+ value=0.95,
47
+ step=0.05,
48
+ label="Top-p (nucleus sampling)",
49
+ ),
50
+ ],
51
+ )
52
+
53
+
54
+ if __name__ == "__main__":
55
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ huggingface_hub