RAG 엔진 API

Vertex AI RAG Engine은 검색 증강 생성(RAG)을 용이하게 하는 Vertex AI 플랫폼의 구성요소입니다. RAG Engine을 사용하면 대규모 언어 모델(LLM)이 문서 및 데이터베이스와 같은 외부 지식 소스의 데이터에 액세스하고 이를 통합할 수 있습니다. RAG를 사용하면 LLM이 더 정확하고 유익한 LLM 응답을 생성할 수 있습니다.

파라미터 목록

이 섹션에는 다음이 나열되어 있습니다.

Parameters 예시
코퍼스 관리 매개변수를 참조하세요. 코퍼스 관리 예시를 참조하세요.
파일 관리 매개변수를 참조하세요. 파일 관리 예시를 참조하세요.
프로젝트 관리 매개변수를 참고하세요. 프로젝트 관리 예시를 참고하세요.

코퍼스 관리 파라미터

RAG 코퍼스에 관한 자세한 내용은 코퍼스 관리를 참조하세요.

RAG 코퍼스 만들기

이 표에는 RAG 코퍼스를 만드는 데 사용되는 파라미터가 나열되어 있습니다.

본문 요청
매개변수

corpus_type_config

선택사항: 변경 불가

RagCorpus.CorpusTypeConfig

코퍼스 유형을 지정하는 구성입니다.

display_name

필수: string

RAG 코퍼스의 표시 이름입니다.

description

선택사항: string

RAG 코퍼스에 대한 설명입니다.

encryption_spec

(선택사항) 변경 불가: string

CMEK 키 이름은 RAG 말뭉치와 관련된 저장 데이터를 암호화하는 데 사용됩니다. 키 이름은 벡터 데이터베이스의 RagManaged 옵션에만 적용됩니다. 코퍼스가 생성되면 이 필드를 설정할 수 있으며 업데이트하거나 삭제할 수 없습니다.

형식: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{key_name}

vector_db_config

(선택사항) 변경 불가: RagVectorDbConfig

벡터 데이터베이스의 구성입니다.

vertex_ai_search_config.serving_config

선택사항: string

Vertex AI Search의 구성입니다.

형식: projects/{project}/locations/{location}/collections/{collection}/engines/{engine}/servingConfigs/{serving_config} 또는 projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/servingConfigs/{serving_config}

CorpusTypeConfig
매개변수

document_corpus

oneof RagCorpus.CorpusTypeConfig.DocumentCorpus

일반적인 문서 기반 RAG 코퍼스를 나타내는 corpus_type_config의 기본값입니다.

memory_corpus

oneof RagCorpus.CorpusTypeConfig.MemoryCorpus

이 유형을 설정하면 RAG 코퍼스가 Gemini Live API에서 메모리 저장소로 사용할 수 있는 MemoryCorpus가 됩니다.

자세한 내용은 Vertex AI RAG Engine을 메모리 저장소로 사용을 참고하세요.

memory_corpus.llm_parser

oneof RagFileParsingConfig.LlmParser

Gemini Live API에서 세션 컨텍스트를 파싱하고 저장하는 데 사용되는 LLM 파서입니다. 색인 생성을 위해 메모리를 빌드할 수 있습니다.

RagVectorDbConfig
매개변수

rag_managed_db

oneof vector_db: RagVectorDbConfig.RagManagedDb

벡터 데이터베이스를 지정하지 않으면 rag_managed_db가 기본 벡터 데이터베이스입니다.

rag_managed_db.knn

oneof retrieval_strategy: KNN

기본값입니다.

RAG 코퍼스의 모든 데이터 포인트를 비교하여 정확한 최근접 이웃을 찾습니다.

RAG 코퍼스를 만들 때 전략을 지정하지 않으면 KNN이 사용되는 기본 검색 전략입니다.

rag_managed_db.ann

oneof retrieval_strategy: ANN

tree_depth

트리의 레이어 또는 수준 수를 결정합니다.

RAG 코퍼스에 O(10K) RAG 파일이 있는 경우 이 값을 2로 설정합니다.
  • 레이어 또는 수준이 더 필요한 경우 이 값을 3으로 설정합니다.
  • 레이어 또는 수준 수가 지정되지 않은 경우 Vertex AI RAG 엔진은 이 매개변수에 기본값 2를 할당합니다.

leaf_count

트리 기반 구조의 리프 노드 수를 결정합니다.

  • 권장 값은 10 * sqrt(num of RAG files in your RAG corpus)입니다.
  • 지정하지 않으면 Vertex AI RAG Engine이 이 매개변수에 기본값 500을 할당합니다.

rebuild_ann_index

  • Vertex AI RAG Engine이 ANN 색인을 다시 빌드합니다.
  • ImportRagFiles API 요청에서 true로 설정합니다.
  • RAG 코퍼스를 쿼리하기 전에 ANN 색인을 한 번 다시 빌드해야 합니다.
  • 각 위치의 프로젝트에서 하나의 동시 색인 재빌드만 지원됩니다.

weaviate

oneof vector_db: RagVectorDbConfig.Weaviate

Weaviate 인스턴스를 지정합니다.

weaviate.http_endpoint

string

Weaviate 인스턴스의 HTTP 엔드포인트입니다.

이 값은 설정된 후에는 변경할 수 없습니다. CreateRagCorpus API 호출에서 비워 두고 후속 UpdateRagCorpus API 호출에서 비어 있지 않은 값으로 설정할 수 있습니다.

weaviate.collection_name

string

RAG 코퍼스가 매핑되는 Weaviate 컬렉션입니다.

이 값은 설정된 후에는 변경할 수 없습니다. CreateRagCorpus API 호출에서 비워 두고 후속 UpdateRagCorpus API 호출에서 비어 있지 않은 값으로 설정할 수 있습니다.

pinecone

oneof vector_db: RagVectorDbConfig.Pinecone

Pinecone 인스턴스를 지정합니다.

pinecone.index_name

string

RAG 코퍼스와 함께 사용되는 Pinecone 색인을 만드는 데 사용되는 이름입니다.

이 값은 설정된 후에는 변경할 수 없습니다. CreateRagCorpus API 호출에서 비워 두고 후속 UpdateRagCorpus API 호출에서 비어 있지 않은 값으로 설정할 수 있습니다.

vertex_feature_store

oneof vector_db: RagVectorDbConfig.VertexFeatureStore

Vertex AI Feature Store 인스턴스를 지정합니다.

vertex_feature_store.feature_view_resource_name

string

RAG 코퍼스가 매핑되는 Vertex AI Feature Store FeatureView입니다.

