Skip to content

Commit a4b396b

Browse files
mosezzwMaxrovr
authored andcommitted
Added - Support for OCI Generative AI Agent - CY25 Q2 Release
1 parent 056b683 commit a4b396b

20 files changed

+1110
-127
lines changed

examples/generative_ai_agent/tools.tf

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,67 @@ resource "oci_generative_ai_agent_tool" "fc_test_tool" {
5555
tool_config_type = "FUNCTION_CALLING_TOOL_CONFIG"
5656
}
5757
}
58+
59+
resource "oci_generative_ai_agent_tool" "http_test_tool" {
60+
agent_id = var.test_agent_id
61+
compartment_id = var.compartment_ocid
62+
display_name = var.test_agent_tool_display_name
63+
description = var.test_agent_tool_description
64+
freeform_tags = {
65+
Department = "Finance"
66+
}
67+
tool_config {
68+
tool_config_type = "HTTP_ENDPOINT_TOOL_CONFIG"
69+
subnet_id = var.test_subnet_id
70+
api_schema {
71+
api_schema_input_location_type = "INLINE"
72+
content = <<EOF
73+
{
74+
"openapi": "3.0.0",
75+
"info": {
76+
"title": "Minimal API",
77+
"version": "1.0"
78+
},
79+
"servers": [
80+
{ "url": "https://example.com/api" }
81+
],
82+
"paths": {
83+
"/ping": {
84+
"get": {
85+
"summary": "Ping for health check",
86+
"responses": {
87+
"200": {
88+
"description": "OK"
89+
}
90+
}
91+
}
92+
}
93+
}
94+
}
95+
EOF
96+
}
97+
98+
http_endpoint_auth_config {
99+
http_endpoint_auth_sources {
100+
http_endpoint_auth_scope = "AGENT"
101+
http_endpoint_auth_scope_config {
102+
http_endpoint_auth_scope_config_type = "HTTP_ENDPOINT_NO_AUTH_SCOPE_CONFIG"
103+
}
104+
}
105+
}
106+
}
107+
}
108+
109+
resource "oci_generative_ai_agent_tool" "agent_test_tool" {
110+
agent_id = var.test_agent_id
111+
compartment_id = var.compartment_ocid
112+
display_name = var.test_agent_tool_display_name
113+
description = var.test_agent_tool_description
114+
freeform_tags = {
115+
Department = "Finance"
116+
}
117+
tool_config {
118+
tool_config_type = "AGENT_TOOL_CONFIG"
119+
agent_endpoint_id = var.test_agent_endpoint_id
120+
}
121+
}

examples/generative_ai_agent/variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ variable "test_namespace" {}
109109

110110
variable "test_prefix" {}
111111

112+
variable "test_subnet_id" {}
113+
114+
variable "test_agent_endpoint_id" {}
115+
112116
variable "agent_endpoint_guardrail_config_content_moderation_config_input_guardrail_mode" {
113117
default = "DISABLE"
114118
}

