Skip to content

Commit 0736612

Browse files
Sangeeta SahaMaxrovr
authored andcommitted
Added - Support for Rel 2.0 Enhancement: Oracle Cloud AI Services Document Understanding
1 parent 0ce604e commit 0736612

20 files changed

+1210
-203
lines changed

examples/aiDocument/main.tf

Lines changed: 61 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
provider "oci" {
2+
# version = "6.21.0"
23
}
34

45
variable "tenancy_ocid" {
5-
default = "ocid1.tenancy.oc1..aaaaaaaaikox5b3adi2w237m2fwomzxybp52i7byjrj5fxradayjqxum7bsq"
6+
default = ""
67
}
78

89
variable "region" {
910
default = "us-phoenix-1"
1011
}
1112

1213
variable "model_model_version" {
13-
default = "modelVersion"
14+
default = "V1.0"
1415
}
1516

16-
variable "compartment_id" { default = "ocid1.compartment.oc1..aaaaaaaa3jewat7ub6yf257bsxvfcfz5zt46fruduji37ekbsefwmcmzvgxq" }
17+
variable "compartment_id" { default = "" }
1718

1819
variable defined_tag_namespace_name { default = "" }
1920

@@ -22,17 +23,19 @@ resource "oci_ai_document_project" "test_project" {
2223
compartment_id = var.compartment_id
2324
}
2425

