Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
48 changes: 27 additions & 21 deletions generative-ai-agent-adk/adk-installation/adk_install.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,53 @@

## Introduction

This lab will take you through the steps needed to install ADK using python installer .We recommend to use *OCI DATA Science* based notebook to run the operation as it comes with all the necessary software in place,however we have added an optional steps to follow local machine for ADK client setup.
This lab will take you through the steps needed to install ADK using the Python installer. We recommend using an OCI Data Science-based notebook to run the operation, as it comes with all the necessary software in place. However, we have added optional steps to follow on a local machine for the ADK client setup.

Estimated Time: 30 minutes



## Task 1: Setup OCI Data Science notebook for **ADK** usage.

1. From OCI Console > *AI & Analytics* > *Data science*
1. From OCI Console > AI & Analytics > Data Science

![Data science view](images/datascience_view.png)
1. Select *Create project*.Provide name and description.

2. Select Create project. Provide a name and description.

![Data science project](images/create_ds_project.png)

1. With in the project,click *Create notebook session*.
3. Within the project, click Create notebook session.

![Create notebook](images/create_nb.png)

1. Provide a name and retain all the other default settings and click *Create*.
4. Provide a name, retain all the other default settings, and click Create.

![Create notebook completed](images/create_nb_final.png)

1. Wait for the resource to become active.
5. Wait for the resource to become active.

![Active notebook](images/nb_active.png)

1. Open the notebook detail page and click *Open*.
6. Open the notebook detail page and click Open.

![NB details](images/nb_detail_page.png)

1. Provide credentials and multi factor auth when prompted.Wait for the notebook to be opened.
7. Provide credentials and multi-factor authentication when prompted. Wait for the notebook to open.

![NB Opened](images/nb_open_view.png)

1. Click *extend* and extend the notebook timeout.
8. Click Extend and extend the notebook timeout.


**You can skip the next section and follow to Task 3**
**You can skip the next section and proceed to Task 3**


## Task 2: (Optional) Setup a local machine for **ADK** usage.

1. Python ADK requires Python 3.10 or later. Ensure you have the correct version of Python installed in your environment.
1. Follow below and installed *OCI* with *ADK*

2. Follow the steps below and install OCI with ADK:

```
<copy>
Expand All @@ -57,49 +60,52 @@ Estimated Time: 30 minutes
source <myenv>/bin/activate
</copy>
```
1. After you create a project and a virtual environment, install the latest version of ADK:

3. After you create a project and a virtual environment, install the latest version of ADK:

```
<copy>
pip install "oci[adk]"
pip install oci-cli
</copy>
```
1. Create an *API Signing Key* and store for further usage. Refer [here](https://docs.oracle.com/en-us/iaas/Content/API/Concepts/apisigningkey.htm#two) for detailed steps.
4. Create an *API Signing Key* and store for it further usage. Refer [here](https://docs.oracle.com/en-us/iaas/Content/API/Concepts/apisigningkey.htm#two) for detailed steps.

## Task 3: Validate ADK installation using OCI Data science.

1. Follow below steps if you are using a data science notebook.If not move to Task 4.
1. Follow the steps below if you are using a Data Science notebook. If not, move to Task 4

* Click File > New >Notebook.
* Click File > New >Notebook.

![New Notebook](images/new_notbook.png)

1. Right click on Untitled notebook and rename the same.
2. Right-click on the untitled notebook and rename it.

![Rename the NB](images/rename_nb.png)

1. Run below and validate it returns the correct name reference.
3. Run the following and validate that it returns the correct name reference.

```
<copy>
from oci.addons import adk
adk.__name__
</copy>
```
![ADK Validation](images/adk_validate.png)

## Task 3: Validate ADK installation for local setup.
<!-- ![ADK Validation](images/adk_validate.png) -->

## Task 4: Validate ADK installation for local setup

1. Follow below steps for local machine
1. Follow the steps below for a local machine:

```
<copy>
from oci.addons import adk
adk.__name__
</copy>
```
1. Validate the name reference.

2. Validate the name reference.

**Proceed to the next lab.**

Expand Down
41 changes: 22 additions & 19 deletions generative-ai-agent-adk/agent-config/agentconfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

## Introduction

This lab will take details the steps to configure Agent using the tools that created.It will also provide the steps to add additional client side tools such as Custom tools using function as well as integration with *Model Context Protocol- MCP*.
This lab details the steps to configure an Agent using the tools that were created. It also provides steps to add additional client-side tools, such as custom tools using functions, as well as integration with Model Context Protocol - MCP.

## Task 1: Import ADK modules.
The tasks imports various ADK python modules as well as some of the optional libraries for our usage.All these instructions works for python script as well as OCI Data science notebooks.
This task imports various ADK Python modules as well as some optional libraries for our usage. All these instructions work for Python scripts as well as OCI Data Science notebooks.

1. Add below to the notebook cell.

Expand All @@ -23,7 +23,8 @@ The tasks imports various ADK python modules as well as some of the optional lib
from mcp.client.session_group import StreamableHttpParameters
</copy>
```
1. Add below snippet for enabling async run for notbook.

2. Add the below snippet to enable async run for the notebook.

```
<copy>
Expand All @@ -33,20 +34,22 @@ The tasks imports various ADK python modules as well as some of the optional lib
```

![](images/module_import.png)
1. For notebook,you may use the *Play* button and run these commands.For python script ,you may use your editor or run using *python scrip.py* format.

3. For notebooks, you may use the Play button and run these commands. For Python scripts, you may use your editor or run using the python script.py format.


## Task 2: Define variables.

1. Define variables for agent endpoint and RAG knowledge based IDs.
1. Define variables for the agent endpoint and RAG knowledge base IDs.

```
<copy>
agent_endpoint="endpoint OCID"
knowledge_id="knowledgeBase OCID"
</copy>
```
1. Define instructions for agents.

2. Define instructions for agents.

```
<copy>
Expand All @@ -63,7 +66,7 @@ The tasks imports various ADK python modules as well as some of the optional lib

## Task 3: Define a custom tool based on function.

1. Use below code to set a simple custom function based tool,which will return the season based on a location.
1. Use the below code to set a simple custom function-based tool, which will return the season based on a location.

```
<copy>
Expand Down Expand Up @@ -92,13 +95,13 @@ The tasks imports various ADK python modules as well as some of the optional lib

![Custom function](images/custom_function.png)

## Task 4: Define mcp call using stdIO mode.
## Task 4: Define MCP call using stdIO mode.

* We are using an open source mcp library to fetch information from public internet.
* We are using an open-source MCP library to fetch information from the public internet.
* The library details and credit goes to https://github.com/openbnb-org/mcp-server-airbnb.
* If you are using local client execution ,ensure nodejs and npx is available for run.
* If you are using local client execution, ensure Node.js and npx are available to run.

1. Copy the below to notebook or local script to define the MCP.
1. Copy the below to a notebook or local script to define the MCP.

```
<copy>
Expand All @@ -114,9 +117,9 @@ The tasks imports various ADK python modules as well as some of the optional lib
![MCP Definition](images/mcp.png)


## Task 5: Connect Knowledge base to the RAG too.
## Task 5: Connect Knowledge Base to the RAG tool.

1. Connect knowledge base id and RAG tool with the agent.To do so copy below snippet and pase to the notebook or python script.
1. Connect the knowledge base ID and RAG tool with the agent. To do so, copy the below snippet and paste it into the notebook or Python script.

```
<copy>
Expand All @@ -133,7 +136,7 @@ The tasks imports various ADK python modules as well as some of the optional lib

## Task 6: Define an agent and connect with the tools.

1. Use below snippet to define an agent along with the tools.You need to update the placeholders accordingly.
1. Use the below snippet to define an agent along with the tools. You need to update the placeholders accordingly.

```
<copy>
Expand Down Expand Up @@ -167,11 +170,11 @@ The tasks imports various ADK python modules as well as some of the optional lib



## Task 7: Initialize and setup the agent.
During the process the ADK will check the tools defined and associate with the Agent.
The process may take several minutes depends on the tools and their configuration.
## Task 7: Initialize and set up the agent.
During the process, the ADK will check the tools defined and associate them with the Agent.
The process may take several minutes depending on the tools and their configuration.

1. Run below to setup and run a sample query.A setup process is only needed for the first time or for any configuration changes that needs to push from local or notebook to agents.You may update your query as well.
1. Run the below to set up and run a sample query. The setup process is only needed for the first time or for any configuration changes that need to be pushed from the local environment or notebook to agents. You may update your query as well.

```
<copy>
Expand All @@ -183,7 +186,7 @@ The process may take several minutes depends on the tools and their configuratio
![Tool sync](images/tool_sync.png)


1. Wait for the execution to complete and validate the result.A result would look like as below.
2. Wait for the execution to complete and validate the result. A result would look like the one below.

![Result](images/mcp_results.png)

Expand Down
28 changes: 16 additions & 12 deletions generative-ai-agent-adk/agent-run/agentrun.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

## Introduction

This lab will take provide various run modes with the *Agent* we have configured.
This lab will provide various run modes with the Agent we have configured.


## Task 1: Run a query using RAG tool.

1. Run below query to fetch answers from OCI Agent RAG tool based on the knowledge base attached.
1. Run the query below to fetch answers from the OCI Agent RAG tool based on the attached knowledge base.

```
<copy>
Expand All @@ -15,14 +16,14 @@ This lab will take provide various run modes with the *Agent* we have configured
response.pretty_print()
</copy>
```
* The agent will run and share the information based on the RAG too.

The agent will run and share the information based on the RAG tool.

![Rag run](images/rag-run.png)

## Task 2: Validate SQL tool execution.

1. Run below query to fetch information via agent ,which will fetch and report the information from OCI Autonomous Data Base.
1. Run the query below to fetch information via the agent, which will retrieve and report the data from the Autonomous AI Database.

```
<copy>
Expand All @@ -31,13 +32,13 @@ This lab will take provide various run modes with the *Agent* we have configured
response.pretty_print()
</copy>
```
* Here the query about secondary category will translate to product subcategory based on the column description that we defined during SQL Tool setup.
* Here, the query about the secondary category will be translated to the product subcategory based on the column description defined during SQL tool setup.

![SQL Run](images/sql-run.png)

## Task 3: Validate function exeuction.
## Task 3: Validate function execution.

1. Run below to understand how agent reacts based on the function tool we defined.
1. Run the command below to see how the agent reacts based on the function tool we defined.

```
<copy>
Expand All @@ -49,8 +50,10 @@ This lab will take provide various run modes with the *Agent* we have configured
![Custom tool run](images/custom_tool_run.png)

## Task 4 : Sample agent run using OCI SDK.
Here we are using OCI python SDK to run the agent endpoint and fetch results.
1. Use below snippet to fetch results using OCI SDK.You may comment/uncomment the Auth section/Region and endpoint details accordingly.

Here we are using the OCI Python SDK to run the agent endpoint and fetch results.

1. Use the snippet below to fetch results using the OCI SDK. You may comment/uncomment the Auth section, region, and endpoint details accordingly.

```
<copy>
Expand Down Expand Up @@ -114,13 +117,14 @@ Here we are using OCI python SDK to run the agent endpoint and fetch results.
```
![SDK Run](images/sdk-run.png)

1. A sample execution result will be as follows.Its for demo purpose only and the same can be achieved using ADK .As you may refer the SDK goes at a lower API level while ADK remains at the upper layer.
2. A sample execution result will be as follows. It is for demo purposes only, and the same can be achieved using ADK. As you may observe, the SDK operates at a lower API level, while ADK remains at a higher abstraction layer.

![SDK run output](images/sdk-output.png)


## Task 5 : Additional samples.
* You may refer [here](https://docs.oracle.com/en-us/iaas/Content/generative-ai-agents/adk/api-reference/examples.htm) for additional samples and can run against the setup.
## Task 5 : Additional samples

* You may refer [here](https://docs.oracle.com/en-us/iaas/Content/generative-ai-agents/adk/api-reference/examples.htm) for additional samples and run them against your setup.


**Proceed to the next lab.**
Expand Down
Loading