drewvid commited on
Commit
3927e32
·
1 Parent(s): e0f99a6

first commit

Browse files
Files changed (2) hide show
  1. Makefile +8 -0
  2. app.py +16 -8
Makefile ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+
2
+ all:
3
+
4
+ update:
5
+ git add . --all
6
+ git commit -a
7
+ git push
8
+
app.py CHANGED
@@ -4,17 +4,23 @@ from huggingface_hub import InferenceClient
4
  """
5
  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
6
  """
7
- client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
 
8
 
9
 
10
  def respond(
11
  message,
12
  history: list[tuple[str, str]],
13
- system_message,
14
  max_tokens,
15
  temperature,
16
  top_p,
17
  ):
 
 
 
 
 
 
18
  messages = [{"role": "system", "content": system_message}]
19
 
20
  for val in history:
@@ -34,10 +40,13 @@ def respond(
34
  temperature=temperature,
35
  top_p=top_p,
36
  ):
37
- token = message.choices[0].delta.content
38
-
39
- response += token
40
- yield response
 
 
 
41
 
42
  """
43
  For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
@@ -45,8 +54,7 @@ For information on how to customize the ChatInterface, peruse the gradio docs: h
45
  demo = gr.ChatInterface(
46
  respond,
47
  additional_inputs=[
48
- gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
49
- gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
50
  gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
51
  gr.Slider(
52
  minimum=0.1,
 
4
  """
5
  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
6
  """
7
+ # client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
8
+ client = InferenceClient("meta-llama/Meta-Llama-3-8B-Instruct")
9
 
10
 
11
  def respond(
12
  message,
13
  history: list[tuple[str, str]],
 
14
  max_tokens,
15
  temperature,
16
  top_p,
17
  ):
18
+
19
+ name = "Ernest"
20
+
21
+ system_message = f"""Assume the role of a versatile and creative author called {name}, capable of writing engaging and informative content on any topic or subject the user requests. Generate high-quality, well-researched, and well-organized writing that is free of errors and biases. Write in a clear, concise, and engaging style, using vivid imagery, compelling narratives, and persuasive arguments to captivate the reader's attention. Adapt to the user's tone, style, and genre preferences, and incorporate feedback to refine and polish the writing.
22
+ """
23
+
24
  messages = [{"role": "system", "content": system_message}]
25
 
26
  for val in history:
 
40
  temperature=temperature,
41
  top_p=top_p,
42
  ):
43
+ if message.choices:
44
+ token = message.choices[0].delta.content
45
+ if token:
46
+ response += token
47
+ yield response
48
+ else:
49
+ yield "Please clear the history and try again."
50
 
51
  """
52
  For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
 
54
  demo = gr.ChatInterface(
55
  respond,
56
  additional_inputs=[
57
+ gr.Slider(minimum=1, maximum=4096, value=2048, step=1, label="Max new tokens"),
 
58
  gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
59
  gr.Slider(
60
  minimum=0.1,