Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OCI Generative AI tool calling support #16888

Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
5ddb034
added tool calling support for oci genai
LejianLeoHe7 Sep 4, 2024
644b0b8
updated conver_to_oci_tool function
LejianLeoHe7 Sep 4, 2024
bbc9742
updated the message_to_oci_params func
LejianLeoHe7 Sep 4, 2024
3906d63
updated chat function with tool calling
LejianLeoHe7 Sep 4, 2024
1a41118
test oci tool calling
LejianLeoHe7 Oct 17, 2024
0f0f2dd
delete test files
LejianLeoHe7 Oct 17, 2024
c31935c
update models names and format
YouNeedCryDear Oct 17, 2024
222881b
Merge branch 'main' into leohe/oci-tool-calling-support-with-test
LejianLeoHe7 Oct 25, 2024
358aec7
updated local branch with other commits
LejianLeoHe7 Oct 25, 2024
943120d
updated chat function with tool calling
LejianLeoHe7 Sep 4, 2024
7527383
updated tests and bug fixes
LejianLeoHe7 Nov 4, 2024
5307b25
updated llamaindex example
LejianLeoHe7 Nov 5, 2024
388c29f
updated the llama-index exmaple notebook
LejianLeoHe7 Nov 8, 2024
6e3b496
added tool calling support for oci genai
LejianLeoHe7 Sep 4, 2024
3e30dc0
updated conver_to_oci_tool function
LejianLeoHe7 Sep 4, 2024
cd416c0
updated the message_to_oci_params func
LejianLeoHe7 Sep 4, 2024
26a8ee7
updated chat function with tool calling
LejianLeoHe7 Sep 4, 2024
20b2578
test oci tool calling
LejianLeoHe7 Oct 17, 2024
b8f2320
delete test files
LejianLeoHe7 Oct 17, 2024
6d493c8
update models names and format
YouNeedCryDear Oct 17, 2024
1880500
updated local branch with other commits
LejianLeoHe7 Oct 25, 2024
485d3a0
updated chat function with tool calling
LejianLeoHe7 Sep 4, 2024
7b9b4d1
updated tests and bug fixes
LejianLeoHe7 Nov 4, 2024
5140cdf
updated llamaindex example
LejianLeoHe7 Nov 5, 2024
4c49158
updated the llama-index exmaple notebook
LejianLeoHe7 Nov 8, 2024
aebdc30
add deprecation and lint
YouNeedCryDear Nov 8, 2024
48666fd
fix test case
YouNeedCryDear Nov 8, 2024
61530f2
add basic tool calling for example
YouNeedCryDear Nov 8, 2024
a164e8e
format and fix test case remove notebook
YouNeedCryDear Nov 8, 2024
93e74e2
fix tool calling repetition bug
YouNeedCryDear Nov 8, 2024
4e3758c
add additional model and improve error message
YouNeedCryDear Nov 8, 2024
ebb1681
bump up oci and integration version
YouNeedCryDear Nov 8, 2024
016c4ff
remove colab hyperlink
YouNeedCryDear Nov 9, 2024
98370b8
update oci base to enable chat tool calling directly
LejianLeoHe7 Nov 19, 2024
ddcc060
rebase current branch and resolve comments on chat/stream_chat
LejianLeoHe7 Nov 20, 2024
30a8e96
Merge branch 'main' into leohe/oci-tool-calling-support-with-test
LejianLeoHe7 Nov 20, 2024
19001af
add additional models
YouNeedCryDear Nov 20, 2024
fe388ef
format and lint
YouNeedCryDear Nov 20, 2024
8ccea97
fix test case
YouNeedCryDear Nov 20, 2024
80424f7
add force single tool call
YouNeedCryDear Nov 20, 2024
5c51d57
additional tool call func and force completion to chat
YouNeedCryDear Nov 20, 2024
fae3ef4
Merge branch 'main' into leohe/oci-tool-calling-support-with-test
YouNeedCryDear Nov 21, 2024
c4093d3
Merge branch 'main' into leohe/oci-tool-calling-support-with-test
YouNeedCryDear Dec 17, 2024
dadbdfd
Merge branch 'main' into leohe/oci-tool-calling-support-with-test
logan-markewich Dec 19, 2024
fd5df72
vbump
logan-markewich Dec 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 50 additions & 9 deletions docs/docs/examples/llm/oci_genai.ipynb
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"id": "6d1ca9ac",
"metadata": {},
"source": [
"<a href=\"https://colab.research.google.com/github/run-llama/llama_index/blob/main/docs/docs/examples/llm/bedrock.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"id": "9e3a8796-edc8-43f2-94ad-fe4fb20d70ed",
Expand Down Expand Up @@ -360,6 +351,56 @@
"resp = llm.chat(messages)\n",
"print(resp)"
]
},
{
"cell_type": "markdown",
"id": "acd73b3d",
"metadata": {},
"source": [
"## Basic tool calling in llamaindex \n",
"\n",
"Only Cohere supports tool calling for now"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5546c661",
"metadata": {},
"outputs": [],
"source": [
"from llama_index.llms.oci_genai import OCIGenAI\n",
"from llama_index.core.tools import FunctionTool\n",
"\n",
"llm = OCIGenAI(\n",
" model=\"MY_MODEL\",\n",
" service_endpoint=\"https://inference.generativeai.us-chicago-1.oci.oraclecloud.com\",\n",
" compartment_id=\"MY_OCID\",\n",
")\n",
"\n",
"\n",
"def multiply(a: int, b: int) -> int:\n",
" \"\"\"Multiple two integers and returns the result integer\"\"\"\n",
" return a * b\n",
"\n",
"\n",
"def add(a: int, b: int) -> int:\n",
" \"\"\"Addition function on two integers.\"\"\"\n",
" return a + b\n",
"\n",
"\n",
"add_tool = FunctionTool.from_defaults(fn=add)\n",
"multiply_tool = FunctionTool.from_defaults(fn=multiply)\n",
"\n",
"response = llm.chat_with_tools(\n",
" tools=[add_tool, multiply_tool],\n",
" user_msg=\"What is 3 * 12? Also, what is 11 + 49?\",\n",
")\n",
"\n",
"print(response)\n",
"tool_calls = response.message.additional_kwargs.get(\"tool_calls\", [])\n",
"print(tool_calls)"
]
}
],
"metadata": {
Expand Down
Loading
Loading