-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_connector.py
More file actions
82 lines (67 loc) · 2.35 KB
/
Copy pathcreate_connector.py
File metadata and controls
82 lines (67 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
"""
Author: L. Saetta
Last modified: 2026-03-16
License: MIT
Description:
Create a connector between an OCI Object Storage bucket and a Vector Store.
"""
from datetime import datetime, timedelta, timezone
from oci.generative_ai.models import (
CreateVectorStoreConnectorDetails,
ObjectStorageConfig,
OciObjectStorageConfiguration,
ScheduleIntervalConfig,
)
from common import build_oci_genai_client, print_runtime_config
from config_private import COMPARTMENT_ID, VECTOR_STORE_ID
# OCI Object Storage source for the connector
OS_NAMESPACE = "frpj5kvxryk1"
OS_BUCKET = "agent_hub_chicago"
# entire bucket
OS_PREFIX = ""
def main() -> None:
"""Build connector details for an Object Storage to Vector Store connector."""
print_runtime_config()
print("")
client = build_oci_genai_client()
# list existing connectors
response = client.list_vector_store_connectors(COMPARTMENT_ID)
items = response.data.items
print("")
print(f"Total connectors in compartment: {len(items)}")
print("")
for item in items:
print(f" - {item.id} [{item.lifecycle_state}] {item.display_name}")
# create the new connector
create_connector_details = CreateVectorStoreConnectorDetails(
compartment_id=COMPARTMENT_ID,
vector_store_id=VECTOR_STORE_ID,
display_name="Product Docs Connector",
description="Syncs documentation from Object Storage",
configuration=OciObjectStorageConfiguration(
storage_config_list=[
ObjectStorageConfig(
namespace=OS_NAMESPACE,
bucket_name=OS_BUCKET,
prefix_list=[OS_PREFIX] if OS_PREFIX else [],
)
]
),
schedule_config=ScheduleIntervalConfig(
config_type="INTERVAL",
frequency="HOURLY",
interval=1,
state="ENABLED",
# schedule the first run 10 minutes from now
time_start=datetime.now(timezone.utc) + timedelta(minutes=10),
),
)
print("")
print("Creating connector...")
response = client.create_vector_store_connector(create_connector_details)
connector = response.data
connector_id = connector.id
print(f"Connector Created: {connector_id} | State:{connector.lifecycle_state}")
print("")
if __name__ == "__main__":
main()