25-
resource "oci_ai_document_model" "test_model1" {
26+
resource "oci_ai_document_model" "test_model" {
2627
#Required
2728
compartment_id = var.compartment_id
2829
model_type = "KEY_VALUE_EXTRACTION"
2930
project_id = oci_ai_document_project.test_project.id
31+
inference_units = 1
32+
language = "ENG"
3033

3134
training_dataset {
32-
bucket = "tf_test_bucket"
35+
bucket = "canary_test"
3336
dataset_type = "OBJECT_STORAGE"
34-
namespace = "axgexwaxnm7k"
35-
object = "tf_test_dataset_1680065500556.jsonl"
37+
namespace = "axylfvgphoea"
38+
object = "canary-aadhar-dataset_1686632830312.jsonl"
3639
}
3740

3841
#Optional
@@ -41,41 +44,61 @@ resource "oci_ai_document_model" "test_model1" {
4144
model_version = var.model_model_version
4245
}
4346

44-
resource "oci_ai_document_model" "test_model2" {
45-
#Required
46-
compartment_id = var.compartment_id
47-
model_type = "KEY_VALUE_EXTRACTION"
48-
project_id = oci_ai_document_project.test_project.id
47+
variable "object_locations" {
48+
type = list(map(string))
49+
default = [
50+
{
51+
bucket = "canary_test"
52+
namespace = "axylfvgphoea"
53+
object = "dus_test.pdf"
54+
}
55+
]
56+
}
4957

50-
training_dataset {
51-
bucket = "tf_test_bucket"
52-
dataset_type = "OBJECT_STORAGE"
53-
namespace = "axgexwaxnm7k"
54-
object = "tf_test_aadhar_1686719828190.jsonl"
55-
}
5658

57-
#Optional
58-
display_name = "test_tf_model2"
59-
is_quick_mode = "false"
60-
model_version = var.model_model_version
59+
variable "features" {
60+
type = list(map(string))
61+
default = [
62+
{
63+
feature_type = "KEY_VALUE_EXTRACTION"
64+
selection_mark_detection = false
65+
}
66+
]
6167
}
6268

63-
resource "oci_ai_document_model" "test_compose_model" {
64-
#Required
69+
resource "oci_ai_document_processor_job" "test_processor_job" {
6570
compartment_id = var.compartment_id
66-
model_type = "KEY_VALUE_EXTRACTION"
67-
project_id = oci_ai_document_project.test_project.id
68-
69-
component_models {
70-
model_id = oci_ai_document_model.test_model1.id
71+
display_name = "test_tf_processor_job"
72+
input_location {
73+
74+
dynamic "object_locations" {
75+
for_each = var.object_locations
76+
content {
77+
bucket = object_locations.value["bucket"]
78+
namespace = object_locations.value["namespace"]
79+
object = object_locations.value["object"]
80+
}
81+
}
82+
83+
source_type = "OBJECT_STORAGE_LOCATIONS"
7184
}
72-
73-
component_models {
74-
model_id = oci_ai_document_model.test_model2.id
85+
output_location {
86+
bucket = "canary_test"
87+
namespace = "axylfvgphoea"
88+
prefix = "test"
7589
}
76-
77-
#Optional
78-
display_name = "test_compose_model"
79-
is_quick_mode = "false"
80-
model_version = var.model_model_version
81-
}
90+
processor_config {
91+
92+
dynamic "features" {
93+
for_each = var.features
94+
content {
95+
feature_type = features.value["feature_type"]
96+
selection_mark_detection = features.value["selection_mark_detection"]
97+
}
98+
}
99+
100+
processor_type = "GENERAL"
101+
document_type = "INVOICE"
102+
language = "ENG"
103+
}
104+
}

internal/integrationtest/ai_document_model_test.go

Lines changed: 103 additions & 55 deletions
Large diffs are not rendered by default.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
package integrationtest
5+
6+
import (
7+
"fmt"
8+
"testing"
9+
10+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
11+
12+
"github.com/oracle/terraform-provider-oci/httpreplay"
13+
"github.com/oracle/terraform-provider-oci/internal/acctest"
14+
15+
"github.com/oracle/terraform-provider-oci/internal/utils"
16+
)
17+
18+
var (
19+
AiDocumentModelTypeSingularDataSourceRepresentation = map[string]interface{}{
20+
"model_type": acctest.Representation{RepType: acctest.Required, Create: `PRE_TRAINED_DOCUMENT_CLASSIFICATION`},
21+
"model_sub_type": acctest.Representation{RepType: acctest.Required, Create: `QR_BAR_CODE`},
22+
}
23+
24+
AiDocumentModelTypeResourceConfig = ""
25+
)
26+
27+
// issue-routing-tag: ai_document/default
28+
func TestAiDocumentModelTypeResource_basic(t *testing.T) {
29+
httpreplay.SetScenario("TestAiDocumentModelTypeResource_basic")
30+
defer httpreplay.SaveScenario()
31+
32+
config := acctest.ProviderTestConfig()
33+
34+
compartmentId := utils.GetEnvSettingWithBlankDefault("compartment_ocid")
35+
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId)
36+
37+
singularDatasourceName := "data.oci_ai_document_model_type.test_model_type"
38+
39+
acctest.SaveConfigContent("", "", "", t)
40+
41+
acctest.ResourceTest(t, nil, []resource.TestStep{
42+
// verify singular datasource
43+
{
44+
Config: config +
45+
acctest.GenerateDataSourceFromRepresentationMap("oci_ai_document_model_type", "test_model_type", acctest.Required, acctest.Create, AiDocumentModelTypeSingularDataSourceRepresentation) +
46+
compartmentIdVariableStr + AiDocumentModelTypeResourceConfig,
47+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
48+
resource.TestCheckResourceAttr(singularDatasourceName, "model_type", "PRE_TRAINED_DOCUMENT_CLASSIFICATION"),
49+
resource.TestCheckResourceAttr(singularDatasourceName, "model_sub_type", "QR_BAR_CODE"),
50+
resource.TestCheckResourceAttr(singularDatasourceName, "versions.#", "1"),
51+
resource.TestCheckResourceAttr(singularDatasourceName, "capabilities", "{\"V1.0\":{\"capability\":{\"description\":{\"details\":[\"document classification model\"]},\"supportedLanguages\":{\"details\":[\"en\"]},\"userDisplayedVersion\":{\"details\":[\"V1.0\"]}}}}"),
52+
),
53+
},
54+
})
55+
}

0 commit comments

Comments
 (0)