형식: projects/{project}/locations/{location}/featureOnlineStores/{feature_online_store}/featureViews/{feature_view}

이 값은 설정된 후에는 변경할 수 없습니다. CreateRagCorpus API 호출에서 비워 두고 후속 UpdateRagCorpus API 호출에서 비어 있지 않은 값으로 설정할 수 있습니다.

vertex_vector_search

oneof vector_db: RagVectorDbConfig.VertexVectorSearch

Vertex 벡터 검색 인스턴스를 지정합니다.

vertex_vector_search.index

string

RAG 코퍼스와 함께 사용되는 벡터 검색 색인의 리소스 이름입니다.

형식: projects/{project}/locations/{location}/indexEndpoints/{index_endpoint}

이 값은 설정된 후에는 변경할 수 없습니다. CreateRagCorpus API 호출에서 비워 두고 후속 UpdateRagCorpus API 호출에서 비어 있지 않은 값으로 설정할 수 있습니다.

vertex_vector_search.index_endpoint

string

RAG 코퍼스와 함께 사용되는 벡터 검색 색인 엔드포인트의 리소스 이름입니다.

형식: projects/{project}/locations/{location}/indexes/{index}

이 값은 설정된 후에는 변경할 수 없습니다. CreateRagCorpus API 호출에서 비워 두고 후속 UpdateRagCorpus API 호출에서 비어 있지 않은 값으로 설정할 수 있습니다.

api_auth.api_key_config.api_key_secret_version

string

Secret Manager에 저장된 보안 비밀의 전체 리소스 이름으로, 벡터 데이터베이스 선택에 따라 Weaviate 또는 Pinecone API 키가 포함되어 있습니다.

형식: projects/{PROJECT_NUMBER}/secrets/{SECRET_ID}/versions/{VERSION_ID}

CreateRagCorpus API 호출에서 비워 두고 후속 UpdateRagCorpus API 호출에서 비어 있지 않은 값으로 설정할 수 있습니다.

rag_embedding_model_config.vertex_prediction_endpoint.endpoint

(선택사항) 변경 불가: string

RAG 코퍼스에 사용할 임베딩 모델입니다. 이 값은 설정된 후에는 변경할 수 없습니다. 비워두면 text-embedding-005가 임베딩 모델로 사용됩니다.

RAG 코퍼스 업데이트

이 표에는 RAG 코퍼스를 업데이트 데 사용되는 파라미터가 나열되어 있습니다.

본문 요청
매개변수

display_name

선택사항: string

RAG 코퍼스의 표시 이름입니다.

description

선택사항: string

RAG 코퍼스에 대한 설명입니다.

rag_vector_db.weaviate.http_endpoint

string

Weaviate 인스턴스의 HTTP 엔드포인트입니다.

RagCorpusWeaviate 구성으로 생성되었고 이 필드가 이전에 설정된 적이 없는 경우 Weaviate 인스턴스의 HTTP 엔드포인트를 업데이트할 수 있습니다.

rag_vector_db.weaviate.collection_name

string

RAG 코퍼스가 매핑되는 Weaviate 컬렉션입니다.

RagCorpusWeaviate 구성으로 생성되었고 이 필드가 이전에 설정된 적이 없는 경우 Weaviate 인스턴스의 컬렉션 이름을 업데이트할 수 있습니다.

rag_vector_db.pinecone.index_name

string

RAG 코퍼스와 함께 사용되는 Pinecone 색인을 만드는 데 사용되는 이름입니다.

Pinecone 구성으로 RagCorpus를 만들었고 이 필드가 이전에 설정된 적이 없는 경우 Pinecone 인스턴스의 색인 이름을 업데이트할 수 있습니다.

rag_vector_db.vertex_feature_store.feature_view_resource_name

string

RAG 코퍼스가 매핑되는 Vertex AI Feature Store FeatureView입니다.

형식: projects/{project}/locations/{location}/featureOnlineStores/{feature_online_store}/featureViews/{feature_view}

RagCorpusVertex AI Feature Store 구성으로 생성되었고 이 필드가 이전에 설정된 적이 없는 경우 업데이트할 수 있습니다.

rag_vector_db.vertex_vector_search.index

string

RAG 코퍼스와 함께 사용되는 벡터 검색 색인의 리소스 이름입니다.

형식: projects/{project}/locations/{location}/indexEndpoints/{index_endpoint}

RagCorpusVector Search 구성으로 생성되었고 이 필드가 이전에 설정된 적이 없는 경우 업데이트할 수 있습니다.

rag_vector_db.vertex_vector_search.index_endpoint

string

RAG 코퍼스와 함께 사용되는 벡터 검색 색인 엔드포인트의 리소스 이름입니다.

형식: projects/{project}/locations/{location}/indexes/{index}

RagCorpusVector Search 구성으로 생성되었고 이 필드가 이전에 설정된 적이 없는 경우 업데이트할 수 있습니다.

rag_vector_db.api_auth.api_key_config.api_key_secret_version

string

Secret Manager에 저장된 보안 비밀의 전체 리소스 이름으로, 벡터 데이터베이스 선택에 따라 Weaviate 또는 Pinecone API 키가 포함되어 있습니다.

형식: projects/{PROJECT_NUMBER}/secrets/{SECRET_ID}/versions/{VERSION_ID}

RAG 코퍼스 목록

이 표에는 RAG 코퍼스를 나열하는 데 사용되는 파라미터가 나와 있습니다.

매개변수

page_size

선택사항: int

표준 목록 페이지 크기입니다.

page_token

선택사항: string

표준 목록 페이지 토큰입니다. 일반적으로 이전 [VertexRagDataService.ListRagCorpora][] 호출의 [ListRagCorporaResponse.next_page_token][]에서 가져옵니다.

RAG 코퍼스 가져오기

이 표에는 RAG 코퍼스를 가져오는 데 사용되는 파라미터가 나와 있습니다.

Parameters

name

string

RagCorpus 리소스 이름입니다. 형식: projects/{project}/locations/{location}/ragCorpora/{rag_corpus_id}

RAG 코퍼스 삭제

이 표에는 RAG 코퍼스를 삭제하는 데 사용되는 파라미터가 나와 있습니다.

매개변수

name

string

RagCorpus 리소스 이름입니다. 형식: projects/{project}/locations/{location}/ragCorpora/{rag_corpus_id}

파일 관리 파라미터

RAG 파일에 관한 자세한 내용은 파일 관리를 참고하세요.

RAG 파일 업로드

이 표에는 RAG 파일을 업로드하는 데 사용되는 파라미터가 나와 있습니다.

본문 요청
매개변수

parent

string

RagCorpus 리소스 이름입니다. 형식: projects/{project}/locations/{location}/ragCorpora/{rag_corpus_id}

