hiieu commited on
Commit
49589d0
·
verified ·
1 Parent(s): 405bcc8

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +26 -4
README.md CHANGED
@@ -29,11 +29,33 @@ model = AutoModelForCausalLM.from_pretrained(
29
  use_cache=True,
30
  )
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  conversation = [
33
- {"role": "system", "content": """Bạn là một trợ lý hữu ích có quyền truy cập vào các chức năng sau. Sử dụng chúng nếu cần -\n[ {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"get_temperature\",\n \"description\": \"get temperature of a city\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"city\": {\n \"type\": \"string\",\n \"description\": \"name\"\n }\n },\n \"required\": [\n \"city\"\n ]\n }\n }\n} ] Để sử dụng các chức năng này, hãy phản hồi với:\n<functioncall> {"name": "function_name", "arguments": {"arg_1": "value_1", "arg_1": "value_1", ...}} </functioncall>\n\nTrường hợp đặc biệt bạn phải xử lý:\n - Nếu không có chức năng nào khớp với yêu cầu của người dùng, bạn sẽ phản hồi một cách lịch sự rằng bạn không thể giúp được.""" },
34
- { "role": "user", "content": "Thời tiết ở Sài Gòn đang là bao nhiêu độ"},
35
- { "role": "assistant", "content": """<functioncall> {"name": "get_temperature", "arguments": \'{"city": "Sai Gon"}\'} </functioncall>"""},
36
- { "role": "user", "content": """<function_response> {"temperature" : 20 C} </function_response>"""},
37
  ]
38
 
39
  input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt").to(model.device)
 
29
  use_cache=True,
30
  )
31
 
32
+ functions_metadata = [
33
+ {
34
+ "type": "function",
35
+ "function": {
36
+ "name": "get_temperature",
37
+ "description": "get temperature of a city",
38
+ "parameters": {
39
+ "type": "object",
40
+ "properties": {
41
+ "city": {
42
+ "type": "string",
43
+ "description": "name"
44
+ }
45
+ },
46
+ "required": [
47
+ "city"
48
+ ]
49
+ }
50
+ }
51
+ }
52
+ ]
53
+
54
  conversation = [
55
+ {"role": "system", "content": f"""Bạn là một trợ lý hữu ích có quyền truy cập vào các chức năng sau. Sử dụng chúng nếu cần -\n{str(functions_metadata)} Để sử dụng các chức năng này, hãy phản hồi với:\n<functioncall> {{\\"name\\": \\"function_name\\", \\"arguments\\": {{\\"arg_1\\": \\"value_1\\", \\"arg_1\\": \\"value_1\\", ...}} }} </functioncall>\n\nTrường hợp đặc biệt bạn phải xử lý:\n - Nếu không có chức năng nào khớp với yêu cầu của người dùng, bạn sẽ phản hồi một cách lịch sự rằng bạn không thể giúp được.""" },
56
+ {"role": "user", "content": "Thời tiết ở Sài Gòn đang là bao nhiêu độ"},
57
+ {"role": "assistant", "content": """<functioncall> {"name": "get_temperature", "arguments": {"city": "Sai Gon"}} </functioncall>"""},
58
+ {"role": "user", "content": """<function_response> {"temperature" : "20 C"} </function_response>"""},
59
  ]
60
 
61
  input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt").to(model.device)