repd79 commited on
Commit
331e0eb
·
verified ·
1 Parent(s): 7b97010

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -16
app.py CHANGED
@@ -6,7 +6,6 @@ For more information on `huggingface_hub` Inference API support, please check th
6
  """
7
  client = InferenceClient("BSC-LT/ALIA-40b")
8
 
9
-
10
  def respond(
11
  message,
12
  history: list[tuple[str, str]],
@@ -15,31 +14,27 @@ def respond(
15
  temperature,
16
  top_p,
17
  ):
18
- messages = [{"role": "system", "content": system_message}]
19
-
20
- for val in history:
21
- if val[0]:
22
- messages.append({"role": "user", "content": val[0]})
23
- if val[1]:
24
- messages.append({"role": "assistant", "content": val[1]})
25
 
26
- messages.append({"role": "user", "content": message})
 
 
 
27
 
28
  response = ""
29
 
30
- for message in client.chat_completion(
31
- messages,
32
- max_tokens=max_tokens,
33
- stream=True,
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
  """
44
  For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
45
  """
 
6
  """
7
  client = InferenceClient("BSC-LT/ALIA-40b")
8
 
 
9
  def respond(
10
  message,
11
  history: list[tuple[str, str]],
 
14
  temperature,
15
  top_p,
16
  ):
17
+ prompt = f"{system_message}\n"
 
 
 
 
 
 
18
 
19
+ for user_input, bot_response in history:
20
+ prompt += f"User: {user_input}\nAssistant: {bot_response}\n"
21
+
22
+ prompt += f"User: {message}\nAssistant:"
23
 
24
  response = ""
25
 
26
+ for message in client.text_generation(
27
+ prompt=prompt,
28
+ max_new_tokens=max_tokens,
 
29
  temperature=temperature,
30
  top_p=top_p,
31
+ stream=True
32
  ):
33
+ response += message
 
 
34
  yield response
35
 
36
 
37
+
38
  """
39
  For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
40
  """