rag_file

필수: RagFile

업로드할 파일입니다.

upload_rag_file_config

필수: UploadRagFileConfig

RagCorpus에 업로드할 RagFile의 구성입니다.

RagFile

display_name

필수: string

RAG 파일의 표시 이름입니다.

description

선택사항: string

RAG 파일에 대한 설명입니다.

UploadRagFileConfig

rag_file_transformation_config.rag_file_chunking_config.fixed_length_chunking.chunk_size

int32

각 청크가 보유한 토큰 수입니다.

rag_file_transformation_config.rag_file_chunking_config.fixed_length_chunking.chunk_overlap

int32

청크 간의 중복입니다.

RAG 파일 가져오기

이 표에는 RAG 파일을 가져오는 데 사용되는 파라미터가 나와 있습니다.

매개변수

parent

필수: string

RagCorpus 리소스 이름입니다.

형식: projects/{project}/locations/{location}/ragCorpora/{rag_corpus_id}

gcs_source

oneof import_source: GcsSource

Cloud Storage 위치

개별 파일뿐만 아니라 전체 Cloud Storage 디렉터리 가져오기를 지원합니다.

gcs_source.uris

list/string

업로드 파일이 포함된 Cloud Storage URI입니다.

google_drive_source

oneof import_source: GoogleDriveSource

Google Drive 위치

개별 파일과 Google Drive 폴더 가져오기를 지원합니다.

slack_source

oneof import_source: SlackSource

파일이 업로드된 Slack 채널입니다.

jira_source

oneof import_source: JiraSource

파일이 업로드된 Jira 쿼리입니다.

share_point_sources

oneof import_source: SharePointSources

파일이 업로드된 SharePoint 소스입니다.

rag_file_transformation_config.rag_file_chunking_config.fixed_length_chunking.chunk_size

int32

각 청크가 보유한 토큰 수입니다.

rag_file_transformation_config.rag_file_chunking_config.fixed_length_chunking.chunk_overlap

int32

청크 간의 중복입니다.

rag_file_parsing_config

(선택사항) RagFileParsingConfig

RagFiles의 파싱 구성을 지정합니다.

이 필드를 설정하지 않으면 RAG는 기본 파서를 사용합니다.

max_embedding_requests_per_min

(선택사항) int32

이 작업이 코퍼스에 지정된 임베딩 모델에 허용되는 분당 최대 쿼리 수입니다. 이 값은 이 작업에만 적용되며 다른 가져오기 작업과 공유되지 않습니다. 프로젝트의 할당량 페이지를 참고하여 적절한 값을 설정하세요.

지정하지 않으면 기본값인 1,000 QPM이 사용됩니다.

GoogleDriveSource

resource_ids.resource_id

필수: string

Google Drive 리소스의 ID입니다.

resource_ids.resource_type

필수: string

Google Drive 리소스 유형입니다.

SlackSource

channels.channels

반복: SlackSource.SlackChannels.SlackChannel

가져올 ID 및 시간 범위를 포함한 Slack 채널 정보

channels.channels.channel_id

필수: string

Slack 채널 ID입니다.

channels.channels.start_time

선택사항: google.protobuf.Timestamp

가져올 메시지의 시작 타임스탬프입니다.

channels.channels.end_time

선택사항: google.protobuf.Timestamp

가져올 메시지의 종료 타임스탬프입니다.

channels.api_key_config.api_key_secret_version

필수: string

Secret Manager에 저장된 보안 비밀의 전체 리소스 이름입니다. 여기에는 Slack 채널 ID에 액세스할 수 있는 Slack 채널 액세스 토큰이 포함됩니다.
참고: https://api.slack.com/tutorials/tracks/getting-a-token

형식: projects/{PROJECT_NUMBER}/secrets/{SECRET_ID}/versions/{VERSION_ID}

JiraSource

jira_queries.projects

반복: string

전체적으로 가져올 Jira 프로젝트 목록입니다.

jira_queries.custom_queries

반복: string

가져올 커스텀 Jira 쿼리 목록입니다. JQL(Jira 쿼리 언어)에 대한 자세한 내용은
Jira 지원을 참고하세요.

jira_queries.email

필수: string

Jira 이메일 주소입니다.

jira_queries.server_uri

필수: string

Jira 서버 URI입니다.

jira_queries.api_key_config.api_key_secret_version

필수: string

Secret Manager에 저장된 보안 비밀의 전체 리소스 이름입니다. 여기에는 Slack 채널 ID에 액세스할 수 있는 Jira API 키가 포함됩니다.
참고: https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/

형식: projects/{PROJECT_NUMBER}/secrets/{SECRET_ID}/versions/{VERSION_ID}

SharePointSources

share_point_sources.sharepoint_folder_path

folder_sourceoneof: string

다운로드할 SharePoint 폴더의 경로입니다.

share_point_sources.sharepoint_folder_id

folder_sourceoneof: string

다운로드할 SharePoint 폴더의 ID입니다.

share_point_sources.drive_name

drive_sourceoneof: string

다운로드할 드라이브의 이름입니다.

share_point_sources.drive_id

drive_sourceoneof: string

다운로드할 드라이브의 ID입니다.

share_point_sources.client_id

string

Microsoft Azure 포털에 등록된 앱의 애플리케이션 ID입니다.
애플리케이션은 MS Graph 권한 'Files.ReadAll', 'Sites.ReadAll', BrowserSiteLists.Read.All로도 구성해야 합니다.

share_point_sources.client_secret.api_key_secret_version

필수: string

Secret Manager에 저장된 보안 비밀의 전체 리소스 이름입니다. 여기에는 Azure에 등록된 앱의 애플리케이션 보안 비밀이 포함됩니다.

형식: projects/{PROJECT_NUMBER}/secrets/{SECRET_ID}/versions/{VERSION_ID}

share_point_sources.tenant_id

string

Azure Active Directory 인스턴스의 고유 식별자입니다.

share_point_sources.sharepoint_site_name

string

다운로드할 SharePoint 사이트의 이름입니다. 사이트 이름 또는 사이트 ID일 수 있습니다.

RagFileParsingConfig

layout_parser

oneof parser: RagFileParsingConfig.LayoutParser

RagFile에 사용할 레이아웃 파서입니다.

layout_parser.processor_name

string

Document AI 프로세서 또는 프로세서 버전의 전체 리소스 이름입니다.

형식:
projects/{project_id}/locations/{location}/processors/{processor_id}
projects/{project_id}/locations/{location}/processors/{processor_id}/processorVersions/{processor_version_id}

layout_parser.max_parsing_requests_per_min

string