internal/integrationtest/generative_ai_agent_data_ingestion_job_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ func TestGenerativeAiAgentDataIngestionJobResource_basic(t *testing.T) {
102102
acctest.GenerateResourceFromRepresentationMap("oci_generative_ai_agent_data_ingestion_job", "test_data_ingestion_job", acctest.Optional, acctest.Create, GenerativeAiAgentDataIngestionJobRepresentation),
103103
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
104104
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
105+
resource.TestCheckResourceAttr(resourceName, "data_ingestion_job_type.#", "1"),
105106
resource.TestCheckResourceAttr(resourceName, "data_ingestion_job_statistics.#", "1"),
106107
resource.TestCheckResourceAttrSet(resourceName, "data_source_id"),
107108
resource.TestCheckResourceAttr(resourceName, "description", "description"),
@@ -131,6 +132,7 @@ func TestGenerativeAiAgentDataIngestionJobResource_basic(t *testing.T) {
131132
acctest.GenerateResourceFromRepresentationMap("oci_generative_ai_agent_data_ingestion_job", "test_data_ingestion_job", acctest.Optional, acctest.Update, GenerativeAiAgentDataIngestionJobRepresentation),
132133
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
133134
resource.TestCheckResourceAttr(datasourceName, "compartment_id", compartmentId),
135+
resource.TestCheckResourceAttr(resourceName, "data_ingestion_job_type.#", "1"),
134136
resource.TestCheckResourceAttrSet(datasourceName, "data_source_id"),
135137
resource.TestCheckResourceAttr(datasourceName, "display_name", "displayName"),
136138
resource.TestCheckResourceAttr(datasourceName, "state", "SUCCEEDED"),
@@ -148,6 +150,7 @@ func TestGenerativeAiAgentDataIngestionJobResource_basic(t *testing.T) {
148150
resource.TestCheckResourceAttrSet(singularDatasourceName, "data_ingestion_job_id"),
149151

150152
resource.TestCheckResourceAttr(singularDatasourceName, "compartment_id", compartmentId),
153+
resource.TestCheckResourceAttr(singularDatasourceName, "data_ingestion_job_type.#", "1"),
151154
resource.TestCheckResourceAttr(singularDatasourceName, "data_ingestion_job_statistics.#", "1"),
152155
resource.TestCheckResourceAttr(singularDatasourceName, "description", "description"),
153156
resource.TestCheckResourceAttr(singularDatasourceName, "display_name", "displayName"),

internal/integrationtest/generative_ai_agent_tool_test.go

Lines changed: 316 additions & 0 deletions
Large diffs are not rendered by default.

internal/service/generative_ai_agent/generative_ai_agent_data_ingestion_job_data_source.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ func (s *GenerativeAiAgentDataIngestionJobDataSourceCrud) SetData() error {
7676
s.D.Set("data_ingestion_job_statistics", nil)
7777
}
7878

79+
if s.Res.DataIngestionJobType != nil {
80+
s.D.Set("data_ingestion_job_type", []interface{}{DataIngestionJobTypeToMap(s.Res.DataIngestionJobType)})
81+
} else {
82+
s.D.Set("data_ingestion_job_type", nil)
83+
}
84+
7985
if s.Res.DataSourceId != nil {
8086
s.D.Set("data_source_id", *s.Res.DataSourceId)
8187
}

internal/service/generative_ai_agent/generative_ai_agent_data_ingestion_job_resource.go

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ func GenerativeAiAgentDataIngestionJobResource() *schema.Resource {
2626
State: schema.ImportStatePassthrough,
2727
},
2828
Timeouts: &schema.ResourceTimeout{
29-
Create: tfresource.GetTimeoutDuration("40m"),
30-
Update: tfresource.GetTimeoutDuration("20m"),
31-
Delete: tfresource.GetTimeoutDuration("20m"),
29+
Create: tfresource.GetTimeoutDuration("50m"),
30+
Update: tfresource.GetTimeoutDuration("30m"),
31+
Delete: tfresource.GetTimeoutDuration("30m"),
3232
},
3333
Create: createGenerativeAiAgentDataIngestionJob,
3434
Read: readGenerativeAiAgentDataIngestionJob,
@@ -94,13 +94,38 @@ func GenerativeAiAgentDataIngestionJobResource() *schema.Resource {
9494
Type: schema.TypeInt,
9595
Computed: true,
9696
},
97+
"number_of_ignored_files": {
98+
Type: schema.TypeInt,
99+
Computed: true,
100+
},
97101
"number_of_ingested_files": {
98102
Type: schema.TypeInt,
99103
Computed: true,
100104
},
101105
},
102106
},
103107
},
108+
"data_ingestion_job_type": {
109+
Type: schema.TypeList,
110+
Computed: true,
111+
Elem: &schema.Resource{
112+
Schema: map[string]*schema.Schema{
113+
// Required
114+
115+
// Optional
116+
117+
// Computed
118+
"type": {
119+
Type: schema.TypeString,
120+
Computed: true,
121+
},
122+
},
123+
},
124+
},
125+
"knowledge_base_id": {
126+
Type: schema.TypeString,
127+
Computed: true,
128+
},
104129
"lifecycle_details": {
105130
Type: schema.TypeString,
106131
Computed: true,
@@ -412,6 +437,12 @@ func (s *GenerativeAiAgentDataIngestionJobResourceCrud) SetData() error {
412437
s.D.Set("data_ingestion_job_statistics", nil)
413438
}
414439

440+
if s.Res.DataIngestionJobType != nil {
441+
s.D.Set("data_ingestion_job_type", []interface{}{DataIngestionJobTypeToMap(s.Res.DataIngestionJobType)})
442+
} else {
443+
s.D.Set("data_ingestion_job_type", nil)
444+
}
445+
415446
if s.Res.DataSourceId != nil {
416447
s.D.Set("data_source_id", *s.Res.DataSourceId)
417448
}
@@ -430,6 +461,10 @@ func (s *GenerativeAiAgentDataIngestionJobResourceCrud) SetData() error {
430461

431462
s.D.Set("freeform_tags", s.Res.FreeformTags)
432463

464+
if s.Res.KnowledgeBaseId != nil {
465+
s.D.Set("knowledge_base_id", *s.Res.KnowledgeBaseId)
466+
}
467+
433468
if s.Res.LifecycleDetails != nil {
434469
s.D.Set("lifecycle_details", *s.Res.LifecycleDetails)
435470
}
@@ -462,6 +497,10 @@ func DataIngestionJobStatisticsToMap(obj *oci_generative_ai_agent.DataIngestionJ
462497
result["number_of_failed_files"] = int(*obj.NumberOfFailedFiles)
463498
}
464499

500+
if obj.NumberOfIgnoredFiles != nil {
501+
result["number_of_ignored_files"] = int(*obj.NumberOfIgnoredFiles)
502+
}
503+
465504
if obj.NumberOfIngestedFiles != nil {
466505
result["number_of_ingested_files"] = int(*obj.NumberOfIngestedFiles)
467506
}
@@ -476,6 +515,14 @@ func DataIngestionJobSummaryToMap(obj oci_generative_ai_agent.DataIngestionJobSu
476515
result["compartment_id"] = string(*obj.CompartmentId)
477516
}
478517

518+
if obj.DataIngestionJobStatistics != nil {
519+
result["data_ingestion_job_statistics"] = []interface{}{DataIngestionJobStatisticsToMap(obj.DataIngestionJobStatistics)}
520+
}
521+
522+
if obj.DataIngestionJobType != nil {
523+
result["data_ingestion_job_type"] = []interface{}{DataIngestionJobTypeToMap(obj.DataIngestionJobType)}
524+
}
525+
479526
if obj.DataSourceId != nil {
480527
result["data_source_id"] = string(*obj.DataSourceId)
481528
}
@@ -518,3 +565,11 @@ func DataIngestionJobSummaryToMap(obj oci_generative_ai_agent.DataIngestionJobSu
518565

519566
return result
520567
}
568+
569+
func DataIngestionJobTypeToMap(obj *oci_generative_ai_agent.DataIngestionJobType) map[string]interface{} {
570+
result := map[string]interface{}{}
571+
572+
result["type"] = string(obj.Type)
573+
574+
return result
575+
}

internal/service/generative_ai_agent/generative_ai_agent_knowledge_base_resource.go

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"context"
88
"fmt"
99
"log"
10+
"strconv"
1011
"strings"
1112
"time"
1213

@@ -27,9 +28,9 @@ func GenerativeAiAgentKnowledgeBaseResource() *schema.Resource {
2728
State: schema.ImportStatePassthrough,
2829
},
2930
Timeouts: &schema.ResourceTimeout{
30-
Create: tfresource.GetTimeoutDuration("50m"),
31-
Update: tfresource.GetTimeoutDuration("20m"),
32-
Delete: tfresource.GetTimeoutDuration("20m"),
31+
Create: tfresource.GetTimeoutDuration("60m"),
32+
Update: tfresource.GetTimeoutDuration("30m"),
33+
Delete: tfresource.GetTimeoutDuration("30m"),
3334
},
3435
Create: createGenerativeAiAgentKnowledgeBase,
3536
Read: readGenerativeAiAgentKnowledgeBase,
@@ -249,6 +250,22 @@ func GenerativeAiAgentKnowledgeBaseResource() *schema.Resource {
249250
},
250251

251252
// Computed
253+
"knowledge_base_statistics": {
254+
Type: schema.TypeList,
255+
Computed: true,
256+
Elem: &schema.Resource{
257+
Schema: map[string]*schema.Schema{
258+
"size_in_bytes": {
259+
Type: schema.TypeString,
260+
Computed: true,
261+
},
262+
"total_ingested_files": {
263+
Type: schema.TypeString,
264+
Computed: true,
265+
},
266+
},
267+
},
268+
},
252269
"lifecycle_details": {
253270
Type: schema.TypeString,
254271
Computed: true,
@@ -660,6 +677,12 @@ func (s *GenerativeAiAgentKnowledgeBaseResourceCrud) SetData() error {
660677
s.D.Set("index_config", nil)
661678
}
662679

680+
if s.Res.KnowledgeBaseStatistics != nil {
681+
s.D.Set("knowledge_base_statistics", []interface{}{KnowledgeBaseStatisticsToMap(s.Res.KnowledgeBaseStatistics)})
682+
} else {
683+
s.D.Set("knowledge_base_statistics", nil)
684+
}
685+
663686
if s.Res.LifecycleDetails != nil {
664687
s.D.Set("lifecycle_details", *s.Res.LifecycleDetails)
665688
}
@@ -966,6 +989,20 @@ func IndexSchemaToMap(obj *oci_generative_ai_agent.IndexSchema) map[string]inter
966989
return result
967990
}
968991

992+
func KnowledgeBaseStatisticsToMap(obj *oci_generative_ai_agent.KnowledgeBaseStatistics) map[string]interface{} {
993+
result := map[string]interface{}{}
994+
995+
if obj.SizeInBytes != nil {
996+
result["size_in_bytes"] = strconv.FormatInt(*obj.SizeInBytes, 10)
997+
}
998+
999+
if obj.TotalIngestedFiles != nil {
1000+
result["total_ingested_files"] = strconv.FormatInt(*obj.TotalIngestedFiles, 10)
1001+
}
1002+
1003+
return result
1004+
}
1005+
9691006
func KnowledgeBaseSummaryToMap(obj oci_generative_ai_agent.KnowledgeBaseSummary) map[string]interface{} {
9701007
result := map[string]interface{}{}
9711008

0 commit comments

Comments
 (0)