Craft AI Modules Google
const { aiModules } = MODULES;
Table of Contents
- aiModules
- GeminiGenerationConfig
- GeminiSafetySetting
- GeminiCandidate
- GeminiResponse
- GeminiStreamChunk
- RagOptions
- CraftExtra
- FunctionDeclaration
- StandardGeminiTools
- FunctionCallingConfig
- StandardGeminiToolConfig
- GeminiContentParams
- GeminiStreamParams
- FunctionCall
- FunctionResponse
- GeminiResultValue
- ContentPart
- Content
- StreamChunk
- ThinkingConfig
- GenerationConfig
- EmbeddingsResultValue
- MultiEmbedding
- MultiEmbeddingsResultValue
- TextEmbeddingInstance
- TextEmbeddingParameters
- RerankRecord
- RankedRecord
- RerankResultValue
aiModules
Standard AI modules for GCP services
gcpGeminiGenerateContent
Geminiにリクエストを送信する
Parameters
params
GeminiContentParams パラメータ
Returns Promise<GeminiResultValue>
gcpGeminiGenerateContentStream
Geminiにストリーミングリクエストを送信する
Parameters
params
GeminiStreamParams パラメータ
Returns Promise<void>
gcpEmbeddingsText
TextEmbeddingsにリクエストを送信する
Parameters
-
param
Objectparam.text
string テキストの内容 (deprecated, use instances instead)param.instances
Array<TextEmbeddingInstance>? インスタンスの配列param.parameters
TextEmbeddingParameters? パラメータparam.model
string? モデル名 (optional) - ‘text-multilingual-embedding-002’, ‘text-embedding-004’, ‘gemini-embedding-001’
Returns Promise<EmbeddingsResultValue>
gcpEmbeddingsMulti
MultiModalEmbeddingsにリクエストを送信する
Parameters
-
param
Object
- Throws Error failed. text or bytesBase64Encoded is required
Returns Promise<MultiEmbeddingsResultValue>
gcpRerank
GCP Rerank APIにリクエストを送信する
Parameters
-
param
Objectparam.query
string 検索クエリparam.records
Array<RerankRecord> ランク付けするレコードの配列param.model
string? モデル名(デフォルト: semantic-ranker-512@latest)。利用可能なモデル: semantic-ranker-512@latest, semantic-ranker-default-004, semantic-ranker-fast-004param.ignoreRecordDetailsInResponse
boolean? レコードのタイトルとコンテンツも返さないか(デフォルト: true)param.topN
number? 返される上位レコードの数(デフォルト: 10)
- Throws Error failed. query and records are required
Returns Promise<RerankResultValue>
GeminiGenerationConfig
Type: Object
Properties
-
maxOutputTokens
number? 最大出力トークン数 -
temperature
number? 温度パラメータ (0-2) -
topP
number? Top-p サンプリング -
responseMimeType
string? レスポンスのMIMEタイプ -
responseSchema
Object? レスポンススキーマ -
thinkingConfig
Object? Thinking mode設定
GeminiSafetySetting
Type: Object
Properties
category
("HARM_CATEGORY_HARASSMENT"
|"HARM_CATEGORY_HATE_SPEECH"
|"HARM_CATEGORY_SEXUALLY_EXPLICIT"
|"HARM_CATEGORY_DANGEROUS_CONTENT"
) 安全性カテゴリthreshold
("BLOCK_NONE"
|"BLOCK_ONLY_HIGH"
|"BLOCK_MEDIUM_AND_ABOVE"
|"BLOCK_LOW_AND_ABOVE"
) ブロック閾値
GeminiCandidate
Type: Object
Properties
GeminiResponse
Type: Object
Properties
-
candidates
Array<GeminiCandidate> 候補リスト -
usageMetadata
Object 使用量メタデータ -
groundingMetadata
Object? グラウンディングメタデータ
GeminiStreamChunk
Type: Object
Properties
delta
Object? デルタコンテンツfinishReason
string? 終了理由groundingMetadata
Object? グラウンディングメタデータusageMetadata
Object? 使用量メタデータ(最終チャンク)
RagOptions
Type: Object
Properties
corpusId
string RAG IDvectorDistanceThreshold
number? ベクトル距離の閾値llmRankerModel
string? LLMランカーのモデル名rankServiceModel
string? ランクサービスのモデル名topK
number? トップK
CraftExtra
Type: Object
Properties
ragOptions
RagOptions? RAGオプション
FunctionDeclaration
Type: Object
Properties
StandardGeminiTools
Type: Object
Properties
functionDeclarations
Array<FunctionDeclaration>? Function calling宣言
FunctionCallingConfig
Type: Object
Properties
mode
("AUTO"
|"ANY"
|"NONE"
)? Function calling modeallowedFunctionNames
Array<string>? 許可する関数名のリスト
StandardGeminiToolConfig
Type: Object
Properties
functionCallingConfig
FunctionCallingConfig? Function calling設定
GeminiContentParams
Type: Object
Properties
model
string モデル(必須) 利用可能なモデル:* ‘gemini-2.5-flash’: Gemini 2.5 Flash- ’gemini-2.5-flash-lite’: Gemini 2.5 Flash Lite
- ’gemini-2.5-pro’: Gemini 2.5 Pro
contents
Array<Object> コンテンツ配列systemInstruction
string? システムインストラクションgenerationConfig
GeminiGenerationConfig? 生成設定safetySettings
Array<GeminiSafetySetting>? 安全性設定tools
StandardGeminiTools? ツール設定(Function callingのみ)toolConfig
StandardGeminiToolConfig? ツール設定(Function calling設定のみ)craftExtra
CraftExtra? Craft固有の追加設定(RAGオプションなど)
GeminiStreamParams
Extends GeminiContentParams
Type: Object
FunctionCall
Type: Object
Properties
FunctionResponse
Type: Object
Properties
GeminiResultValue
Type: Object
Properties
-
usageMetadata
Object 使用量メタデータ -
-
candidates[].content
Object 回答の内容candidates[].content.role
string 役割candidates[].content.parts
Array<Object> 回答の部分candidates[].content.parts
string [].text - 回答のテキストcandidates[].content.parts
FunctionCall [].functionCall - functionCallcandidates[].content.parts
FunctionResponse [].functionResponse - functionResponse
-
candidates[].finishReason
string 回答終了理由
-
ContentPart
Type: Object
Properties
Content
Type: Object
Properties
role
string 役割parts
Array<ContentPart> コンテンツの部分
StreamChunk
Type: Object
Properties
ThinkingConfig
Type: Object
Properties
GenerationConfig
Type: Object
Properties
maxOutputTokens
number? 最大出力トークン数temperature
number? 生成時の多様性を制御するパラメータtopP
number? 確率の高いトークンから選択する閾値responseMimeType
string? レスポンスタイプresponseSchema
Object? レスポンス構造を定義するスキーマthinkingConfig
ThinkingConfig? 思考処理の設定
EmbeddingsResultValue
Type: Object
Properties
MultiEmbedding
Type: Object
Properties
textEmbedding
Array<number>? The text embedding array.imageEmbedding
Array<number>? The image embedding array.
MultiEmbeddingsResultValue
Type: Object
Properties
predictions
Array<MultiEmbedding> An array of embedding objects.
TextEmbeddingInstance
Type: Object
Properties
content
string コンテンツtitle
string? タイトル (optional) - RETRIEVAL_DOCUMENTタスクタイプでのみ使用可能task_type
string? タスクタイプ (optional) - 以下の値が使用可能。デフォルトは ‘RETRIEVAL_QUERY’:* ‘RETRIEVAL_QUERY’: 検索クエリ用- ’RETRIEVAL_DOCUMENT’: 検索対象のドキュメント用
- ’SEMANTIC_SIMILARITY’: 意味的類似性の比較用
- ’CLASSIFICATION’: 分類タスク用
- ’CLUSTERING’: クラスタリングタスク用
- ’QUESTION_ANSWERING’: 質問応答システム用
- ’FACT_VERIFICATION’: 事実検証用
- ’CODE_RETRIEVAL_QUERY’: コード検索クエリ用
TextEmbeddingParameters
Type: Object
Properties
RerankRecord
Type: Object
Properties
RankedRecord
Type: Object
Properties
id
string レコードのIDtitle
string? レコードのタイトル。ignoreRecordDetailsInResponse が true の場合は省略される。content
string? レコードのコンテンツ。ignoreRecordDetailsInResponse が true の場合は省略される。score
number ランキングスコア
RerankResultValue
Type: Object
Properties
records
Array<RankedRecord> ランク付けされたレコードの配列