작업이 Document AI 프로세서에 분당 요청할 수 있는 최대 요청 수입니다.

https://cloud.google.com/document-ai/quotas 및 프로젝트의 할당량 페이지를 참고하여 여기에 적절한 값을 설정하세요. 지정하지 않으면 기본값인 120 QPM이 사용됩니다.

llm_parser

oneof parser: RagFileParsingConfig.LlmParser

RagFile에 사용할 LLM 파서입니다.

llm_parser.model_name

string

LLM 모델의 리소스 이름입니다.

형식:
projects/{project_id}/locations/{location}/publishers/{publisher}/models/{model}

llm_parser.max_parsing_requests_per_min

string

작업이 분당 LLM 모델에 할 수 있는 최대 요청 수입니다.

프로젝트에 적합한 값을 설정하려면 모델 할당량 섹션과 프로젝트의 할당량 페이지를 참고하여 여기에 적합한 값을 설정하세요. 지정하지 않으면 기본값인 5, 000 QPM이 사용됩니다.

RAG 파일 받기

이 표에는 RAG 파일을 가져오는 데 사용되는 파라미터가 나와 있습니다.

매개변수

name

string

RagFile 리소스 이름입니다. 형식: projects/{project}/locations/{location}/ragCorpora/{rag_file_id}

RAG 파일 삭제

이 표에는 RAG 파일을 삭제하는 데 사용되는 파라미터가 나와 있습니다.

Parameters

name

string

RagFile 리소스 이름입니다. 형식: projects/{project}/locations/{location}/ragCorpora/{rag_file_id}

검색 및 예측 파라미터

이 섹션에는 검색 및 예측 파라미터가 나와 있습니다.

검색 파라미터

이 표에는 retrieveContexts API의 파라미터가 나와 있습니다.

매개변수

parent

필수: string

RagContexts를 검색할 위치의 리소스 이름입니다.
사용자에게 프로젝트에서 전화를 걸 수 있는 권한이 있어야 합니다.

형식: projects/{project}/locations/{location}

vertex_rag_store

VertexRagStore

Vertex RagStore의 데이터 소스입니다.

query

필수: RagQuery

단일 RAG 검색 쿼리입니다.

VertexRagStore
VertexRagStore

rag_resources

목록: RagResource

RAG 소스의 표현입니다. 코퍼스만 지정하거나 RagFile를 지정하는 데 사용할 수 있습니다. 하나의 코퍼스 또는 하나의 코퍼스에서 여러 파일만 지원합니다.

rag_resources.rag_corpus

선택사항: string

RagCorpora 리소스 이름입니다.

형식: projects/{project}/locations/{location}/ragCorpora/{rag_corpus}

rag_resources.rag_file_ids

목록: string

RagFile 리소스 목록입니다.

형식: projects/{project}/locations/{location}/ragCorpora/{rag_corpus}/ragFiles/{rag_file}

RagQuery

text

string

관련 컨텍스트를 가져올 텍스트 형식의 질문입니다.

rag_retrieval_config

선택사항: RagRetrievalConfig

질문의 검색 구성입니다.

RagRetrievalConfig

top_k

선택사항: int32

검색할 컨텍스트 수입니다.

hybrid_search.alpha

(선택사항) float

알파 값은 밀집 벡터 검색 결과와 희소 벡터 검색 결과 간의 가중치를 제어합니다. 범위는 [0, 1]입니다. 여기서 0은 희소 벡터 검색만, 1은 밀집 벡터 검색만을 의미합니다. 기본값은 0.5이며 희소 벡터 검색과 밀집 벡터 검색의 균형을 동일하게 맞춥니다.

하이브리드 검색은 Weaviate에서만 사용할 수 있습니다.

filter.vector_distance_threshold

oneof vector_db_threshold: double

벡터 거리가 기준점보다 작은 컨텍스트만 반환합니다.

filter.vector_similarity_threshold

oneof vector_db_threshold: double

벡터 유사성이 기준점보다 큰 컨텍스트만 반환합니다.

ranking.rank_service.model_name

(선택사항) string

순위 서비스의 모델 이름입니다.

예시: semantic-ranker-512@latest

ranking.llm_ranker.model_name

(선택사항) string

순위 지정에 사용되는 모델 이름입니다.

예시: gemini-2.5-flash

예측 파라미터

이 표에는 예측 파라미터가 나열됩니다.

GenerateContentRequest

tools.retrieval.vertex_rag_store

VertexRagStore

Vertex AI RAG 스토어에서 제공하는 데이터 소스를 사용하도록 설정합니다.

자세한 내용은 VertexRagStore를 참조하세요.

프로젝트 관리 매개변수

이 표에는 프로젝트 수준 매개변수가 나열되어 있습니다.

RagEngineConfig
매개변수
RagManagedDbConfig.scaled 이 등급은 자동 확장 기능과 함께 프로덕션 규모의 성능을 제공합니다.
RagManagedDbConfig.basic 이 등급은 비용 효율적이고 컴퓨팅 등급이 낮습니다.
RagManagedDbConfig.unprovisioned 이 등급은 RagManagedDb 및 기본 Spanner 인스턴스를 삭제합니다.

코퍼스 관리 예시

이 섹션에서는 API를 사용하여 RAG 코퍼스를 관리하는 방법의 예시를 제공합니다.

RAG 코퍼스 만들기 예시

이 코드 샘플은 RAG 코퍼스를 만드는 방법을 보여줍니다.

REST

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • PROJECT_ID: 프로젝트 ID
  • LOCATION: 요청을 처리하는 리전
  • CORPUS_DISPLAY_NAME: RagCorpus의 표시 이름
  • CORPUS_DESCRIPTION: RagCorpus에 대한 설명

HTTP 메서드 및 URL:

POST https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora

JSON 요청 본문:

{
  "display_name" : "CORPUS_DISPLAY_NAME",
  "description": "CORPUS_DESCRIPTION",
}

요청을 보내려면 다음 옵션 중 하나를 선택합니다.

curl

요청 본문을 request.json 파일에 저장하고 다음 명령어를 실행합니다.

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora"

PowerShell

요청 본문을 request.json 파일에 저장하고 다음 명령어를 실행합니다.

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora" | Select-Object -Expand Content
성공 상태 코드(2xx)를 받아야 합니다.

다음 예에서는 REST API를 사용하여 RAG 코퍼스를 만드는 방법을 보여줍니다.

  PROJECT_ID: Your project ID.
  LOCATION: The region to process the request.
  CORPUS_DISPLAY_NAME: The display name of the <code>RagCorpus</code>.
    // CreateRagCorpus
    // Input: LOCATION, PROJECT_ID, CORPUS_DISPLAY_NAME
    // Output: CreateRagCorpusOperationMetadata
    curl -X POST \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    -H "Content-Type: application/json" \
    https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora \
    -d '{
          "display_name" : "CORPUS_DISPLAY_NAME"
      }'

