Skip to content

Commit c4fb312

Browse files
authored
Merge branch 'main' into dependabot/pip/ai/gen-ai-agents/travel_agent/protobuf-6.31.1
2 parents 9f52147 + d87a906 commit c4fb312

File tree

49 files changed

+1200
-206
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1200
-206
lines changed

ai/README.md

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,28 @@
11
# AI Services
22

3-
Oracle Cloud Infrastructure (OCI) AI Services and Generative AI Services are a collection of services with prebuilt machine learning and Generative AI models that make it easier for developers to apply AI to applications and business operations. The models can be custom-trained (or fine-tuned) for more accurate business results. Teams within an organization can reuse the models, datasets, and data labels across services. OCI AI Services makes it possible for developers to easily add machine learning to apps without slowing down application development.
3+
Oracle Cloud Infrastructure (OCI) AI Services, Generative AI Services and Generative AI Agents are a collection of services with prebuilt machine learning and Generative AI models that make it easy for developers to apply AI to applications and business processes. The models can be custom-trained (or fine-tuned) for more accurate business results. Teams within an organization can reuse the models, datasets, and data labels across services. OCI AI makes it possible for developers to easily add AI to applications without slowing down application development.
44

5-
Reviewed: 17.10.2024
5+
Reviewed: 03.06.2025
66

