Update README.md
Browse files
README.md
CHANGED
|
@@ -69,13 +69,10 @@ This formatting is also available via our vLLM server which we process the funct
|
|
| 69 |
from openai import OpenAI
|
| 70 |
|
| 71 |
client = OpenAI(base_url="http://localhost:8000/v1", api_key="functionary")
|
| 72 |
-
|
| 73 |
-
client.chat.completions.create(
|
| 74 |
-
model="path/to/functionary/model/",
|
| 75 |
-
messages=[{"role": "user",
|
| 76 |
"content": "What is the weather for Istanbul?"}
|
| 77 |
-
]
|
| 78 |
-
|
| 79 |
"type": "function",
|
| 80 |
"function": {
|
| 81 |
"name": "get_current_weather",
|
|
@@ -91,7 +88,15 @@ client.chat.completions.create(
|
|
| 91 |
"required": ["location"]
|
| 92 |
}
|
| 93 |
}
|
| 94 |
-
}]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
tool_choice="auto"
|
| 96 |
)
|
| 97 |
```
|
|
@@ -101,7 +106,8 @@ will yield:
|
|
| 101 |
```
|
| 102 |
<|start_header_id|>system<|end_header_id|>
|
| 103 |
|
| 104 |
-
|
|
|
|
| 105 |
|
| 106 |
Cutting Knowledge Date: December 2023
|
| 107 |
|
|
@@ -109,7 +115,7 @@ Cutting Knowledge Date: December 2023
|
|
| 109 |
You have access to the following functions:
|
| 110 |
|
| 111 |
Use the function 'get_current_weather' to 'Get the current weather'
|
| 112 |
-
{"name": "get_current_weather", "description": "Get the current weather", "parameters": {"type": "object", "properties": {"location": {"type": "string", "description": "The city and state, e.g. San Francisco, CA"}},"required": ["location"]}}
|
| 113 |
|
| 114 |
|
| 115 |
Think very carefully before calling functions.
|
|
@@ -136,7 +142,6 @@ Reminder:
|
|
| 136 |
What is the weather for Istanbul?
|
| 137 |
```
|
| 138 |
|
| 139 |
-
A more detailed example is provided [here](https://github.com/MeetKai/functionary/blob/main/tests/prompt_test_v3-llama3.1.txt).
|
| 140 |
|
| 141 |
## Run the model
|
| 142 |
|
|
|
|
| 69 |
from openai import OpenAI
|
| 70 |
|
| 71 |
client = OpenAI(base_url="http://localhost:8000/v1", api_key="functionary")
|
| 72 |
+
messages = [{"role": "user",
|
|
|
|
|
|
|
|
|
|
| 73 |
"content": "What is the weather for Istanbul?"}
|
| 74 |
+
]
|
| 75 |
+
tools = [{
|
| 76 |
"type": "function",
|
| 77 |
"function": {
|
| 78 |
"name": "get_current_weather",
|
|
|
|
| 88 |
"required": ["location"]
|
| 89 |
}
|
| 90 |
}
|
| 91 |
+
}]
|
| 92 |
+
|
| 93 |
+
# to let the model generate the reasoning first, then the tool uses add type reasoning; without reasoning tool, the model will not output the reasoning
|
| 94 |
+
tools.append({"type": "reasoning"})
|
| 95 |
+
|
| 96 |
+
client.chat.completions.create(
|
| 97 |
+
model="path/to/functionary/model/",
|
| 98 |
+
messages=messages,
|
| 99 |
+
tools=tools,
|
| 100 |
tool_choice="auto"
|
| 101 |
)
|
| 102 |
```
|
|
|
|
| 106 |
```
|
| 107 |
<|start_header_id|>system<|end_header_id|>
|
| 108 |
|
| 109 |
+
Reasoning Mode: On
|
| 110 |
+
|
| 111 |
|
| 112 |
Cutting Knowledge Date: December 2023
|
| 113 |
|
|
|
|
| 115 |
You have access to the following functions:
|
| 116 |
|
| 117 |
Use the function 'get_current_weather' to 'Get the current weather'
|
| 118 |
+
{"name": "get_current_weather", "description": "Get the current weather", "parameters": {"type": "object", "properties": {"location": {"type": "string", "description": "The city and state, e.g. San Francisco, CA"}}, "required": ["location"]}}
|
| 119 |
|
| 120 |
|
| 121 |
Think very carefully before calling functions.
|
|
|
|
| 142 |
What is the weather for Istanbul?
|
| 143 |
```
|
| 144 |
|
|
|
|
| 145 |
|
| 146 |
## Run the model
|
| 147 |
|