RAG 코퍼스 업데이트 예시

새 표시 이름, 설명, 벡터 데이터베이스 구성으로 RAG 코퍼스를 업데이트할 수 있습니다. 하지만 RAG 코퍼스에서는 다음 파라미터를 변경할 수 없습니다.

  • 벡터 데이터베이스 유형. 예를 들어 벡터 데이터베이스를 Weaviate에서 Vertex AI Feature Store로 변경할 수는 없습니다.
  • 관리 데이터베이스 옵션을 사용하는 경우 벡터 데이터베이스 구성을 업데이트할 수 없습니다.

이 예시에서는 RAG 코퍼스를 업데이트하는 방법을 보여줍니다.

REST

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • PROJECT_ID: 프로젝트 ID
  • LOCATION: 요청을 처리하는 리전
  • CORPUS_ID: RAG 자료의 자료 ID
  • CORPUS_DISPLAY_NAME: RagCorpus의 표시 이름
  • CORPUS_DESCRIPTION: RagCorpus에 대한 설명
  • INDEX_NAME: Vector Search Index의 리소스 이름 형식: projects/{project}/locations/{location}/indexes/{index}
  • INDEX_ENDPOINT_NAME: Vector Search Index Endpoint의 리소스 이름 형식: projects/{project}/locations/{location}/indexEndpoints/{index_endpoint}

HTTP 메서드 및 URL:

PATCH https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/CORPUS_ID

JSON 요청 본문:

{
  "display_name" : "CORPUS_DISPLAY_NAME",
  "description": "CORPUS_DESCRIPTION",
  "rag_vector_db_config": {
     "vertex_vector_search": {
         "index": "INDEX_NAME",
         "index_endpoint": "INDEX_ENDPOINT_NAME",
     }
  }
}

요청을 보내려면 다음 옵션 중 하나를 선택합니다.

curl

요청 본문을 request.json 파일에 저장하고 다음 명령어를 실행합니다.

curl -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/CORPUS_ID"

PowerShell

