Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
yalu4 committed May 7, 2024
1 parent 2db0ec7 commit 78aba8d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions examples/flows/chat/use_tools_with_chat_models/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
This flow covers how to use the LLM tool chat API in combination with external functions to extend the
capabilities of GPT models.

`tools` is an optional parameter in the <a href='https://platform.openai.com/docs/api-reference/chat/create' target='_blank'>Chat Completion API</a> which can be used to provide function
`tools` is an optional parameter in the <a href='https://platform.openai.com/docs/api-reference/chat/create' target='_blank'>Chat Completion API</a> which can be used to provide tool
specifications. The purpose of this is to enable models to generate function arguments which adhere to the provided
specifications. Note that the API will not actually execute any function calls. It is up to developers to execute
function calls using model outputs.
specifications. Note that the API will not actually execute any tool calls. It is up to developers to execute
tool calls using model outputs.

If the `tools` parameter is provided then by default the model will decide when it is appropriate to use one of the
tools. The API can be forced to use a specific function by setting the `tool_choice` parameter to
`{"name": "<insert-function-name>"}`. The API can also be forced to not use any function by setting the `tool_choice`
parameter to `"none"`. If a function is used, the output will contain `"finish_reason": "tool_choice"` in the
response, as well as a `tool_choice` object that has the name of the function and the generated function arguments.
tools. The API can be forced to use a specific tool by setting the `tool_choice` parameter to
`{"type": "function", "function": {"name": "<insert-function-name>"}}`. The API can also be forced to not use any tool by setting the `tool_choice`
parameter to `"none"`. If a tool is used, the output will contain `"finish_reason": "tool_choice"` in the
response, as well as a `tool_choice` object that has the name of the tool and the generated function arguments.
You can refer to <a href='https://github.com/openai/openai-cookbook/blob/main/examples/How_to_call_functions_with_chat_models.ipynb' target='_blank'>openai sample</a> for more details.


## What you will learn

In this flow, you will learn how to use tools with LLM chat models and how to compose function role message in prompt template.
In this flow, you will learn how to use tools with LLM chat models and how to compose tool role message in prompt template.

## Tools used in this flow
- LLM tool
Expand Down Expand Up @@ -55,7 +55,7 @@ pf connection show --name open_ai_connection
pf flow test --flow .

# run chat flow with new question
pf flow test --flow . --inputs question="How about London next week?"
pf flow test --flow . --inputs question="What's the current weather like in San Francisco, Tokyo and Paris in Fahrenheit?"

# start a interactive chat session in CLI
pf flow test --flow . --interactive
Expand All @@ -67,5 +67,5 @@ pf flow test --flow . --interactive --verbose
## References
- <a href='https://github.com/openai/openai-cookbook/blob/main/examples/How_to_call_functions_with_chat_models.ipynb' target='_blank'>OpenAI cookbook example</a>
- <a href='https://openai.com/blog/function-calling-and-other-api-updates?ref=upstract.com' target='_blank'>OpenAI function calling announcement</a>
- <a href='https://platform.openai.com/docs/guides/gpt/function-calling' target='_blank'>OpenAI function calling doc</a>
- <a href='https://platform.openai.com/docs/api-reference/chat/create' target='_blank'>OpenAI function calling API</a>
- <a href='https://platform.openai.com/docs/guides/function-calling' target='_blank'>OpenAI function calling doc</a>
- <a href='https://platform.openai.com/docs/api-reference/chat/create' target='_blank'>OpenAI tools API</a>
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ nodes:
tool: promptflow.tools.llm.llm
path: use_tools_with_chat_models.jinja2
inputs:
connection: azure_open_ai_connection
connection: open_ai_connection
api: chat
deployment_name: gpt-35-turbo-1106
temperature: 0.7
Expand Down

0 comments on commit 78aba8d

Please sign in to comment.