starnernj commited on
Commit
4b74937
·
verified ·
1 Parent(s): 9702672

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -66
app.py CHANGED
@@ -33,69 +33,4 @@ interface = gr.Interface(
33
  description="A chatbot using my fine-tuned LoRA adapter on LLaMA 3.1 8B, tuned on thousands of writings of the early Christian Church Fathers.",
34
  )
35
 
36
- interface.launch()
37
-
38
- """
39
-
40
- """
41
- For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
42
- """
43
- client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
44
-
45
-
46
- def respond(
47
- message,
48
- history: list[tuple[str, str]],
49
- system_message,
50
- max_tokens,
51
- temperature,
52
- top_p,
53
- ):
54
- messages = [{"role": "system", "content": system_message}]
55
-
56
- for val in history:
57
- if val[0]:
58
- messages.append({"role": "user", "content": val[0]})
59
- if val[1]:
60
- messages.append({"role": "assistant", "content": val[1]})
61
-
62
- messages.append({"role": "user", "content": message})
63
-
64
- response = ""
65
-
66
- for message in client.chat_completion(
67
- messages,
68
- max_tokens=max_tokens,
69
- stream=True,
70
- temperature=temperature,
71
- top_p=top_p,
72
- ):
73
- token = message.choices[0].delta.content
74
-
75
- response += token
76
- yield response
77
-
78
-
79
- """
80
- For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
81
- """
82
- demo = gr.ChatInterface(
83
- respond,
84
- additional_inputs=[
85
- gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
86
- gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
87
- gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
88
- gr.Slider(
89
- minimum=0.1,
90
- maximum=1.0,
91
- value=0.95,
92
- step=0.05,
93
- label="Top-p (nucleus sampling)",
94
- ),
95
- ],
96
- )
97
-
98
-
99
- if __name__ == "__main__":
100
- demo.launch()
101
- """
 
33
  description="A chatbot using my fine-tuned LoRA adapter on LLaMA 3.1 8B, tuned on thousands of writings of the early Christian Church Fathers.",
34
  )
35
 
36
+ interface.launch()