-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Xue, Chendi <chendi.xue@intel.com>
- Loading branch information
Showing
13 changed files
with
350 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# with [tools.setuptools] in pyproject.toml, the configs below work in both baremetal and container | ||
include inference/**/*.yaml | ||
include inference/**/*.jinja |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 0 additions & 126 deletions
126
examples/inference/api_server_langchain/openai_bind_tools_with_langchain_sdk.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
llm_on_ray/inference/api_openai_backend/templates/tools_functions.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{%- set func_call_token = "!function_call:" -%} {#- The special prefix to functions calls, be aware of extra space or new lines ! -#} | ||
|
||
{%- if CONTEXT == CALL_TOKEN -%} {#- return only the func_call_token value. Needed by the implementation. No data included -#} | ||
{{- func_call_token -}} | ||
{%- endif -%} {#- CONTEXT == CALL_TOKEN -#} | ||
|
||
{%- if CONTEXT == CALLS_NOTIF -%} {#- Format the notification of the function call. Data: tool_calls = ToolCall -#} | ||
{%- for call in tool_calls -%} | ||
{%- if call.function.arguments == None or call.function.arguments|count == 0 -%} | ||
{{- call.id }} was called with no argument | ||
{%- else -%} | ||
{{- call.id }} was called with arguments : {{- call.function.arguments -}} | ||
{%- endif -%} | ||
{%- raw %} | ||
{% endraw -%} | ||
{%- endfor -%} | ||
{%- endif -%} {#- CONTEXT == CALLS_NOTIF -#} | ||
|
||
{%- if CONTEXT == TOOL_RESPONSE -%} {#- Format of the response of the function call. Data: message = ChatMessage -#} | ||
{{- message.content -}} | ||
{%- endif -%} {#- CONTEXT == TOOL_RESPONSE -#} | ||
|
||
{%- if CONTEXT == FORCE_CALL -%} {#- One tool call defined request. Data: tool = ToolCall -#} | ||
You must call the following function at least one time to answer the question. You may call it multiple times if needed: | ||
{%- if tool.function.parameters == None or tool.function.parameters|count == 0 -%} {#- without parameter #} | ||
{'name': "{{tool.function.name}}", 'description': "{{tool.function.description}}", 'arguments': null}, | ||
{%- else -%} {#- with parameters #} | ||
{'name': "{{tool.function.name}}", 'description': "{{tool.function.description}}", 'arguments': { {{tool.function.parameters}} {{ '}}' }}, | ||
{%- endif %} {#- tool.function.parameters #} | ||
{%- endif -%} {#- CONTEXT == FORCE_CALL -#} | ||
|
||
{%- if CONTEXT == FUNCTIONS_LIST -%} {#- Functions list generation Data: tools_list = List[ToolCall] -#} | ||
{%- raw -%}The following is a list of external functions that may be called to complete certain tasks: | ||
[ | ||
{%- endraw -%} | ||
{%- for tool in tools_list -%} | ||
{%- if tool.function.parameters == None or tool.function.parameters|count == 0 -%} {#- without parameter #} | ||
{'name': "{{tool.function.name}}", 'description': "{{tool.function.description}}", 'arguments': null}, | ||
{%- else -%} {#- with parameters #} | ||
{'name': "{{tool.function.name}}", 'description': "{{tool.function.description}}", 'arguments': { {{tool.function.parameters}} {{ '}}' }}, | ||
{% endif -%} {#- tool.function.parameters #} | ||
{%- endfor -%} | ||
{%- raw %} | ||
] | ||
End of list | ||
|
||
* Whenever the user asks you something, you can either respond directly or invoke a function if it is present in the previous list. | ||
* The decision to invoke a function is yours, only invoke a function if it is necessary to answer the user's question | ||
* If you need to call at least one function, your message should contain only a list of function calls and nothing else; the function calls are the response. | ||
{%- endraw %} | ||
{%- endif -%} {#- CONTEXT == FUNCTIONS_LIST -#} | ||
|
||
{%- if CONTEXT == FORCE_CALL or CONTEXT == FUNCTIONS_LIST -%} | ||
To call a function, the message must start by "{{func_call_token}}" followed by a json like this: | ||
* With arguments: | ||
{{func_call_token}}{"name": "function_name", "arguments": {"arg1": "value1"}} | ||
* Without arguments: | ||
{{func_call_token}}{"name": "function_name", "arguments": null} | ||
End of functions instructions | ||
{%- endif -%} {#- CONTEXT == FORCE_CALL or CONTEXT == FUNCTIONS_LIST -#} |
Oops, something went wrong.