huipeng6 commited on
Commit
14c9582
1 Parent(s): 49ab6fa

feat: 适配function-calling

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -4,7 +4,7 @@ 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(
@@ -21,7 +21,15 @@ def respond(
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
 
 
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("xalss/Qwen2-7B-Instruct-glaive-function-calling")
8
 
9
 
10
  def respond(
 
21
  if val[0]:
22
  messages.append({"role": "user", "content": val[0]})
23
  if val[1]:
24
+ assistant = val[1]
25
+ messages.append({
26
+ "role": (
27
+ "function"
28
+ if assistant.startswith("<FUNCTION RESPONSE>")
29
+ else "assistant"
30
+ ),
31
+ "content": assistant.lstrip("<FUNCTION RESPONSE>"),
32
+ })
33
 
34
  messages.append({"role": "user", "content": message})
35