7-
# Team Publications
8-
- [Cloud Coaching - Low Code embraces Oracle Cloud Infrastructure AI services](https://www.youtube.com/watch?v=0oHixpA9JDc)
9-
- Learn how to create applications that read, modify, and classify documents with a couple of clicks using our low code development platform and some of the OCI AI services offering.
10-
11-
# Table of Contents
12-
13-
- [AI Services](#ai-services)
14-
- [Team Publications](#team-publications)
15-
- [Table of Contents](#table-of-contents)
16-
- [Useful Links](#useful-links)
17-
- [Reusable Assets](#reusable-assets)
18-
- [License](#license)
197

208
# Useful Links
219

10+
## Examples and hands-on workshops
2211
- [AI Solutions Hub](https://www.oracle.com/artificial-intelligence/solutions/)
12+
- [Oracle LiveLabs](https://apexapps.oracle.com/pls/apex/r/dbpm/livelabs/home)
13+
14+
## Discover Oracle AI
2315
- [Oracle AI Services on Oracle.com](https://www.oracle.com/artificial-intelligence/ai-services/)
2416
- [Oracle Generative AI on Oracle.com](https://www.oracle.com/artificial-intelligence/generative-ai/generative-ai-service/)
17+
- [Oracle AI Strategy and Platform webinar](https://go.oracle.com/LP=138234?elqCampaignId=489428&src1=:so:ch:or:dg::::&SC=:so:ch:or:dg::::&pcode=WWMK230822P00010)
2518
- [Oracle’s Generative AI strategy](https://blogs.oracle.com/ai-and-datascience/post/generative-ai-strategy)
26-
- [OCI AI Foundations Certification](https://mylearn.oracle.com/ou/learning-path/become-an-oci-ai-foundations-associate-2024/140164)
27-
- [OCI Generative AI Professional](https://mylearn.oracle.com/ou/learning-path/become-an-oci-generative-ai-professional/136227)
2819
- [AI use cases - 10 examples](https://www.oracle.com/a/ocom/docs/gated/ai-use-cases-ebook.pdf)
2920
- [Availability of AI Services across OCI datacenters](https://www.oracle.com/uk/cloud/public-cloud-regions/service-availability/#commercial)
30-
- [Oracle LiveLabs](https://apexapps.oracle.com/pls/apex/r/dbpm/livelabs/home)
3121

32-
# Reusable Assets
33-
- [Smarter Applications with AI Services](https://go.oracle.com/LP=138234?elqCampaignId=489428&src1=:so:ch:or:dg::::&SC=:so:ch:or:dg::::&pcode=WWMK230822P00010)
34-
- [Oracle AI Strategy and Platform webinar](https://go.oracle.com/LP=138234?elqCampaignId=489428&src1=:so:ch:or:dg::::&SC=:so:ch:or:dg::::&pcode=WWMK230822P00010)
22+
## Learning paths and certifications
23+
- [OCI AI Foundations Certification](https://mylearn.oracle.com/ou/learning-path/become-an-oci-ai-foundations-associate-2024/140164)
24+
- [OCI Generative AI Professional](https://mylearn.oracle.com/ou/learning-path/become-an-oci-generative-ai-professional/136227)
25+
- [Become a Digital Assistant developer](https://mylearn.oracle.com/ou/learning-path/become-a-digital-assistant-developer-2025/147740)
3526

3627
# License
3728

ai/gen-ai-agents/custom_rag_agent/config.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,24 @@
3131

3232
# embeddings
3333
EMBED_MODEL_ID = "cohere.embed-multilingual-v3.0"
34+
# EMBED_MODEL_ID = "cohere.embed-multilingual-image-v3.0"
3435

3536
# LLM
3637
# this is the default model
3738
LLM_MODEL_ID = "meta.llama-3.3-70b-instruct"
3839
TEMPERATURE = 0.1
39-
MAX_TOKENS = 1024
40+
MAX_TOKENS = 2048
4041

4142
# for the UI
4243
LANGUAGE_LIST = ["same as the question", "en", "fr", "it", "es"]
43-
MODEL_LIST = ["meta.llama-3.3-70b-instruct", "cohere.command-r-plus-08-2024"]
44+
# replaced command-r with command-a
45+
MODEL_LIST = ["meta.llama-3.3-70b-instruct", "cohere.command-a-03-2025"]
4446

4547
ENABLE_USER_FEEDBACK = True
4648

4749
# semantic search
4850
TOP_K = 6
49-
COLLECTION_LIST = ["BOOKS", "CNAF"]
51+
COLLECTION_LIST = ["DEV_COACHING", "BOOKS", "CNAF"]
5052

5153
# OCI general
5254
COMPARTMENT_ID = "ocid1.compartment.oc1..aaaaaaaaushuwb2evpuf7rcpl4r7ugmqoe7ekmaiik3ra3m7gec3d234eknq"
@@ -69,3 +71,8 @@
6971
# for loading
7072
CHUNK_SIZE = 2000
7173
CHUNK_OVERLAP = 100
74+
75+
# for MCP server
76+
TRANSPORT = "streamable-http"
77+
HOST = "0.0.0.0"
78+
PORT = 9000
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
"""
2+
Semantic Search exposed as an MCP tool
3+
4+
Author: L. Saetta
5+
License: MIT
6+
"""
7+
8+
from typing import Annotated
9+
from pydantic import Field
10+
import oracledb
11+
from fastmcp import FastMCP
12+
from langchain_community.vectorstores.utils import DistanceStrategy
13+
from langchain_community.embeddings import OCIGenAIEmbeddings
14+
from langchain_community.vectorstores.oraclevs import OracleVS
15+
from utils import get_console_logger
16+
17+
from config import DEBUG
18+
from config import AUTH, EMBED_MODEL_ID, SERVICE_ENDPOINT, COMPARTMENT_ID
19+
from config import TRANSPORT, HOST, PORT
20+
from config_private import CONNECT_ARGS
21+
22+
logger = get_console_logger()
23+
24+
mcp = FastMCP("Demo Semantic Search as MCP server")
25+
26+
27+
#
28+
# Helper functions
29+
#
30+
def get_connection():
31+
"""
32+
get a connection to the DB
33+
"""
34+
return oracledb.connect(**CONNECT_ARGS)
35+
36+
37+
def get_embedding_model():
38+
"""
39+
Create the Embedding Model
40+
"""
41+
embed_model = OCIGenAIEmbeddings(
42+
auth_type=AUTH,
43+
model_id=EMBED_MODEL_ID,
44+
service_endpoint=SERVICE_ENDPOINT,
45+
compartment_id=COMPARTMENT_ID,
46+
)
47+
return embed_model
48+
49+
50+
@mcp.tool
51+
def semantic_search(
52+
query: Annotated[
53+
str, Field(description="The search query to find relevant documents.")
54+
],
55+
top_k: Annotated[int, Field(description="TOP_K parameter for search")] = 5,
56+
collection_name: Annotated[
57+
str, Field(description="The name of DB table")
58+
] = "BOOKS",
59+
) -> dict:
60+
"""
61+
Perform a semantic search based on the provided query.
62+
Args:
63+
query (str): The search query.
64+
top_k (int): The number of top results to return.
65+
Returns:
66+
dict: a dictionary containing the relevant documents.
67+
"""
68+
try:
69+
# must be the same embedding model used during load in the Vector Store
70+
embed_model = get_embedding_model()
71+
72+
# get a connection to the DB and init VS
73+
with get_connection() as conn:
74+
v_store = OracleVS(
75+
client=conn,
76+
table_name=collection_name,
77+
distance_strategy=DistanceStrategy.COSINE,
78+
embedding_function=embed_model,
79+
)
80+
81+
relevant_docs = v_store.similarity_search(query=query, k=top_k)
82+
83+
if DEBUG:
84+
logger.info("Result from similarity search:")
85+
logger.info(relevant_docs)
86+
87+
except Exception as e:
88+
logger.error("Error in vector_store.invoke: %s", e)
89+
error = str(e)
90+
return {"error": error}
91+
92+
result = {"relevant_docs": relevant_docs}
93+
94+
return result
95+
96+
@mcp.tool
97+
def get_collections() -> list:
98+
"""
99+
Get the list of collections (DB tables) available in the Oracle Vector Store.
100+
Returns:
101+
list: A list of collection names.
102+
"""
103+
with get_connection() as conn:
104+
cursor = conn.cursor()
105+
106+
cursor.execute(
107+
"""SELECT DISTINCT utc.table_name
108+
FROM user_tab_columns utc
109+
WHERE utc.data_type = 'VECTOR'
110+
ORDER BY 1 ASC"""
111+
)
112+
collections = [row[0] for row in cursor.fetchall()]
113+
return collections
114+
115+
if __name__ == "__main__":
116+
mcp.run(
117+
transport=TRANSPORT,
118+
# Bind to all interfaces
119+
host=HOST,
120+
port=PORT,
121+
log_level="INFO",
122+
)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Copyright (c) 2024 Oracle and/or its affiliates.
2+
3+
The Universal Permissive License (UPL), Version 1.0
4+
5+
Subject to the condition set forth below, permission is hereby granted to any
6+
person obtaining a copy of this software, associated documentation and/or data
7+
(collectively the "Software"), free of charge and under any and all copyright
8+
rights in the Software, and any and all patent rights owned or freely
9+
licensable by each licensor hereunder covering either (i) the unmodified
10+
Software as contributed to or provided by such licensor, or (ii) the Larger
11+
Works (as defined below), to deal in both
12+
13+
(a) the Software, and
14+
(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
15+
one is included with the Software (each a "Larger Work" to which the Software
16+
is contributed by such licensors),
17+
18+
without restriction, including without limitation the rights to copy, create
19+
derivative works of, display, perform, and distribute the Software and make,
20+
use, sell, offer for sale, import, export, have made, and have sold the
21+
Software and the Larger Work(s), and to sublicense the foregoing rights on
22+
either these or other terms.
23+
24+
This license is subject to the following condition:
25+
The above copyright notice and either this complete permission notice or at
26+
a minimum a reference to the UPL must be included in all copies or
27+
substantial portions of the Software.
28+
29+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35+
SOFTWARE.
Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
# Integration of OCI Generative AI in Langflow
22

3-
This repository contains all the code for a prototype of the integration of OCI Generative AI in Langflow
3+
[![License: UPL](https://img.shields.io/badge/license-UPL-green)](https://img.shields.io/badge/license-UPL-green) [![Quality gate](https://sonarcloud.io/api/project_badges/quality_gate?project=oracle-devrel_test)](https://sonarcloud.io/dashboard?id=oracle-devrel_test)
44

5-
Reviewed: 23.01.2025
6-
7-
# **Link to code**
8-
[Code](https://github.com/luigisaetta/oci_langflow/tree/main)
5+
## Introduction
6+
This repository contains the code for a prototype of the integration of OCI Generative AI in Langflow
97

10-
# License
11-
8+
Reviewed: 25.06.2025
9+
10+
## Security
11+
Please consult the [security guide](./SECURITY.md) for our responsible security
12+
vulnerability disclosure process.
13+
14+
## License
1215
Copyright (c) 2024 Oracle and/or its affiliates.
13-
16+
1417
Licensed under the Universal Permissive License (UPL), Version 1.0.
15-
16-
See [LICENSE](https://github.com/oracle-devrel/technology-engineering/blob/main/LICENSE) for more details.
18+
19+
See [LICENSE](LICENSE.txt) for more details.
20+
21+
ORACLE AND ITS AFFILIATES DO NOT PROVIDE ANY WARRANTY WHATSOEVER, EXPRESS OR IMPLIED, FOR ANY SOFTWARE, MATERIAL OR CONTENT OF ANY KIND CONTAINED OR PRODUCED WITHIN THIS REPOSITORY, AND IN PARTICULAR SPECIFICALLY DISCLAIM ANY AND ALL IMPLIED WARRANTIES OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. FURTHERMORE, ORACLE AND ITS AFFILIATES DO NOT REPRESENT THAT ANY CUSTOMARY SECURITY REVIEW HAS BEEN PERFORMED WITH RESPECT TO ANY SOFTWARE, MATERIAL OR CONTENT CONTAINED OR PRODUCED WITHIN THIS REPOSITORY. IN ADDITION, AND WITHOUT LIMITING THE FOREGOING, THIRD PARTIES MAY HAVE POSTED SOFTWARE, MATERIAL OR CONTENT TO THIS REPOSITORY WITHOUT ANY REVIEW. USE AT YOUR OWN RISK.
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
"""
2+
Custom integration with Langflow and OCI Embeddings Model
3+
4+
Author: L. Saetta (Oracle)
5+
6+
"""
7+
8+
from langchain_community.embeddings import OCIGenAIEmbeddings
9+
10+
from langflow.base.models.model import LCModelComponent
11+
from langflow.io import DropdownInput, StrInput, Output, SecretStrInput
12+
from langflow.field_typing import Embeddings
13+
14+
class OCIEmbeddingsComponent(LCModelComponent):
15+
"""
16+
This class integrates the OCI Embeddings Model with Langflow.
17+
18+
Notes:
19+
* Security: for now API_KEY, set your key-pair in $HOME/.oci
20+
21+
"""
22+
23+
display_name = "OCI Cohere Embeddings"
24+
description = "Generate Embeddings using OCI Cohere models."
25+
26+
inputs = [
27+
# example of dropdown
28+
DropdownInput(
29+
name="auth_type",
30+
display_name="auth_type",
31+
info="The type of auth_type to use for the chat model",
32+
advanced=True,
33+
options=[
34+
"API_KEY",
35+
"RESOURCE_PRINCIPAL",
36+
],
37+
value="API_KEY",
38+
),
39+
DropdownInput(
40+
name="model",
41+
display_name="Model",
42+
advanced=True,
43+
options=[
44+
"cohere.embed-english-v3.0",
45+
"cohere.embed-multilingual-v3.0",
46+
],
47+
value="cohere.embed-english-v3.0",
48+
),
49+
StrInput(
50+
name="service_endpoint",
51+
display_name="Service Endpoint",
52+
info="OCI Service Endpoint URL",
53+
required=True,
54+
),
55+
SecretStrInput(
56+
name="compartment_id",
57+
display_name="Compartment ID",
58+
info="OCI Compartment OCID",
59+
),
60+
]
61+
62+
outputs = [
63+
Output(display_name="Embeddings", name="embeddings", method="build_embeddings"),
64+
]
65+
66+
def build_model(self) -> Embeddings:
67+
"""
68+
build the embeddings model
69+
"""
70+
return self.build_embeddings()
71+
72+
def build_embeddings(self) -> Embeddings:
73+
"""
74+
build the embeddings model
75+
"""
76+
# default truncate strategy is END
77+
return OCIGenAIEmbeddings(
78+
auth_type=self.auth_type,
79+
model_id=self.model,
80+
service_endpoint=self.service_endpoint,
81+
compartment_id=self.compartment_id,
82+
)

0 commit comments

Comments
 (0)