Skip to content

Commit ce262b4

Browse files
Alexander Garcell RoqueManiteja-Kurapati
authored andcommitted
Added - Support for Project Flash
1 parent 6675188 commit ce262b4

28 files changed

+1983
-416
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ vendor/github.com/oracle/oci-go-sdk/target
2828
internal/record
2929
.terraform.lock.hcl
3030
dist/
31-
internal/integrationtest/output
31+
internal/integrationtest/output
32+
/vendor/

examples/generative_ai/endpoint.tf

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
resource "oci_generative_ai_endpoint" "test_endpoint" {
2+
depends_on = [oci_generative_ai_dedicated_ai_cluster.test_hosting_cluster,oci_generative_ai_model.llama3_test_model]
23
#Required
34
compartment_id = var.compartment_ocid
45
dedicated_ai_cluster_id = data.oci_generative_ai_dedicated_ai_cluster.test_hosting_cluster.id
@@ -24,17 +25,17 @@ data "oci_generative_ai_endpoints" "test_endpoints" {
2425
locals {
2526
filtered_serving_models = [
2627
for item in data.oci_generative_ai_models.serving_models.model_collection[0].items : item
27-
if (
28-
(item.version == "14.2")
29-
&& length(item.capabilities) == 1
30-
&& (item.display_name == "cohere.command-light")
31-
)
32-
]
28+
if (
29+
(item.version == "1.0")
30+
&& length(item.capabilities) == 1
31+
&& (item.display_name == "cohere.command-a-03-2025")
32+
)
33+
]
3334

3435
servering_model_id = local.filtered_serving_models[0].id
3536
}
3637

3738
data "oci_generative_ai_models" "serving_models" {
3839
compartment_id = var.compartment_ocid
39-
display_name = "cohere.command-light"
40+
display_name = "cohere.command-a-03-2025"
4041
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
resource "oci_generative_ai_imported_model" "test_imported_model" {
2+
#Required
3+
compartment_id = var.compartment_ocid
4+
data_source {
5+
#Optional
6+
access_token = var.hf_access_token
7+
model_id = var.imported_model_model_id
8+
source_type = var.imported_model_data_source_source_type
9+
}
10+
11+
#Optional
12+
capabilities = var.imported_model_capabilities
13+
description = var.imported_model_description
14+
display_name = var.imported_model_display_name
15+
freeform_tags = var.imported_model_freeform_tags
16+
vendor = var.imported_model_vendor
17+
version = var.imported_model_version
18+
}
19+
20+
data "oci_generative_ai_imported_models" "test_imported_models" {
21+
#Required
22+
compartment_id = var.compartment_ocid
23+
24+
#Optional
25+
capability = var.imported_model_capability
26+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
provider "oci" {
2+
auth = "SecurityToken"
3+
config_file_profile = var.config_file_profile
4+
region = var.region
5+
}
6+
7+
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
variable "compartment_ocid" {}
2+
3+
variable "region" {}
4+
5+
variable config_file_profile {}
6+
7+
variable "imported_model_capabilities" {
8+
default = ["TEXT_TO_TEXT"]
9+
}
10+
11+
variable "imported_model_capability" {
12+
default = ["TEXT_TO_TEXT"]
13+
}
14+
15+
variable "hf_access_token" {
16+
type = string
17+
}
18+
19+
variable "imported_model_data_source_source_type" {
20+
default = "HUGGING_FACE_MODEL"
21+
}
22+
23+
variable "imported_model_description" {
24+
default = "description"
25+
}
26+
27+
variable "imported_model_display_name" {
28+
default = "displayName"
29+
}
30+
31+
variable "imported_model_freeform_tags" {
32+
default = { "Department" = "Finance" }
33+
}
34+
35+
variable "imported_model_model_id" {
36+
default = "google/gemma-3-12b-it"
37+
}
38+
39+
variable "imported_model_vendor" {
40+
default = "vendor"
41+
}
42+
43+
variable "imported_model_version" {
44+
default = "4.0"
45+
}
46+
47+

examples/generative_ai/model.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
resource "oci_generative_ai_model" "llama3_test_model" {
2+
depends_on = [oci_generative_ai_dedicated_ai_cluster.test_dedicated_ai_cluster_large_generic ]
23
#Required
34
compartment_id = var.compartment_ocid
45
base_model_id = local.llama_base_model_id

examples/generative_ai/provider.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ provider "oci" {
1515
auth = "SecurityToken"
1616
config_file_profile = var.config_file_profile
1717
region = var.region
18-
}
18+
}
1919

2020

examples/generative_ai/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ variable "hosting_cluster_description" {
1010
}
1111

1212
variable "hosting_cluster_shape" {
13-
default = "SMALL_COHERE"
13+
default = "LARGE_COHERE_V3"
1414
}
1515

1616
variable "hosting_cluster_unit_count" {
@@ -66,7 +66,7 @@ variable "test_model_vendor" {
6666
}
6767

6868
variable "test_model_version" {
69-
default = "1.1"
69+
default = "1.3"
7070
}
7171

7272
variable "test_freeform_tags" {

internal/integrationtest/generative_ai_dedicated_ai_cluster_test.go

Lines changed: 35 additions & 50 deletions
Large diffs are not rendered by default.

internal/integrationtest/generative_ai_endpoint_test.go

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,33 @@ var (
5151
"dedicated_ai_cluster_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_generative_ai_dedicated_ai_cluster.test_dedicated_ai_cluster.id}`},
5252
"model_id": acctest.Representation{RepType: acctest.Required, Create: `${local.servering_model_id}`},
5353
"content_moderation_config": acctest.RepresentationGroup{RepType: acctest.Optional, Group: GenerativeAiEndpointContentModerationConfigRepresentation},
54-
// "defined_tags": acctest.Representation{RepType: acctest.Optional, Create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, Update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
54+
//"defined_tags": acctest.Representation{RepType: acctest.Optional, Create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, Update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
5555
"description": acctest.Representation{RepType: acctest.Optional, Create: `description`, Update: `description2`},
5656
"display_name": acctest.Representation{RepType: acctest.Optional, Create: `displayName`, Update: `displayName2`},
5757
"freeform_tags": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{"Department": "Finance"}, Update: map[string]string{"Department": "Accounting"}},
5858
}
5959
GenerativeAiEndpointContentModerationConfigRepresentation = map[string]interface{}{
60-
"is_enabled": acctest.Representation{RepType: acctest.Optional, Create: `false`, Update: `true`},
60+
"is_enabled": acctest.Representation{RepType: acctest.Required, Create: `false`, Update: `true`},
61+
"mode": acctest.Representation{RepType: acctest.Optional, Create: `INFORM`, Update: `BLOCK`},
62+
"model_id": acctest.Representation{RepType: acctest.Optional, Create: `${local.servering_model_id}`},
6163
}
6264

63-
GenerativeAiEndpointResourceDependencies = acctest.GenerateResourceFromRepresentationMap("oci_generative_ai_dedicated_ai_cluster", "test_dedicated_ai_cluster", acctest.Required, acctest.Create, GenerativeAiHostingDedicatedAiClusterRepresentation) +
65+
GenerativeAiEndpointResourceDependencies = acctest.GenerateResourceFromRepresentationMap("oci_generative_ai_dedicated_ai_cluster", "test_dedicated_ai_cluster", acctest.Required, acctest.Create, DedicatedAiClusterRepresentation) +
6466
servingModelDependencies
6567
// DefinedTagsDependencies + - no test in home region
6668

69+
DedicatedAiClusterRepresentation = map[string]interface{}{
70+
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
71+
"type": acctest.Representation{RepType: acctest.Required, Create: `HOSTING`},
72+
"unit_count": acctest.Representation{RepType: acctest.Required, Create: `1`, Update: `2`},
73+
"unit_shape": acctest.Representation{RepType: acctest.Required, Create: `LARGE_COHERE_V3`},
74+
"defined_tags": acctest.Representation{RepType: acctest.Optional, Create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, Update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
75+
"description": acctest.Representation{RepType: acctest.Optional, Create: `description`, Update: `description2`},
76+
"display_name": acctest.Representation{RepType: acctest.Optional, Create: `displayName`, Update: `displayName2`},
77+
"freeform_tags": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{"Department": "Finance"}, Update: map[string]string{"Department": "Accounting"}},
78+
"lifecycle": acctest.RepresentationGroup{RepType: acctest.Required, Group: generativeaiDatasetIgnoreDefinedTagsChangesRep},
79+
}
80+
6781
servingModelDependencies = `
6882
locals {
6983
@@ -84,6 +98,17 @@ var (
8498
display_name = "cohere.command-a-03-2025"
8599
}
86100
`
101+
102+
GenerativeAiEndpointModelRepresentation = map[string]interface{}{
103+
"base_model_id": acctest.Representation{RepType: acctest.Required, Create: `${local.servering_model_id}`},
104+
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
105+
//"defined_tags": acctest.Representation{RepType: acctest.Optional, Create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, Update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
106+
"description": acctest.Representation{RepType: acctest.Optional, Create: `description`, Update: `description2`},
107+
"display_name": acctest.Representation{RepType: acctest.Optional, Create: `displayName`, Update: `displayName2`},
108+
"freeform_tags": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{"Department": "Finance"}, Update: map[string]string{"Department": "Accounting"}},
109+
"vendor": acctest.Representation{RepType: acctest.Optional, Create: `vendor`},
110+
"version": acctest.Representation{RepType: acctest.Optional, Create: generativeAiVersion, Update: generativeAiVersion2},
111+
}
87112
)
88113

89114
// issue-routing-tag: generative_ai/default
@@ -137,6 +162,8 @@ func TestGenerativeAiEndpointResource_basic(t *testing.T) {
137162
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
138163
resource.TestCheckResourceAttr(resourceName, "content_moderation_config.#", "1"),
139164
resource.TestCheckResourceAttr(resourceName, "content_moderation_config.0.is_enabled", "false"),
165+
resource.TestCheckResourceAttr(resourceName, "content_moderation_config.0.mode", "INFORM"),
166+
resource.TestCheckResourceAttrSet(resourceName, "content_moderation_config.0.model_id"),
140167
resource.TestCheckResourceAttrSet(resourceName, "dedicated_ai_cluster_id"),
141168
resource.TestCheckResourceAttr(resourceName, "description", "description"),
142169
resource.TestCheckResourceAttr(resourceName, "display_name", "displayName"),
@@ -169,6 +196,8 @@ func TestGenerativeAiEndpointResource_basic(t *testing.T) {
169196
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentIdU),
170197
resource.TestCheckResourceAttr(resourceName, "content_moderation_config.#", "1"),
171198
resource.TestCheckResourceAttr(resourceName, "content_moderation_config.0.is_enabled", "false"),
199+
resource.TestCheckResourceAttr(resourceName, "content_moderation_config.0.mode", "INFORM"),
200+
resource.TestCheckResourceAttrSet(resourceName, "content_moderation_config.0.model_id"),
172201
resource.TestCheckResourceAttrSet(resourceName, "dedicated_ai_cluster_id"),
173202
resource.TestCheckResourceAttr(resourceName, "description", "description"),
174203
resource.TestCheckResourceAttr(resourceName, "display_name", "displayName"),
@@ -196,6 +225,8 @@ func TestGenerativeAiEndpointResource_basic(t *testing.T) {
196225
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
197226
resource.TestCheckResourceAttr(resourceName, "content_moderation_config.#", "1"),
198227
resource.TestCheckResourceAttr(resourceName, "content_moderation_config.0.is_enabled", "true"),
228+
resource.TestCheckResourceAttr(resourceName, "content_moderation_config.0.mode", "BLOCK"),
229+
resource.TestCheckResourceAttrSet(resourceName, "content_moderation_config.0.model_id"),
199230
resource.TestCheckResourceAttrSet(resourceName, "dedicated_ai_cluster_id"),
200231
resource.TestCheckResourceAttr(resourceName, "description", "description2"),
201232
resource.TestCheckResourceAttr(resourceName, "display_name", "displayName2"),
@@ -237,9 +268,10 @@ func TestGenerativeAiEndpointResource_basic(t *testing.T) {
237268
compartmentIdVariableStr + GenerativeAiEndpointResourceConfig,
238269
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
239270
resource.TestCheckResourceAttrSet(singularDatasourceName, "endpoint_id"),
240-
resource.TestCheckResourceAttr(singularDatasourceName, "compartment_id", compartmentId),
271+
241272
resource.TestCheckResourceAttr(singularDatasourceName, "content_moderation_config.#", "1"),
242273
resource.TestCheckResourceAttr(singularDatasourceName, "content_moderation_config.0.is_enabled", "true"),
274+
resource.TestCheckResourceAttr(singularDatasourceName, "content_moderation_config.0.mode", "BLOCK"),
243275
resource.TestCheckResourceAttr(singularDatasourceName, "description", "description2"),
244276
resource.TestCheckResourceAttr(singularDatasourceName, "display_name", "displayName2"),
245277
resource.TestCheckResourceAttr(singularDatasourceName, "freeform_tags.%", "1"),
@@ -251,11 +283,14 @@ func TestGenerativeAiEndpointResource_basic(t *testing.T) {
251283
},
252284
// verify resource import
253285
{
254-
Config: config + GenerativeAiEndpointRequiredOnlyResource,
255-
ImportState: true,
256-
ImportStateVerify: true,
257-
ImportStateVerifyIgnore: []string{},
258-
ResourceName: resourceName,
286+
Config: config + GenerativeAiEndpointRequiredOnlyResource,
287+
ImportState: true,
288+
ImportStateVerify: true,
289+
ImportStateVerifyIgnore: []string{
290+
"compartment_id",
291+
"previous_state",
292+
},
293+
ResourceName: resourceName,
259294
},
260295
})
261296
}
@@ -364,7 +399,7 @@ func getGenerativeAiEndpointIds(compartment string) ([]string, error) {
364399
}
365400

366401
func GenerativeAiEndpointSweepWaitCondition(response common.OCIOperationResponse) bool {
367-
// Only stop if the resource is ACTIVE beyond 3 mins. As there could be an issue for the sweeper to delete the resource and manual intervention required.
402+
// Only stop if the resource is active beyond 3 mins. As there could be an issue for the sweeper to delete the resource and manual intervention required.
368403
if endpointResponse, ok := response.Response.(oci_generative_ai.GetEndpointResponse); ok {
369404
return endpointResponse.LifecycleState != oci_generative_ai.EndpointLifecycleStateDeleted
370405
}

0 commit comments

Comments
 (0)