Skip to content

Commit 872c3ec

Browse files
authored
docs: unify get weather function name in openai-harmony for consistency (#2048)
1 parent 594ec0e commit 872c3ec

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

articles/openai-harmony.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ convo = Conversation.from_messages(
9191
Message.from_role_and_content(Role.USER, "What is the weather in Tokyo?"),
9292
Message.from_role_and_content(
9393
Role.ASSISTANT,
94-
'User asks: "What is the weather in Tokyo?" We need to use get_weather tool.',
94+
'User asks: "What is the weather in Tokyo?" We need to use get_current_weather tool.',
9595
).with_channel("analysis"),
9696
Message.from_role_and_content(Role.ASSISTANT, '{"location": "Tokyo"}')
9797
.with_channel("commentary")
98-
.with_recipient("functions.get_weather")
98+
.with_recipient("functions.get_current_weather")
9999
.with_content_type("<|constrain|> json"),
100100
Message.from_author_and_content(
101-
Author.new(Role.TOOL, "functions.lookup_weather"),
101+
Author.new(Role.TOOL, "functions.get_current_weather"),
102102
'{ "temperature": 20, "sunny": true }',
103103
).with_channel("commentary"),
104104
]
@@ -376,7 +376,7 @@ If the model decides to call a tool it will define a `recipient` in the header o
376376
The model might also specify a `<|constrain|>` token to indicate the type of input for the tool call. In this case since it’s being passed in as JSON the `<|constrain|>` is set to `json`.
377377

378378
```
379-
<|channel|>analysis<|message|>Need to use function get_weather.<|end|><|start|>assistant<|channel|>commentary to=functions.get_weather <|constrain|>json<|message|>{"location":"San Francisco"}<|call|>
379+
<|channel|>analysis<|message|>Need to use function get_current_weather.<|end|><|start|>assistant<|channel|>commentary to=functions.get_current_weather <|constrain|>json<|message|>{"location":"San Francisco"}<|call|>
380380
```
381381

382382
#### Handling tool calls
@@ -392,7 +392,7 @@ A tool message has the following format:
392392
So in our example above
393393

394394
```
395-
<|start|>functions.get_weather to=assistant<|channel|>commentary<|message|>{"sunny": true, "temperature": 20}<|end|>
395+
<|start|>functions.get_current_weather to=assistant<|channel|>commentary<|message|>{"sunny": true, "temperature": 20}<|end|>
396396
```
397397

398398
Once you have gathered the output for the tool calls you can run inference with the complete content:
@@ -432,10 +432,10 @@ locations: string[],
432432
format?: "celsius" | "fahrenheit", // default: celsius
433433
}) => any;
434434
435-
} // namespace functions<|end|><|start|>user<|message|>What is the weather like in SF?<|end|><|start|>assistant<|channel|>analysis<|message|>Need to use function get_weather.<|end|><|start|>assistant<|channel|>commentary to=functions.get_weather <|constrain|>json<|message|>{"location":"San Francisco"}<|call|><|start|>functions.get_weather to=assistant<|channel|>commentary<|message|>{"sunny": true, "temperature": 20}<|end|><|start|>assistant
435+
} // namespace functions<|end|><|start|>user<|message|>What is the weather like in SF?<|end|><|start|>assistant<|channel|>analysis<|message|>Need to use function get_current_weather.<|end|><|start|>assistant<|channel|>commentary to=functions.get_current_weather <|constrain|>json<|message|>{"location":"San Francisco"}<|call|><|start|>functions.get_current_weather to=assistant<|channel|>commentary<|message|>{"sunny": true, "temperature": 20}<|end|><|start|>assistant
436436
```
437437

438-
As you can see above we are passing not just the function out back into the model for further sampling but also the previous chain-of-thought (“Need to use function get_weather.”) to provide the model with the necessary information to continue its chain-of-thought or provide the final answer.
438+
As you can see above we are passing not just the function out back into the model for further sampling but also the previous chain-of-thought (“Need to use function get_current_weather.”) to provide the model with the necessary information to continue its chain-of-thought or provide the final answer.
439439

440440
#### Preambles
441441

0 commit comments

Comments
 (0)