select-ai 1.1.0__tar.gz → 1.2.0rc1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of select-ai might be problematic. Click here for more details.
- {select_ai-1.1.0/src/select_ai.egg-info → select_ai-1.2.0rc1}/PKG-INFO +1 -1
- select_ai-1.2.0rc1/samples/agent/agent_create.py +27 -0
- select_ai-1.2.0rc1/samples/agent/movie_analyst.py +63 -0
- select_ai-1.2.0rc1/samples/agent/task_create.py +31 -0
- select_ai-1.2.0rc1/samples/agent/tasks_list.py +13 -0
- select_ai-1.2.0rc1/samples/agent/team_create.py +33 -0
- select_ai-1.2.0rc1/samples/agent/tool_create.py +55 -0
- select_ai-1.2.0rc1/samples/agent/tool_create_human.py +35 -0
- select_ai-1.2.0rc1/samples/agent/tool_delete.py +25 -0
- select_ai-1.2.0rc1/samples/agent/tool_list.py +26 -0
- select_ai-1.2.0rc1/samples/agent/websearch_agent.py +101 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/enable_ai_provider.py +1 -1
- select_ai-1.2.0rc1/src/select_ai/agent/__init__.py +24 -0
- select_ai-1.2.0rc1/src/select_ai/agent/core.py +235 -0
- select_ai-1.2.0rc1/src/select_ai/agent/sql.py +80 -0
- select_ai-1.2.0rc1/src/select_ai/agent/task.py +247 -0
- select_ai-1.2.0rc1/src/select_ai/agent/team.py +280 -0
- select_ai-1.2.0rc1/src/select_ai/agent/tool.py +620 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/src/select_ai/errors.py +40 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/src/select_ai/sql.py +10 -4
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/src/select_ai/vector_index.py +12 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/src/select_ai/version.py +1 -1
- {select_ai-1.1.0 → select_ai-1.2.0rc1/src/select_ai.egg-info}/PKG-INFO +1 -1
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/src/select_ai.egg-info/SOURCES.txt +17 -1
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/LICENSE.txt +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/MANIFEST.in +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/README.md +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/pyproject.toml +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/async/conversation_chat_session.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/async/conversations_list.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/async/create_ai_credential.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/async/delete_ai_credential.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/async/disable_ai_provider.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/async/enable_ai_provider.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/async/profile_chat.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/async/profile_create.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/async/profile_explain_sql.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/async/profile_gen_multi_table_synthetic_data.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/async/profile_gen_single_table_synthetic_data.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/async/profile_pipeline.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/async/profile_run_sql.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/async/profile_show_sql.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/async/profile_sql_concurrent_tasks.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/async/profiles_list.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/async/vector_index_create.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/async/vector_index_delete.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/async/vector_index_get_attributes.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/async/vector_index_list.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/async/vector_index_rag.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/async/vector_index_update_attributes.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/conversation_chat_session.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/conversation_create.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/conversation_delete.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/conversations_list.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/create_ai_credential.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/delete_ai_credential.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/disable_ai_provider.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/profile_chat.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/profile_create.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/profile_delete.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/profile_explain_sql.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/profile_gen_multi_table_synthetic_data.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/profile_gen_single_table_synthetic_data.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/profile_narrate.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/profile_run_sql.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/profile_show_sql.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/profiles_list.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/vector_index_create.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/vector_index_delete.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/vector_index_get_attributes.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/vector_index_list.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/vector_index_rag.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/samples/vector_index_update_attributes.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/setup.cfg +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/src/select_ai/__init__.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/src/select_ai/_abc.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/src/select_ai/_enums.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/src/select_ai/_validations.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/src/select_ai/action.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/src/select_ai/async_profile.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/src/select_ai/base_profile.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/src/select_ai/conversation.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/src/select_ai/credential.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/src/select_ai/db.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/src/select_ai/profile.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/src/select_ai/provider.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/src/select_ai/synthetic_data.py +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/src/select_ai.egg-info/dependency_links.txt +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/src/select_ai.egg-info/requires.txt +0 -0
- {select_ai-1.1.0 → select_ai-1.2.0rc1}/src/select_ai.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
import select_ai
|
|
4
|
+
from select_ai.agent import (
|
|
5
|
+
Agent,
|
|
6
|
+
AgentAttributes,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
user = os.getenv("SELECT_AI_USER")
|
|
10
|
+
password = os.getenv("SELECT_AI_PASSWORD")
|
|
11
|
+
dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
|
|
12
|
+
|
|
13
|
+
select_ai.connect(user=user, password=password, dsn=dsn)
|
|
14
|
+
|
|
15
|
+
# Agent
|
|
16
|
+
agent_attributes = AgentAttributes(
|
|
17
|
+
profile_name="LLAMA_4_MAVERICK",
|
|
18
|
+
role="You are an AI Movie Analyst. "
|
|
19
|
+
"Your can help answer a variety of questions related to movies. ",
|
|
20
|
+
enable_human_tool=False,
|
|
21
|
+
)
|
|
22
|
+
agent = Agent(
|
|
23
|
+
agent_name="MOVIE_ANALYST",
|
|
24
|
+
attributes=agent_attributes,
|
|
25
|
+
)
|
|
26
|
+
agent.create(enabled=True, replace=True)
|
|
27
|
+
print("Created Agent:", agent)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import uuid
|
|
3
|
+
|
|
4
|
+
import select_ai
|
|
5
|
+
from select_ai.agent import (
|
|
6
|
+
Agent,
|
|
7
|
+
AgentAttributes,
|
|
8
|
+
Task,
|
|
9
|
+
TaskAttributes,
|
|
10
|
+
Team,
|
|
11
|
+
TeamAttributes,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
user = os.getenv("SELECT_AI_USER")
|
|
15
|
+
password = os.getenv("SELECT_AI_PASSWORD")
|
|
16
|
+
dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
|
|
17
|
+
|
|
18
|
+
select_ai.connect(user=user, password=password, dsn=dsn)
|
|
19
|
+
|
|
20
|
+
# Agent
|
|
21
|
+
agent_attributes = AgentAttributes(
|
|
22
|
+
profile_name="oci_ai_profile",
|
|
23
|
+
role="You are an AI Movie Analyst. "
|
|
24
|
+
"Your can help answer a variety of questions related to movies. ",
|
|
25
|
+
enable_human_tool=False,
|
|
26
|
+
)
|
|
27
|
+
agent = Agent(
|
|
28
|
+
agent_name="MOVIE_ANALYST",
|
|
29
|
+
attributes=agent_attributes,
|
|
30
|
+
)
|
|
31
|
+
agent.create(enabled=True, replace=True)
|
|
32
|
+
print("Create Agent", agent)
|
|
33
|
+
|
|
34
|
+
# Task
|
|
35
|
+
task_attributes = TaskAttributes(
|
|
36
|
+
instruction="Help the user with their request about movies. "
|
|
37
|
+
"User question: {query}",
|
|
38
|
+
enable_human_tool=False,
|
|
39
|
+
)
|
|
40
|
+
task = Task(
|
|
41
|
+
task_name="ANALYZE_MOVIE_TASK",
|
|
42
|
+
description="Movie task involving a human",
|
|
43
|
+
attributes=task_attributes,
|
|
44
|
+
)
|
|
45
|
+
task.create(replace=True)
|
|
46
|
+
print("Created Task", task)
|
|
47
|
+
|
|
48
|
+
# Team
|
|
49
|
+
team_attributes = TeamAttributes(
|
|
50
|
+
agents=[{"name": "MOVIE_ANALYST", "task": "ANALYZE_MOVIE_TASK"}],
|
|
51
|
+
process="sequential",
|
|
52
|
+
)
|
|
53
|
+
team = Team(
|
|
54
|
+
team_name="MOVIE_AGENT_TEAM",
|
|
55
|
+
attributes=team_attributes,
|
|
56
|
+
)
|
|
57
|
+
team.create(enabled=True, replace=True)
|
|
58
|
+
print(
|
|
59
|
+
team.run(
|
|
60
|
+
prompt="In the movie Titanic, was there enough space for Jack ? ",
|
|
61
|
+
params={"conversation_id": str(uuid.uuid4())},
|
|
62
|
+
)
|
|
63
|
+
)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from pprint import pformat
|
|
3
|
+
|
|
4
|
+
import select_ai
|
|
5
|
+
import select_ai.agent
|
|
6
|
+
from select_ai.agent import Task, TaskAttributes
|
|
7
|
+
|
|
8
|
+
user = os.getenv("SELECT_AI_USER")
|
|
9
|
+
password = os.getenv("SELECT_AI_PASSWORD")
|
|
10
|
+
dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
|
|
11
|
+
|
|
12
|
+
select_ai.connect(user=user, password=password, dsn=dsn)
|
|
13
|
+
|
|
14
|
+
attributes = TaskAttributes(
|
|
15
|
+
instruction="Help the user with their request about movies. "
|
|
16
|
+
"User question: {query}. "
|
|
17
|
+
"You can use SQL tool to search the data from database",
|
|
18
|
+
tools=["MOVIE_SQL_TOOL"],
|
|
19
|
+
enable_human_tool=False,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
task = Task(
|
|
23
|
+
task_name="ANALYZE_MOVIE_TASK",
|
|
24
|
+
description="Movie task involving a human",
|
|
25
|
+
attributes=attributes,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
task.create(replace=True)
|
|
29
|
+
|
|
30
|
+
print(task.task_name)
|
|
31
|
+
print(pformat(task.attributes))
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
import select_ai
|
|
4
|
+
import select_ai.agent
|
|
5
|
+
|
|
6
|
+
user = os.getenv("SELECT_AI_USER")
|
|
7
|
+
password = os.getenv("SELECT_AI_PASSWORD")
|
|
8
|
+
dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
|
|
9
|
+
|
|
10
|
+
select_ai.connect(user=user, password=password, dsn=dsn)
|
|
11
|
+
|
|
12
|
+
for task in select_ai.agent.Task.list():
|
|
13
|
+
print(task)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import uuid
|
|
3
|
+
|
|
4
|
+
import select_ai
|
|
5
|
+
from select_ai.agent import (
|
|
6
|
+
Team,
|
|
7
|
+
TeamAttributes,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
conversation_id = str(uuid.uuid4())
|
|
11
|
+
|
|
12
|
+
user = os.getenv("SELECT_AI_USER")
|
|
13
|
+
password = os.getenv("SELECT_AI_PASSWORD")
|
|
14
|
+
dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
|
|
15
|
+
|
|
16
|
+
select_ai.connect(user=user, password=password, dsn=dsn)
|
|
17
|
+
|
|
18
|
+
# Team
|
|
19
|
+
team = Team(
|
|
20
|
+
team_name="MOVIE_AGENT_TEAM",
|
|
21
|
+
attributes=TeamAttributes(
|
|
22
|
+
agents=[{"name": "MOVIE_ANALYST", "task": "ANALYZE_MOVIE_TASK"}],
|
|
23
|
+
process="sequential",
|
|
24
|
+
),
|
|
25
|
+
)
|
|
26
|
+
team.create(enabled=True, replace=True)
|
|
27
|
+
|
|
28
|
+
print(
|
|
29
|
+
team.run(
|
|
30
|
+
prompt="Could you list the movies in the database?",
|
|
31
|
+
params={"conversation_id": conversation_id},
|
|
32
|
+
)
|
|
33
|
+
)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# -----------------------------------------------------------------------------
|
|
2
|
+
# Copyright (c) 2025, Oracle and/or its affiliates.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Universal Permissive License v 1.0 as shown at
|
|
5
|
+
# http://oss.oracle.com/licenses/upl.
|
|
6
|
+
# -----------------------------------------------------------------------------
|
|
7
|
+
|
|
8
|
+
# -----------------------------------------------------------------------------
|
|
9
|
+
# tool_create.py
|
|
10
|
+
#
|
|
11
|
+
# Create a tool for
|
|
12
|
+
# -----------------------------------------------------------------------------
|
|
13
|
+
|
|
14
|
+
import os
|
|
15
|
+
from pprint import pformat
|
|
16
|
+
|
|
17
|
+
import select_ai
|
|
18
|
+
import select_ai.agent
|
|
19
|
+
|
|
20
|
+
user = os.getenv("SELECT_AI_USER")
|
|
21
|
+
password = os.getenv("SELECT_AI_PASSWORD")
|
|
22
|
+
dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
|
|
23
|
+
|
|
24
|
+
select_ai.connect(user=user, password=password, dsn=dsn)
|
|
25
|
+
|
|
26
|
+
profile_attributes = select_ai.ProfileAttributes(
|
|
27
|
+
credential_name="my_oci_ai_profile_key",
|
|
28
|
+
object_list=[
|
|
29
|
+
{"owner": user, "name": "MOVIE"},
|
|
30
|
+
{"owner": user, "name": "ACTOR"},
|
|
31
|
+
{"owner": user, "name": "DIRECTOR"},
|
|
32
|
+
],
|
|
33
|
+
provider=select_ai.OCIGenAIProvider(
|
|
34
|
+
region="us-chicago-1",
|
|
35
|
+
oci_apiformat="GENERIC",
|
|
36
|
+
model="meta.llama-4-maverick-17b-128e-instruct-fp8",
|
|
37
|
+
),
|
|
38
|
+
)
|
|
39
|
+
profile = select_ai.Profile(
|
|
40
|
+
profile_name="LLAMA_4_MAVERICK",
|
|
41
|
+
attributes=profile_attributes,
|
|
42
|
+
description="MY OCI AI Profile",
|
|
43
|
+
replace=True,
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
# Use the OCI AI Profile to perform natural
|
|
47
|
+
# language SQL translation
|
|
48
|
+
sql_tool = select_ai.agent.Tool.create_sql_tool(
|
|
49
|
+
tool_name="MOVIE_SQL_TOOL",
|
|
50
|
+
description="My Select AI MOVIE SQL agent tool",
|
|
51
|
+
profile_name="LLAMA_4_MAVERICK",
|
|
52
|
+
replace=True,
|
|
53
|
+
)
|
|
54
|
+
print(sql_tool.tool_name)
|
|
55
|
+
print(pformat(sql_tool.attributes))
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# -----------------------------------------------------------------------------
|
|
2
|
+
# Copyright (c) 2025, Oracle and/or its affiliates.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Universal Permissive License v 1.0 as shown at
|
|
5
|
+
# http://oss.oracle.com/licenses/upl.
|
|
6
|
+
# -----------------------------------------------------------------------------
|
|
7
|
+
|
|
8
|
+
# -----------------------------------------------------------------------------
|
|
9
|
+
# tool_create_human.py
|
|
10
|
+
#
|
|
11
|
+
# Create a vector index for Retrieval Augmented Generation (RAG)
|
|
12
|
+
# -----------------------------------------------------------------------------
|
|
13
|
+
|
|
14
|
+
import os
|
|
15
|
+
|
|
16
|
+
import select_ai
|
|
17
|
+
import select_ai.agent
|
|
18
|
+
|
|
19
|
+
user = os.getenv("SELECT_AI_USER")
|
|
20
|
+
password = os.getenv("SELECT_AI_PASSWORD")
|
|
21
|
+
dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
|
|
22
|
+
|
|
23
|
+
select_ai.connect(user=user, password=password, dsn=dsn)
|
|
24
|
+
|
|
25
|
+
attributes = select_ai.agent.ToolAttributes(
|
|
26
|
+
tool_params=select_ai.agent.HumanToolParams()
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
human_tool = select_ai.agent.Tool(
|
|
30
|
+
attributes=attributes,
|
|
31
|
+
tool_name="Human",
|
|
32
|
+
description="My Select AI agent human tool",
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
human_tool.create()
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# -----------------------------------------------------------------------------
|
|
2
|
+
# Copyright (c) 2025, Oracle and/or its affiliates.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Universal Permissive License v 1.0 as shown at
|
|
5
|
+
# http://oss.oracle.com/licenses/upl.
|
|
6
|
+
# -----------------------------------------------------------------------------
|
|
7
|
+
|
|
8
|
+
# -----------------------------------------------------------------------------
|
|
9
|
+
# tool_delete.py
|
|
10
|
+
#
|
|
11
|
+
# Delete an AI tool
|
|
12
|
+
# -----------------------------------------------------------------------------
|
|
13
|
+
|
|
14
|
+
import os
|
|
15
|
+
|
|
16
|
+
import select_ai.agent
|
|
17
|
+
|
|
18
|
+
user = os.getenv("SELECT_AI_USER")
|
|
19
|
+
password = os.getenv("SELECT_AI_PASSWORD")
|
|
20
|
+
dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
|
|
21
|
+
|
|
22
|
+
select_ai.connect(user=user, password=password, dsn=dsn)
|
|
23
|
+
|
|
24
|
+
tool = select_ai.agent.Tool("LLM_CHAT_TOOL")
|
|
25
|
+
tool.delete(force=True)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# -----------------------------------------------------------------------------
|
|
2
|
+
# Copyright (c) 2025, Oracle and/or its affiliates.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Universal Permissive License v 1.0 as shown at
|
|
5
|
+
# http://oss.oracle.com/licenses/upl.
|
|
6
|
+
# -----------------------------------------------------------------------------
|
|
7
|
+
|
|
8
|
+
# -----------------------------------------------------------------------------
|
|
9
|
+
# tool_list.py
|
|
10
|
+
#
|
|
11
|
+
# List all the Agent Tools
|
|
12
|
+
# -----------------------------------------------------------------------------
|
|
13
|
+
|
|
14
|
+
import os
|
|
15
|
+
|
|
16
|
+
import select_ai
|
|
17
|
+
import select_ai.agent
|
|
18
|
+
|
|
19
|
+
user = os.getenv("SELECT_AI_USER")
|
|
20
|
+
password = os.getenv("SELECT_AI_PASSWORD")
|
|
21
|
+
dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
|
|
22
|
+
|
|
23
|
+
select_ai.connect(user=user, password=password, dsn=dsn)
|
|
24
|
+
|
|
25
|
+
for tool in select_ai.agent.Tool.list():
|
|
26
|
+
print(tool)
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
import select_ai
|
|
4
|
+
from select_ai.agent import (
|
|
5
|
+
Agent,
|
|
6
|
+
AgentAttributes,
|
|
7
|
+
Task,
|
|
8
|
+
TaskAttributes,
|
|
9
|
+
Team,
|
|
10
|
+
TeamAttributes,
|
|
11
|
+
Tool,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
OPEN_AI_CREDENTIAL_NAME = "OPENAI_CRED"
|
|
15
|
+
OPEN_AI_PROFILE_NAME = "OPENAI_PROFILE"
|
|
16
|
+
SELECT_AI_AGENT_NAME = "WEB_SEARCH_AGENT"
|
|
17
|
+
SELECT_AI_TASK_NAME = "WEB_SEARCH_TASK"
|
|
18
|
+
SELECT_AI_TOOL_NAME = "WEB_SEARCH_TOOL"
|
|
19
|
+
SELECT_AI_TEAM_NAME = "WEB_SEARCH_TEAM"
|
|
20
|
+
|
|
21
|
+
USER_QUERIES = {
|
|
22
|
+
"d917b055-e8a1-463a-a489-d4328a7b2210": "What are the key features for the product highlighted at this URL https://www.oracle.com/artificial-intelligence/database-machine-learning",
|
|
23
|
+
"c2e3ff20-f56d-40e7-987c-cc72740c75a5": "What is the main topic at this URL https://www.oracle.com/artificial-intelligence/database-machine-learning",
|
|
24
|
+
"25e23a25-07b9-4ed7-be11-f7e5e445d286": "What is the main topic at this URL https://openai.com",
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
# connect
|
|
28
|
+
user = os.getenv("SELECT_AI_USER")
|
|
29
|
+
password = os.getenv("SELECT_AI_PASSWORD")
|
|
30
|
+
dsn = os.getenv("SELECT_AI_DB_CONNECT_STRING")
|
|
31
|
+
select_ai.connect(user=user, password=password, dsn=dsn)
|
|
32
|
+
|
|
33
|
+
# Create Open AI credential
|
|
34
|
+
select_ai.create_credential(
|
|
35
|
+
credential={
|
|
36
|
+
"credential_name": OPEN_AI_CREDENTIAL_NAME,
|
|
37
|
+
"username": "OPENAI",
|
|
38
|
+
"password": os.getenv("OPEN_AI_API_KEY"),
|
|
39
|
+
},
|
|
40
|
+
replace=True,
|
|
41
|
+
)
|
|
42
|
+
print("Created credential: ", OPEN_AI_CREDENTIAL_NAME)
|
|
43
|
+
|
|
44
|
+
# # Create Open AI Profile
|
|
45
|
+
profile = select_ai.Profile(
|
|
46
|
+
profile_name=OPEN_AI_PROFILE_NAME,
|
|
47
|
+
attributes=select_ai.ProfileAttributes(
|
|
48
|
+
credential_name=OPEN_AI_CREDENTIAL_NAME,
|
|
49
|
+
provider=select_ai.OpenAIProvider(model="gpt-4.1"),
|
|
50
|
+
),
|
|
51
|
+
description="My Open AI Profile",
|
|
52
|
+
replace=True,
|
|
53
|
+
)
|
|
54
|
+
print("Created profile: ", OPEN_AI_PROFILE_NAME)
|
|
55
|
+
|
|
56
|
+
# Create an AI Agent team
|
|
57
|
+
team = Team(
|
|
58
|
+
team_name=SELECT_AI_TEAM_NAME,
|
|
59
|
+
attributes=TeamAttributes(
|
|
60
|
+
agents=[{"name": SELECT_AI_AGENT_NAME, "task": SELECT_AI_TASK_NAME}]
|
|
61
|
+
),
|
|
62
|
+
)
|
|
63
|
+
team.create(replace=True)
|
|
64
|
+
|
|
65
|
+
# Agent
|
|
66
|
+
agent = Agent(
|
|
67
|
+
agent_name=SELECT_AI_AGENT_NAME,
|
|
68
|
+
attributes=AgentAttributes(
|
|
69
|
+
profile_name=OPEN_AI_PROFILE_NAME,
|
|
70
|
+
enable_human_tool=False,
|
|
71
|
+
role="You are a specialized web search agent that can access web page contents and respond to questions based on its content.",
|
|
72
|
+
),
|
|
73
|
+
)
|
|
74
|
+
agent.create(replace=True)
|
|
75
|
+
|
|
76
|
+
# Task
|
|
77
|
+
task = Task(
|
|
78
|
+
task_name=SELECT_AI_TASK_NAME,
|
|
79
|
+
attributes=TaskAttributes(
|
|
80
|
+
instruction="Answer the user question about the provided URL:{query}",
|
|
81
|
+
enable_human_tool=False,
|
|
82
|
+
tools=[SELECT_AI_TOOL_NAME],
|
|
83
|
+
),
|
|
84
|
+
)
|
|
85
|
+
task.create(replace=True)
|
|
86
|
+
|
|
87
|
+
# Tool
|
|
88
|
+
web_search_tool = Tool.create_websearch_tool(
|
|
89
|
+
tool_name=SELECT_AI_TOOL_NAME,
|
|
90
|
+
credential_name=OPEN_AI_CREDENTIAL_NAME,
|
|
91
|
+
description="Web Search Tool using OpenAI",
|
|
92
|
+
replace=True,
|
|
93
|
+
)
|
|
94
|
+
print("Created tool: ", SELECT_AI_TOOL_NAME)
|
|
95
|
+
|
|
96
|
+
# Run the Agent Team
|
|
97
|
+
for conversation_id, prompt in USER_QUERIES.items():
|
|
98
|
+
response = team.run(
|
|
99
|
+
prompt=prompt, params={"conversation_id": conversation_id}
|
|
100
|
+
)
|
|
101
|
+
print(response)
|
|
@@ -23,6 +23,6 @@ select_ai_user = os.getenv("SELECT_AI_USER")
|
|
|
23
23
|
|
|
24
24
|
select_ai.connect(user=admin_user, password=password, dsn=dsn)
|
|
25
25
|
select_ai.enable_provider(
|
|
26
|
-
users=select_ai_user, provider_endpoint="
|
|
26
|
+
users=select_ai_user, provider_endpoint="api.OPENAI.com"
|
|
27
27
|
)
|
|
28
28
|
print("Enabled AI provider for user: ", select_ai_user)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# -----------------------------------------------------------------------------
|
|
2
|
+
# Copyright (c) 2025, Oracle and/or its affiliates.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Universal Permissive License v 1.0 as shown at
|
|
5
|
+
# http://oss.oracle.com/licenses/upl.
|
|
6
|
+
# -----------------------------------------------------------------------------
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
from .core import Agent, AgentAttributes
|
|
10
|
+
from .task import Task, TaskAttributes
|
|
11
|
+
from .team import Team, TeamAttributes
|
|
12
|
+
from .tool import (
|
|
13
|
+
EmailNotificationToolParams,
|
|
14
|
+
HTTPToolParams,
|
|
15
|
+
HumanToolParams,
|
|
16
|
+
RAGToolParams,
|
|
17
|
+
SlackNotificationToolParams,
|
|
18
|
+
SQLToolParams,
|
|
19
|
+
Tool,
|
|
20
|
+
ToolAttributes,
|
|
21
|
+
ToolParams,
|
|
22
|
+
ToolType,
|
|
23
|
+
WebSearchToolParams,
|
|
24
|
+
)
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
# ------------------------------------------------------------------------------
|
|
2
|
+
# Copyright (c) 2025, Oracle and/or its affiliates.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Universal Permissive License v 1.0 as shown at
|
|
5
|
+
# http://oss.oracle.com/licenses/upl.
|
|
6
|
+
# -----------------------------------------------------------------------------
|
|
7
|
+
|
|
8
|
+
import json
|
|
9
|
+
from abc import ABC
|
|
10
|
+
from dataclasses import dataclass
|
|
11
|
+
from typing import (
|
|
12
|
+
Any,
|
|
13
|
+
AsyncGenerator,
|
|
14
|
+
Iterator,
|
|
15
|
+
List,
|
|
16
|
+
Mapping,
|
|
17
|
+
Optional,
|
|
18
|
+
Union,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
import oracledb
|
|
22
|
+
|
|
23
|
+
from select_ai import BaseProfile
|
|
24
|
+
from select_ai._abc import SelectAIDataClass
|
|
25
|
+
from select_ai._enums import StrEnum
|
|
26
|
+
from select_ai.agent.sql import (
|
|
27
|
+
GET_USER_AI_AGENT,
|
|
28
|
+
GET_USER_AI_AGENT_ATTRIBUTES,
|
|
29
|
+
LIST_USER_AI_AGENTS,
|
|
30
|
+
)
|
|
31
|
+
from select_ai.async_profile import AsyncProfile
|
|
32
|
+
from select_ai.db import async_cursor, cursor
|
|
33
|
+
from select_ai.errors import AgentNotFoundError
|
|
34
|
+
from select_ai.profile import Profile
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@dataclass
|
|
38
|
+
class AgentAttributes(SelectAIDataClass):
|
|
39
|
+
"""AI Agent Attributes
|
|
40
|
+
|
|
41
|
+
:param str profile_name: Name of the AI Profile which agent will
|
|
42
|
+
use to send request to LLM
|
|
43
|
+
:param str role: Agent's role also sent to LLM
|
|
44
|
+
:param bool enable_human_tool: Enable human tool support. Agent
|
|
45
|
+
will ask question to the user for any clarification
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
profile_name: str
|
|
49
|
+
role: str
|
|
50
|
+
enable_human_tool: Optional[bool] = True
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class BaseAgent(ABC):
|
|
54
|
+
|
|
55
|
+
def __init__(
|
|
56
|
+
self,
|
|
57
|
+
agent_name: Optional[str] = None,
|
|
58
|
+
description: Optional[str] = None,
|
|
59
|
+
attributes: Optional[AgentAttributes] = None,
|
|
60
|
+
):
|
|
61
|
+
if attributes is not None and not isinstance(
|
|
62
|
+
attributes, AgentAttributes
|
|
63
|
+
):
|
|
64
|
+
raise TypeError(
|
|
65
|
+
"attributes must be an object of type "
|
|
66
|
+
"select_ai.agent.AgentAttributes"
|
|
67
|
+
)
|
|
68
|
+
self.agent_name = agent_name
|
|
69
|
+
self.description = description
|
|
70
|
+
self.attributes = attributes
|
|
71
|
+
|
|
72
|
+
def __repr__(self):
|
|
73
|
+
return (
|
|
74
|
+
f"{self.__class__.__name__}("
|
|
75
|
+
f"agent_name={self.agent_name}, "
|
|
76
|
+
f"attributes={self.attributes}, description={self.description})"
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class Agent(BaseAgent):
|
|
81
|
+
"""
|
|
82
|
+
select_ai.agent.Agent class lets you create, delete, enable, disable
|
|
83
|
+
and list AI agents
|
|
84
|
+
|
|
85
|
+
:param str agent_name: The name of the AI Agent
|
|
86
|
+
:param str description: Optional description of the AI agent
|
|
87
|
+
:param select_ai.agent.AgentAttributes attributes: AI agent attributes
|
|
88
|
+
|
|
89
|
+
"""
|
|
90
|
+
|
|
91
|
+
@staticmethod
|
|
92
|
+
def _get_attributes(agent_name: str) -> AgentAttributes:
|
|
93
|
+
with cursor() as cr:
|
|
94
|
+
cr.execute(GET_USER_AI_AGENT, agent_name=agent_name.upper())
|
|
95
|
+
attributes = cr.fetchall()
|
|
96
|
+
if attributes:
|
|
97
|
+
post_processed_attributes = {}
|
|
98
|
+
for k, v in attributes:
|
|
99
|
+
if isinstance(v, oracledb.LOB):
|
|
100
|
+
post_processed_attributes[k] = v.read()
|
|
101
|
+
else:
|
|
102
|
+
post_processed_attributes[k] = v
|
|
103
|
+
return AgentAttributes(**post_processed_attributes)
|
|
104
|
+
else:
|
|
105
|
+
raise AgentNotFoundError(agent_name=agent_name)
|
|
106
|
+
|
|
107
|
+
def create(
|
|
108
|
+
self, enabled: Optional[bool] = True, replace: Optional[bool] = False
|
|
109
|
+
):
|
|
110
|
+
"""
|
|
111
|
+
Register a new AI Agent within the Select AI framework
|
|
112
|
+
|
|
113
|
+
:param bool enabled: Whether the AI Agent should be enabled.
|
|
114
|
+
Default value is True.
|
|
115
|
+
|
|
116
|
+
:param bool replace: Whether the AI Agent should be replaced.
|
|
117
|
+
Default value is False.
|
|
118
|
+
|
|
119
|
+
"""
|
|
120
|
+
if self.agent_name is None:
|
|
121
|
+
raise AttributeError("Agent must have a name")
|
|
122
|
+
if self.attributes is None:
|
|
123
|
+
raise AttributeError("Agent must have attributes")
|
|
124
|
+
|
|
125
|
+
parameters = {
|
|
126
|
+
"agent_name": self.agent_name,
|
|
127
|
+
"attributes": self.attributes.json(),
|
|
128
|
+
}
|
|
129
|
+
if self.description:
|
|
130
|
+
parameters["description"] = self.description
|
|
131
|
+
|
|
132
|
+
if not enabled:
|
|
133
|
+
parameters["status"] = "disabled"
|
|
134
|
+
|
|
135
|
+
with cursor() as cr:
|
|
136
|
+
try:
|
|
137
|
+
cr.callproc(
|
|
138
|
+
"DBMS_CLOUD_AI_AGENT.CREATE_AGENT",
|
|
139
|
+
keyword_parameters=parameters,
|
|
140
|
+
)
|
|
141
|
+
except oracledb.Error as err:
|
|
142
|
+
(err_obj,) = err.args
|
|
143
|
+
if err_obj.code in (20050, 20052) and replace:
|
|
144
|
+
self.delete(force=True)
|
|
145
|
+
cr.callproc(
|
|
146
|
+
"DBMS_CLOUD_AI_AGENT.CREATE_AGENT",
|
|
147
|
+
keyword_parameters=parameters,
|
|
148
|
+
)
|
|
149
|
+
else:
|
|
150
|
+
raise
|
|
151
|
+
|
|
152
|
+
def delete(self, force: Optional[bool] = False):
|
|
153
|
+
"""
|
|
154
|
+
Delete AI Agent from the database
|
|
155
|
+
|
|
156
|
+
:param bool force: Force the deletion. Default value is False.
|
|
157
|
+
|
|
158
|
+
"""
|
|
159
|
+
with cursor() as cr:
|
|
160
|
+
cr.callproc(
|
|
161
|
+
"DBMS_CLOUD_AI_AGENT.DROP_AGENT",
|
|
162
|
+
keyword_parameters={
|
|
163
|
+
"agent_name": self.agent_name,
|
|
164
|
+
"force": force,
|
|
165
|
+
},
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
def disable(self):
|
|
169
|
+
"""
|
|
170
|
+
Disable AI Agent
|
|
171
|
+
|
|
172
|
+
"""
|
|
173
|
+
pass
|
|
174
|
+
|
|
175
|
+
def enable(self):
|
|
176
|
+
"""
|
|
177
|
+
Enable AI Agent
|
|
178
|
+
"""
|
|
179
|
+
pass
|
|
180
|
+
|
|
181
|
+
@classmethod
|
|
182
|
+
def fetch(cls, agent_name: str) -> "Agent":
|
|
183
|
+
"""
|
|
184
|
+
Fetch AI Agent attributes from the Database and build a proxy object in
|
|
185
|
+
the Python layer
|
|
186
|
+
|
|
187
|
+
:param str agent_name: The name of the AI Agent
|
|
188
|
+
|
|
189
|
+
:return: select_ai.agent.Agent
|
|
190
|
+
|
|
191
|
+
:raises select_ai.errors.AgentNotFoundError:
|
|
192
|
+
If the AI Agent is not found
|
|
193
|
+
|
|
194
|
+
"""
|
|
195
|
+
pass
|
|
196
|
+
|
|
197
|
+
@classmethod
|
|
198
|
+
def list(
|
|
199
|
+
cls, agent_name_pattern: Optional[str] = ".*"
|
|
200
|
+
) -> Iterator["Agent"]:
|
|
201
|
+
"""
|
|
202
|
+
List AI agents matching a pattern
|
|
203
|
+
|
|
204
|
+
:param str agent_name_pattern: Regular expressions can be used
|
|
205
|
+
to specify a pattern. Function REGEXP_LIKE is used to perform the
|
|
206
|
+
match. Default value is ".*" i.e. match all agent names.
|
|
207
|
+
|
|
208
|
+
:return: Iterator[Agent]
|
|
209
|
+
"""
|
|
210
|
+
with cursor() as cr:
|
|
211
|
+
cr.execute(
|
|
212
|
+
LIST_USER_AI_AGENTS,
|
|
213
|
+
agent_name_pattern=agent_name_pattern,
|
|
214
|
+
)
|
|
215
|
+
for row in cr.fetchall():
|
|
216
|
+
agent_name = row[0]
|
|
217
|
+
if row[1]:
|
|
218
|
+
description = row[1].read() # Oracle.LOB
|
|
219
|
+
else:
|
|
220
|
+
description = None
|
|
221
|
+
attributes = cls._get_attributes(agent_name=agent_name)
|
|
222
|
+
yield cls(
|
|
223
|
+
agent_name=agent_name,
|
|
224
|
+
description=description,
|
|
225
|
+
attributes=attributes,
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
def set_attributes(self, attributes: AgentAttributes) -> None:
|
|
229
|
+
"""
|
|
230
|
+
Set AI Agent attributes
|
|
231
|
+
"""
|
|
232
|
+
pass
|
|
233
|
+
|
|
234
|
+
def set_attribute(self, attribute_name: str, attribute_value: Any) -> None:
|
|
235
|
+
pass
|