actuallyn commited on
Commit
3c69672
·
verified ·
1 Parent(s): eb87598

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -56
app.py CHANGED
@@ -1,62 +1,7 @@
1
  import gradio as gr
2
- import torch
3
- from huggingface_hub import InferenceClient
4
  from transformers import AutoModel
 
5
 
6
  model = AutoModel.from_pretrained("SchizoDev/Llama3-8b-CunnyGPT-16bit")
7
 
8
 
9
- def respond(
10
- message,
11
- history: list[tuple[str, str]],
12
- system_message,
13
- max_tokens,
14
- temperature,
15
- top_p,
16
- ):
17
- messages = [{"role": "system", "content": system_message}]
18
-
19
- for val in history:
20
- if val[0]:
21
- messages.append({"role": "user", "content": val[0]})
22
- if val[1]:
23
- messages.append({"role": "assistant", "content": val[1]})
24
-
25
- messages.append({"role": "user", "content": message})
26
-
27
- response = ""
28
-
29
- for message in client.chat_completion(
30
- messages,
31
- max_tokens=max_tokens,
32
- stream=True,
33
- temperature=temperature,
34
- top_p=top_p,
35
- ):
36
- token = message.choices[0].delta.content
37
-
38
- response += token
39
- yield response
40
-
41
- """
42
- For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
43
- """
44
- demo = gr.ChatInterface(
45
- respond,
46
- additional_inputs=[
47
- gr.Textbox(value="", label="System message"),
48
- gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
49
- gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
50
- gr.Slider(
51
- minimum=0.1,
52
- maximum=1.0,
53
- value=0.95,
54
- step=0.05,
55
- label="Top-p (nucleus sampling)",
56
- ),
57
- ],
58
- )
59
-
60
-
61
- if __name__ == "__main__":
62
- demo.launch()
 
1
  import gradio as gr
 
 
2
  from transformers import AutoModel
3
+ import torch
4
 
5
  model = AutoModel.from_pretrained("SchizoDev/Llama3-8b-CunnyGPT-16bit")
6
 
7