Skip to content

Commit e1a03c0

Browse files
Merge branch 'main' into dependabot/pip/ai/gen-ai-agents/oci_adk_projects/adk-weather-tool/requests-2.32.4
2 parents 3b5cfeb + 3c4e211 commit e1a03c0

File tree

180 files changed

+13330
-279
lines changed

Some content is hidden

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

180 files changed

+13330
-279
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,6 @@ terraform.rc
4444
# Exclude cached Python binary files
4545
*.pyc
4646
__pycache__
47+
48+
desktop.ini
49+

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"githubPullRequests.ignoredPullRequestBranches": [
3+
"main"
4+
]
5+
}

ai/README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
1-
# AI Services
1+
# OCI Generative AI and AI Services
22

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.
3+
Oracle Cloud Infrastructure (OCI) [Generative AI Service](https://docs.oracle.com/en-us/iaas/Content/generative-ai/overview.htm), [Generative AI Agents](https://docs.oracle.com/en-us/iaas/Content/generative-ai-agents/overview.htm) and [AI Services](https://www.oracle.com/uk/artificial-intelligence/ai-services/) 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: 03.06.2025
5+
Reviewed: 21.08.2025
66

77

88
# Useful Links
99

1010
## Examples and hands-on workshops
1111
- [AI Solutions Hub](https://www.oracle.com/artificial-intelligence/solutions/)
1212
- [Oracle LiveLabs](https://apexapps.oracle.com/pls/apex/r/dbpm/livelabs/home)
13+
- [This repository](https://github.com/oracle-devrel/technology-engineering/tree/main/ai) and [Oracle-samples repository](https://github.com/oracle-samples/oci-data-science-ai-samples)
14+
- [Oracle Developer Coaching channel on Youtube](https://www.youtube.com/@oracledevs)
1315

1416
## Discover Oracle AI
15-
- [Oracle AI Services on Oracle.com](https://www.oracle.com/artificial-intelligence/ai-services/)
17+
- [Oracle AI on Oracle.com](https://www.oracle.com/artificial-intelligence/)
1618
- [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)
19+
- [Oracle AI First Principles - Youtube series](https://www.youtube.com/watch?v=ZCX-gT1q0ZQ)
1820
- [Oracle’s Generative AI strategy](https://blogs.oracle.com/ai-and-datascience/post/generative-ai-strategy)
19-
- [AI use cases - 10 examples](https://www.oracle.com/a/ocom/docs/gated/ai-use-cases-ebook.pdf)
20-
- [Availability of AI Services across OCI datacenters](https://www.oracle.com/uk/cloud/public-cloud-regions/service-availability/#commercial)
21+
- [Oracle AI & Data Science Blog](https://blogs.oracle.com/ai-and-datascience/)
22+
- [AI use cases - 11 examples](https://www.oracle.com/a/ocom/docs/gated/ai-use-cases-ebook.pdf)
23+
- [Availability of AI Services across OCI datacenters](https://www.oracle.com/cloud/distributed-cloud/#service-availability)
2124

2225
## Learning paths and certifications
2326
- [OCI AI Foundations Certification](https://mylearn.oracle.com/ou/learning-path/become-an-oci-ai-foundations-associate-2024/140164)

ai/gen-ai-agents/assistant-secretary-agent/files/local_requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ traitlets==5.14.3
9494
typing-inspect==0.9.0
9595
typing_extensions==4.12.2
9696
tzdata==2024.2
97-
urllib3==2.3.0
97+
urllib3==2.5.0
9898
wcwidth==0.2.13
9999
yarl==1.18.0
100100
zstandard==0.23.0

ai/gen-ai-agents/assistant-secretary-agent/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
An AI-powered assistant that routes user input across tools like Gmail, Google Calendar, Weather API, Calculator, and Oracle’s Generative AI services for smart, dynamic task automation.
44

5-
Reviewed: 23.04.2025
5+
Reviewed: 23.08.2025
66

77
# When to use this asset?
88

ai/gen-ai-agents/csvpdf_analyzer/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ CSV Analyzer Agent is an AI-Agent assistant designed to automate document unders
44
It intelligently routes user questions through a multi-step process that includes PDF information extraction, CSV data analysis, code generation, execution, and natural language explanation.
55
It supports dynamic workflows like PDF parsing, CSV querying, and context-aware reporting through a Streamlit UI.
66

7-
Reviewed: April 18, 2025
7+
Reviewed: August 18, 2025
88

99
# When to use this asset?
1010

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ class State(TypedDict):
4040
standalone_question: str = ""
4141

4242
# similarity_search
43+
# 30/06: modified, now they're a dict with
44+
# page_content and metadata
45+
# populated with docs_serializable (utils.py)
4346
retriever_docs: Optional[list] = []
4447
# reranker
4548
reranker_docs: Optional[list] = []

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
File name: answer_generator.py
33
Author: Luigi Saetta
4-
Date last modified: 2025-03-31
4+
Date last modified: 2025-04-02
55
Python Version: 3.11
66
77
Description:
@@ -67,10 +67,8 @@ def build_context_for_llm(self, docs: list):
6767
6868
docs: list[Documents]
6969
"""
70-
_context = ""
71-
72-
for doc in docs:
73-
_context += doc.page_content + "\n\n"
70+
# more Pythonic
71+
_context = "\n\n".join(doc["page_content"] for doc in docs)
7472

7573
return _context
7674

@@ -79,7 +77,7 @@ def invoke(self, input: State, config=None, **kwargs):
7977
"""
8078
Generate the final answer
8179
"""
82-
# get the config
80+
# get the model_id from config
8381
model_id = config["configurable"]["model_id"]
8482

8583
if config["configurable"]["main_language"] in self.dict_languages:
@@ -102,6 +100,7 @@ def invoke(self, input: State, config=None, **kwargs):
102100
try:
103101
llm = get_llm(model_id=model_id)
104102

103+
# docs are returned from the reranker
105104
_context = self.build_context_for_llm(input["reranker_docs"])
106105

107106
system_prompt = PromptTemplate(

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
File name: assistant_ui.py
33
Author: Luigi Saetta
44
Date created: 2024-12-04
5-
Date last modified: 2025-03-31
5+
Date last modified: 2025-07-01
66
Python Version: 3.11
77
88
Description:
@@ -15,7 +15,7 @@
1515
This code is released under the MIT License.
1616
1717
Notes:
18-
This is part of a demo fro a RAG solution implemented
18+
This is part of a demo for a RAG solution implemented
1919
using LangGraph
2020
2121
Warnings:
@@ -38,7 +38,7 @@
3838
from transport import http_transport
3939
from utils import get_console_logger
4040

41-
# changed to better manage ENABLE_TRACING
41+
# changed to better manage ENABLE_TRACING (can be enabled from UI)
4242
import config
4343

4444
# Constant
@@ -142,13 +142,14 @@ def register_feedback():
142142

143143
st.sidebar.header("Options")
144144

145+
st.sidebar.text_input(label="Region", value=config.REGION, disabled=True)
146+
145147
# the collection used for semantic search
146148
st.session_state.collection_name = st.sidebar.selectbox(
147149
"Collection name",
148150
config.COLLECTION_LIST,
149151
)
150152

151-
# add the choice of LLM (not used for now)
152153
st.session_state.main_language = st.sidebar.selectbox(
153154
"Select the language for the answer",
154155
config.LANGUAGE_LIST,
@@ -203,11 +204,11 @@ def register_feedback():
203204
encoding=Encoding.V2_JSON,
204205
sample_rate=100,
205206
) as span:
206-
# loop to manage streaming
207207
# set the agent config
208208
agent_config = {
209209
"configurable": {
210210
"model_id": st.session_state.model_id,
211+
"embed_model_type": config.EMBED_MODEL_TYPE,
211212
"enable_reranker": st.session_state.enable_reranker,
212213
"enable_tracing": config.ENABLE_TRACING,
213214
"main_language": st.session_state.main_language,
@@ -219,6 +220,7 @@ def register_feedback():
219220
if config.DEBUG:
220221
logger.info("Agent config: %s", agent_config)
221222

223+
# loop to manage streaming
222224
for event in st.session_state.workflow.stream(
223225
input_state,
224226
config=agent_config,
@@ -248,13 +250,13 @@ def register_feedback():
248250
# Stream
249251
with st.chat_message(ASSISTANT):
250252
response_container = st.empty()
251-
full_response = ""
253+
FULL_RESPONSE = ""
252254

253255
for chunk in answer_generator:
254-
full_response += chunk.content
255-
response_container.markdown(full_response + "▌")
256+
FULL_RESPONSE += chunk.content
257+
response_container.markdown(FULL_RESPONSE + "▌")
256258

257-
response_container.markdown(full_response)
259+
response_container.markdown(FULL_RESPONSE)
258260

259261
elapsed_time = round((time.time() - time_start), 1)
260262
logger.info("Elapsed time: %s sec.", elapsed_time)
@@ -268,7 +270,7 @@ def register_feedback():
268270

269271
# Add user/assistant message to chat history
270272
add_to_chat_history(HumanMessage(content=question))
271-
add_to_chat_history(AIMessage(content=full_response))
273+
add_to_chat_history(AIMessage(content=FULL_RESPONSE))
272274

273275
# get the feedback
274276
if st.session_state.get_feedback:

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

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,22 @@ def fetch_text_data(self):
5757
cursor.execute(query)
5858

5959
while True:
60-
rows = cursor.fetchmany(self.batch_size) # Fetch records in batches
60+
# Fetch records in batches
61+
rows = cursor.fetchmany(self.batch_size)
6162
if not rows:
62-
break # Exit loop when no more data
63+
# Exit loop when no more data
64+
break
6365

6466
for row in rows:
65-
lob_data = row[0] # This is a CLOB object
67+
# This is a CLOB object
68+
lob_data = row[0]
6669

6770
if isinstance(lob_data, oracledb.LOB):
68-
_results.append(lob_data.read()) # Read LOB content
71+
# Read LOB content
72+
_results.append(lob_data.read())
6973
else:
70-
_results.append(str(lob_data)) # Fallback for non-LOB data
74+
# Fallback for non-LOB data
75+
_results.append(str(lob_data))
7176

7277
return _results
7378

@@ -116,18 +121,33 @@ def search(self, query, top_n=5):
116121

117122
# Example Usage:
118123
# credential are packed in CONNECT_ARGS
119-
table_name = "BOOKS"
120-
text_column = "TEXT"
121124

122-
# create the index
123-
bm25_search = BM25OracleSearch(table_name, text_column)
124125

125-
questions = ["Chi è Luigi Saetta?", "What are the main innovation produced by GPT-4?"]
126+
def run_test():
127+
"""
128+
To run a quick test.
129+
"""
130+
table_name = "BOOKS"
131+
text_column = "TEXT"
132+
133+
# create the index
134+
bm25_search = BM25OracleSearch(table_name, text_column)
135+
136+
questions = [
137+
"Chi è Luigi Saetta?",
138+
"What are the main innovation produced by GPT-4?",
139+
]
140+
141+
for _question in questions:
142+
results = bm25_search.search(_question, top_n=2)
143+
144+
# Print search results
145+
for text, score in results:
146+
print(f"Score: {score:.2f} - Text: {text}")
147+
print("")
126148

127-
for _question in questions:
128-
results = bm25_search.search(_question, top_n=2)
129149

130-
# Print search results
131-
for text, score in results:
132-
print(f"Score: {score:.2f} - Text: {text}")
133-
print("")
150+
#
151+
# Main
152+
#
153+
run_test()

0 commit comments

Comments
 (0)