요청 본문을 request.json 파일에 저장하고 다음 명령어를 실행합니다.

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method PATCH `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/CORPUS_ID" | Select-Object -Expand Content
성공 상태 코드(2xx)를 받아야 합니다.

RAG 코퍼스 나열 예시

이 코드 샘플은 모든 RAG 코퍼스를 나열하는 방법을 보여줍니다.

REST

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • PROJECT_ID: 프로젝트 ID
  • LOCATION: 요청을 처리하는 리전
  • PAGE_SIZE: 표준 목록 페이지 크기. page_size 파라미터를 업데이트하여 페이지당 반환할 RagCorpora 수를 조정할 수 있습니다.
  • PAGE_TOKEN: 표준 목록 페이지 토큰. 일반적으로 이전 VertexRagDataService.ListRagCorpora 호출의 ListRagCorporaResponse.next_page_token을 사용하여 가져옵니다.

HTTP 메서드 및 URL:

GET https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora?page_size=PAGE_SIZE&page_token=PAGE_TOKEN

요청을 보내려면 다음 옵션 중 하나를 선택합니다.

curl

다음 명령어를 실행합니다.

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora?page_size=PAGE_SIZE&page_token=PAGE_TOKEN"

PowerShell

다음 명령어를 실행합니다.

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora?page_size=PAGE_SIZE&page_token=PAGE_TOKEN" | Select-Object -Expand Content
주어진 PROJECT_ID 아래의 성공적인 상태 코드('2xx')와 RagCorpora 목록을 받아야 합니다.

RAG 코퍼스 가져오기 예시

REST

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • PROJECT_ID: 프로젝트 ID
  • LOCATION: 요청을 처리하는 리전
  • RAG_CORPUS_ID: RagCorpus 리소스의 ID

HTTP 메서드 및 URL:

GET https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID

요청을 보내려면 다음 옵션 중 하나를 선택합니다.

curl

다음 명령어를 실행합니다.

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID"

PowerShell

다음 명령어를 실행합니다.

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID" | Select-Object -Expand Content
응답에 성공하면 RagCorpus 리소스가 반환됩니다.

getlist 명령어는 RagCorpus이 선택한 삽입 모델을 가리키는 vector_db_config 내에서 rag_embedding_model_config 필드를 사용하는 방법을 보여주는 예시에서 사용됩니다.

  PROJECT_ID: Your project ID.
  LOCATION: The region to process the request.
  RAG_CORPUS_ID: The corpus ID of your RAG corpus.
// GetRagCorpus
// Input: LOCATION, PROJECT_ID, RAG_CORPUS_ID
// Output: RagCorpus
curl -X GET \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID

// ListRagCorpora
curl -sS -X GET \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/

RAG 코퍼스 삭제 예시

REST

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • PROJECT_ID: 프로젝트 ID
  • LOCATION: 요청을 처리하는 리전
  • RAG_CORPUS_ID: RagCorpus 리소스의 ID

HTTP 메서드 및 URL:

DELETE https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID

요청을 보내려면 다음 옵션 중 하나를 선택합니다.

curl

다음 명령어를 실행합니다.

curl -X DELETE \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID"

PowerShell

다음 명령어를 실행합니다.

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method DELETE `
-Headers $headers `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID" | Select-Object -Expand Content
응답에 성공하면 DeleteOperationMetadata가 반환됩니다.

파일 관리 예시

이 섹션에서는 API를 사용하여 RAG 파일을 관리하는 방법의 예시를 제공합니다.

RAG 파일 업로드 예시

REST

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  PROJECT_ID: Your project ID.
  LOCATION: The region to process the request.
  RAG_CORPUS_ID: The corpus ID of your RAG corpus.
  LOCAL_FILE_PATH: The local path to the file to be uploaded.
  DISPLAY_NAME: The display name of the RAG file.
  DESCRIPTION: The description of the RAG file.

요청을 보내려면 다음 명령어를 사용합니다.

  curl -X POST \
    -H "X-Goog-Upload-Protocol: multipart" \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    -F metadata="{'rag_file': {'display_name':' DISPLAY_NAME', 'description':'DESCRIPTION'}}" \
    -F file=@LOCAL_FILE_PATH \
    "https://LOCATION-aiplatform.googleapis.com/upload/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID/ragFiles:upload"

RAG 파일 가져오기 예시

Drive 또는 Cloud Storage에서 파일과 폴더를 가져올 수 있습니다.

response.skipped_rag_files_count는 가져오기 중에 건너뛴 파일 수를 나타냅니다. 다음 조건이 충족되면 파일이 건너뛰기됩니다.

  1. 파일을 이미 가져왔습니다.
  2. 파일이 변경되지 않았습니다.
  3. 파일의 청킹 구성이 변경되지 않았습니다.

REST

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • PROJECT_ID: 프로젝트 ID
  • LOCATION: 요청을 처리하는 리전
  • RAG_CORPUS_ID: RagCorpus 리소스의 ID
  • GCS_URIS: Cloud Storage 위치 목록. 예시: gs://my-bucket1, gs://my-bucket2
  • CHUNK_SIZE: (선택사항) 각 청크에 있어야 하는 토큰 수입니다.
  • CHUNK_OVERLAP: (선택사항) 청크 간에 겹치는 토큰 수입니다.

HTTP 메서드 및 URL:

POST https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID/ragFiles:import

JSON 요청 본문:

{
  "import_rag_files_config": {
    "gcs_source": {
      "uris": "GCS_URIS"
    },
    "rag_file_chunking_config": {
      "chunk_size": CHUNK_SIZE,
      "chunk_overlap": CHUNK_OVERLAP
    }
  }
}

요청을 보내려면 다음 옵션 중 하나를 선택합니다.

curl

요청 본문을 request.json 파일에 저장하고 다음 명령어를 실행합니다.

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID/ragFiles:import"

PowerShell

요청 본문을 request.json 파일에 저장하고 다음 명령어를 실행합니다.

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID/ragFiles:import" | Select-Object -Expand Content
응답에 성공하면 ImportRagFilesOperationMetadata 리소스가 반환됩니다.

다음 샘플은 Cloud Storage에서 파일을 가져오는 방법을 보여줍니다. max_embedding_requests_per_min 제어 필드를 사용하여 RAG Engine이 ImportRagFiles 색인 생성 프로세스 중에 임베딩 모델을 호출하는 속도를 제한합니다. 이 필드의 기본값은 분당 1000 호출입니다.

  PROJECT_ID: Your project ID.
  LOCATION: The region to process the request.
  RAG_CORPUS_ID: The corpus ID of your RAG corpus.
  GCS_URIS: A list of Cloud Storage locations. Example: gs://my-bucket1.
  CHUNK_SIZE: Number of tokens each chunk should have.
  CHUNK_OVERLAP: Number of tokens overlap between chunks.
  EMBEDDING_MODEL_QPM_RATE: The QPM rate to limit RAGs access to your embedding model. Example: 1000.
// ImportRagFiles
// Import a single Cloud Storage file or all files in a Cloud Storage bucket.
// Input: LOCATION, PROJECT_ID, RAG_CORPUS_ID, GCS_URIS
// Output: ImportRagFilesOperationMetadataNumber
// Use ListRagFiles to find the server-generated rag_file_id.
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID/ragFiles:import \
-d '{
  "import_rag_files_config": {
    "gcs_source": {
      "uris": "GCS_URIS"
    },
    "rag_file_chunking_config": {
      "chunk_size": CHUNK_SIZE,
      "chunk_overlap": CHUNK_OVERLAP
    },
    "max_embedding_requests_per_min": EMBEDDING_MODEL_QPM_RATE
  }
}'

// Poll the operation status.
// The response contains the number of files imported.
OPERATION_ID: The operation ID you get from the response of the previous command.
poll_op_wait OPERATION_ID

다음 샘플은 Drive에서 파일을 가져오는 방법을 보여줍니다. max_embedding_requests_per_min 제어 필드를 사용하여 RAG Engine이 ImportRagFiles 색인 생성 프로세스 중에 임베딩 모델을 호출하는 속도를 제한합니다. 이 필드의 기본값은 분당 1000 호출입니다.

  PROJECT_ID: Your project ID.
  LOCATION: The region to process the request.
  RAG_CORPUS_ID: The corpus ID of your RAG corpus.
  FOLDER_RESOURCE_ID: The resource ID of your Google Drive folder.
  CHUNK_SIZE: Number of tokens each chunk should have.
  CHUNK_OVERLAP: Number of tokens overlap between chunks.
  EMBEDDING_MODEL_QPM_RATE: The QPM rate to limit RAGs access to your embedding model. Example: 1000.
// ImportRagFiles
// Import all files in a Google Drive folder.
// Input: LOCATION, PROJECT_ID, RAG_CORPUS_ID, FOLDER_RESOURCE_ID
// Output: ImportRagFilesOperationMetadataNumber
// Use ListRagFiles to find the server-generated rag_file_id.
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID/ragFiles:import \
-d '{
  "import_rag_files_config": {
    "google_drive_source": {
      "resource_ids": {
        "resource_id": "FOLDER_RESOURCE_ID",
        "resource_type": "RESOURCE_TYPE_FOLDER"
      }
    },
    "max_embedding_requests_per_min": EMBEDDING_MODEL_QPM_RATE
  }
}'

// Poll the operation status.
// The response contains the number of files imported.
OPERATION_ID: The operation ID you get from the response of the previous command.
poll_op_wait OPERATION_ID

RAG 파일 나열 예시

이 코드 샘플은 RAG 파일을 나열하는 방법을 보여줍니다.

REST

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • PROJECT_ID: 프로젝트 ID
  • LOCATION: 요청을 처리하는 리전
  • RAG_CORPUS_ID: RagCorpus 리소스의 ID
  • PAGE_SIZE: 표준 목록 페이지 크기. page_size 파라미터를 업데이트하여 페이지당 반환할 RagFiles 수를 조정할 수 있습니다.
  • PAGE_TOKEN: 표준 목록 페이지 토큰. 일반적으로 이전 VertexRagDataService.ListRagFiles 호출의 ListRagFilesResponse.next_page_token을 사용하여 가져옵니다.

HTTP 메서드 및 URL:

GET https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID/ragFiles?page_size=PAGE_SIZE&page_token=PAGE_TOKEN

요청을 보내려면 다음 옵션 중 하나를 선택합니다.

curl

다음 명령어를 실행합니다.

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID/ragFiles?page_size=PAGE_SIZE&page_token=PAGE_TOKEN"

PowerShell

다음 명령어를 실행합니다.

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID/ragFiles?page_size=PAGE_SIZE&page_token=PAGE_TOKEN" | Select-Object -Expand Content
해당 RAG_CORPUS_ID 아래의 RagFiles 목록과 함께 성공적인 상태 코드(2xx)를 받아야 합니다.

RAG 파일 가져오기 예시

이 코드 샘플은 RAG 파일을 가져오는 방법을 보여줍니다.

REST

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • PROJECT_ID: 프로젝트 ID
  • LOCATION: 요청을 처리하는 리전
  • RAG_CORPUS_ID: RagCorpus 리소스의 ID
  • RAG_FILE_ID: RagFile 리소스의 ID

HTTP 메서드 및 URL:

GET https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID/ragFiles/RAG_FILE_ID

요청을 보내려면 다음 옵션 중 하나를 선택합니다.

curl

다음 명령어를 실행합니다.

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID/ragFiles/RAG_FILE_ID"

PowerShell

다음 명령어를 실행합니다.

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID/ragFiles/RAG_FILE_ID" | Select-Object -Expand Content
응답에 성공하면 RagFile 리소스가 반환됩니다.

RAG 파일 삭제 예시

이 코드 샘플은 RAG 파일을 삭제하는 방법을 보여줍니다.

REST

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • PROJECT_ID: 프로젝트 ID
  • LOCATION: 요청을 처리하는 리전
  • RAG_CORPUS_ID: RagCorpus 리소스의 ID
  • RAG_FILE_ID: RagFile 리소스의 ID 형식은 projects/{project}/locations/{location}/ragCorpora/{rag_corpus}/ragFiles/{rag_file_id}입니다.

HTTP 메서드 및 URL:

DELETE https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID/ragFiles/RAG_FILE_ID

요청을 보내려면 다음 옵션 중 하나를 선택합니다.

curl

다음 명령어를 실행합니다.

curl -X DELETE \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID/ragFiles/RAG_FILE_ID"

PowerShell

다음 명령어를 실행합니다.

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method DELETE `
-Headers $headers `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragCorpora/RAG_CORPUS_ID/ragFiles/RAG_FILE_ID" | Select-Object -Expand Content
응답에 성공하면 DeleteOperationMetadata 리소스가 반환됩니다.

검색 쿼리 예시

사용자가 질문하거나 프롬프트를 제공하면 RAG의 검색 구성요소는 기술 자료를 통해 쿼리와 관련된 정보를 찾습니다.

REST

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • LOCATION: 요청을 처리하는 리전
  • PROJECT_ID: 프로젝트 ID
  • RAG_CORPUS_RESOURCE: RagCorpus 리소스의 이름. 형식은 projects/{project}/locations/{location}/ragCorpora/{rag_corpus}입니다.
  • VECTOR_DISTANCE_THRESHOLD: 벡터 거리가 기준점보다 작은 컨텍스트만 반환됩니다.
  • TEXT: 관련 컨텍스트를 가져올 쿼리 텍스트입니다.
  • SIMILARITY_TOP_K: 검색할 상위 컨텍스트 수입니다.

HTTP 메서드 및 URL:

POST https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION:retrieveContexts

JSON 요청 본문:

{
 "vertex_rag_store": {
    "rag_resources": {
      "rag_corpus": "RAG_CORPUS_RESOURCE"
    },
    "vector_distance_threshold": VECTOR_DISTANCE_THRESHOLD
  },
  "query": {
   "text": "TEXT",
   "similarity_top_k": SIMILARITY_TOP_K
  }
}

요청을 보내려면 다음 옵션 중 하나를 선택합니다.

curl

요청 본문을 request.json 파일에 저장하고 다음 명령어를 실행합니다.

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION:retrieveContexts"

PowerShell

요청 본문을 request.json 파일에 저장하고 다음 명령어를 실행합니다.

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION:retrieveContexts" | Select-Object -Expand Content
성공 상태 코드(2xx) 및 관련 RagFiles 목록을 받아야 합니다.

생성 예

LLM은 검색된 컨텍스트를 사용하여 그라운딩된 대답을 생성합니다.

REST

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • PROJECT_ID: 프로젝트 ID
  • LOCATION: 요청을 처리하는 리전
  • MODEL_ID: 콘텐츠 생성을 위한 LLM 모델. 예를 들면 gemini-2.5-flash입니다.
  • GENERATION_METHOD: 콘텐츠 생성을 위한 LLM 방법. (선택사항) generateContent, streamGenerateContent
  • INPUT_PROMPT: 콘텐츠 생성을 위해 LLM에 전송된 텍스트. 업로드된 래그 파일과 관련된 프롬프트를 사용해 보세요.
  • RAG_CORPUS_RESOURCE: RagCorpus 리소스의 이름. 형식은 projects/{project}/locations/{location}/ragCorpora/{rag_corpus}입니다.
  • SIMILARITY_TOP_K: (선택사항) 검색할 인기 컨텍스트 수
  • VECTOR_DISTANCE_THRESHOLD: (선택사항) 벡터 거리가 기준점보다 작은 컨텍스트가 반환됩니다.

HTTP 메서드 및 URL:

POST https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/publishers/google/models/MODEL_ID:GENERATION_METHOD

JSON 요청 본문:

{
 "contents": {
  "role": "user",
  "parts": {
    "text": "INPUT_PROMPT"
  }
 },
 "tools": {
  "retrieval": {
   "disable_attribution": false,
   "vertex_rag_store": {
    "rag_resources": {
      "rag_corpus": "RAG_CORPUS_RESOURCE"
    },
    "similarity_top_k": SIMILARITY_TOP_K,
    "vector_distance_threshold": VECTOR_DISTANCE_THRESHOLD
   }
  }
 }
}

요청을 보내려면 다음 옵션 중 하나를 선택합니다.

curl

요청 본문을 request.json 파일에 저장하고 다음 명령어를 실행합니다.

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/publishers/google/models/MODEL_ID:GENERATION_METHOD"

PowerShell

요청 본문을 request.json 파일에 저장하고 다음 명령어를 실행합니다.

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/publishers/google/models/MODEL_ID:GENERATION_METHOD" | Select-Object -Expand Content
응답에 성공하면 인용과 함께 생성된 콘텐츠가 반환됩니다.

프로젝트 관리 예시

등급은 RagEngineConfig 리소스에서 사용할 수 있는 프로젝트 수준 설정이며 RagManagedDb를 사용하는 RAG 코퍼스에 영향을 미칩니다. 등급 구성을 가져오려면 GetRagEngineConfig를 사용합니다. 등급 구성을 업데이트하려면 UpdateRagEngineConfig를 사용합니다.

등급 구성 관리에 대한 자세한 내용은 등급 관리를 참고하세요.

프로젝트 구성 가져오기

다음 샘플 코드는 RagEngineConfig를 읽는 방법을 보여줍니다.

콘솔

  1. Google Cloud 콘솔에서 RAG Engine 페이지로 이동합니다.

    RAG Engine으로 이동

  2. RAG Engine이 실행 중인 리전을 선택합니다. RAG 코퍼스 목록이 업데이트됩니다.
  3. RAG 엔진 구성을 클릭합니다. RAG 엔진 구성 창이 표시됩니다. RAG 엔진에 선택된 등급을 확인할 수 있습니다.
  4. 취소를 클릭합니다.

Python

from vertexai import rag
import vertexai

PROJECT_ID = YOUR_PROJECT_ID
LOCATION = YOUR_RAG_ENGINE_LOCATION

# Initialize Vertex AI API once per session
vertexai.init(project=PROJECT_ID, location=LOCATION)

rag_engine_config = rag.rag_data.get_rag_engine_config(
    name=f"projects/{PROJECT_ID}/locations/{LOCATION}/ragEngineConfig"
)

print(rag_engine_config)

REST

curl -X GET \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
https://${LOCATION}-aiplatform.googleapis.com/v1beta1/projects/${PROJECT_ID}/locations/${LOCATION}/ragEngineConfig

프로젝트 구성 업데이트

이 섹션에서는 구성에서 등급을 변경하는 방법을 보여주는 코드 샘플을 제공합니다.

RagEngineConfig을 확장 등급으로 업데이트

다음 코드 샘플은 RagEngineConfig를 확장 등급으로 설정하는 방법을 보여줍니다.

콘솔

  1. Google Cloud 콘솔에서 RAG Engine 페이지로 이동합니다.

    RAG Engine으로 이동

  2. RAG Engine이 실행 중인 리전을 선택합니다. RAG 코퍼스 목록이 업데이트됩니다.
  3. RAG 엔진 구성을 클릭합니다. RAG 엔진 구성 창이 표시됩니다.
  4. RAG 엔진을 실행할 등급을 선택합니다.
  5. 저장을 클릭합니다.

Python

from vertexai import rag
import vertexai

PROJECT_ID = YOUR_PROJECT_ID
LOCATION = YOUR_RAG_ENGINE_LOCATION

# Initialize Vertex AI API once per session
vertexai.init(project=PROJECT_ID, location=LOCATION)

rag_engine_config_name=f"projects/{PROJECT_ID}/locations/{LOCATION}/ragEngineConfig"

new_rag_engine_config = rag.RagEngineConfig(
name=rag_engine_config_name,
rag_managed_db_config=rag.RagManagedDbConfig(tier=rag.Scaled()),
)

updated_rag_engine_config = rag.rag_data.update_rag_engine_config(
rag_engine_config=new_rag_engine_config
)

print(updated_rag_engine_config)

REST

curl -X PATCH \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
https://${LOCATION}-aiplatform.googleapis.com/v1beta1/projects/${PROJECT_ID}/locations/${LOCATION}/ragEngineConfig -d "{'ragManagedDbConfig': {'scaled': {}}}"

RagEngineConfig을 Basic 등급으로 업데이트

다음 코드 샘플은 RagEngineConfig를 기본 등급으로 설정하는 방법을 보여줍니다.

RAG 코퍼스 전반에 RagManagedDb에 많은 양의 데이터가 있는 경우 컴퓨팅 및 스토리지 용량이 부족하여 Basic 등급으로 다운그레이드하지 못할 수 있습니다.

콘솔

  1. Google Cloud 콘솔에서 RAG Engine 페이지로 이동합니다.

    RAG Engine으로 이동

  2. RAG Engine이 실행 중인 리전을 선택합니다. RAG 코퍼스 목록이 업데이트됩니다.
  3. RAG 엔진 구성을 클릭합니다. RAG 엔진 구성 창이 표시됩니다.
  4. RAG 엔진을 실행할 등급을 선택합니다.
  5. 저장을 클릭합니다.

Python

from vertexai import rag
import vertexai

PROJECT_ID = YOUR_PROJECT_ID
LOCATION = YOUR_RAG_ENGINE_LOCATION

# Initialize Vertex AI API once per session
vertexai.init(project=PROJECT_ID, location=LOCATION)

rag_engine_config_name=f"projects/{PROJECT_ID}/locations/{LOCATION}/ragEngineConfig"

new_rag_engine_config = rag.RagEngineConfig(
name=rag_engine_config_name,
rag_managed_db_config=rag.RagManagedDbConfig(tier=rag.Basic()),
)

updated_rag_engine_config = rag.rag_data.update_rag_engine_config(
rag_engine_config=new_rag_engine_config
)

print(updated_rag_engine_config)

REST

curl -X PATCH \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
https://${LOCATION}-aiplatform.googleapis.com/v1beta1/projects/${PROJECT_ID}/locations/${LOCATION}/ragEngineConfig -d "{'ragManagedDbConfig': {'basic': {}}}"

RagEngineConfig을 프로비저닝되지 않음 등급으로 업데이트

다음 코드 샘플은 RagEngineConfig를 프로비저닝되지 않은 등급으로 설정하는 방법을 보여줍니다.

콘솔

  1. Google Cloud 콘솔에서 RAG Engine 페이지로 이동합니다.

    RAG Engine으로 이동

  2. RAG Engine이 실행 중인 리전을 선택합니다. RAG 코퍼스 목록이 업데이트됩니다.
  3. RAG 엔진 구성을 클릭합니다. RAG 엔진 구성 창이 표시됩니다.
  4. RAG 엔진 삭제를 클릭합니다. 확인 대화상자가 나타납니다.
  5. delete를 입력하여 RAG 엔진에서 데이터를 삭제하려고 하는지 확인한 다음 확인을 클릭합니다.
  6. 저장을 클릭합니다.

Python

from vertexai import rag
import vertexai

PROJECT_ID = YOUR_PROJECT_ID
LOCATION = YOUR_RAG_ENGINE_LOCATION

# Initialize Vertex AI API once per session
vertexai.init(project=PROJECT_ID, location=LOCATION)

rag_engine_config_name=f"projects/{PROJECT_ID}/locations/{LOCATION}/ragEngineConfig"

new_rag_engine_config = rag.RagEngineConfig(
  name=rag_engine_config_name,
  rag_managed_db_config=rag.RagManagedDbConfig(tier=rag.Unprovisioned()),
)

updated_rag_engine_config = rag.rag_data.update_rag_engine_config(
  rag_engine_config=new_rag_engine_config
)

print(updated_rag_engine_config)

REST

curl -X PATCH \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
https://${LOCATION}-aiplatform.googleapis.com/v1beta1/projects/${PROJECT_ID}/locations/${LOCATION}/ragEngineConfig -d "{'ragManagedDbConfig': {'unprovisioned': {}}}"

다음 단계