Skip to main content
This guide helps you get started with AI/ML API 向量嵌入模型 using LangChain.

概述

集成详情

设置

要访问 AI/ML API embedding 模型,您需要创建一个 账户,获取 API 密钥,并安装 langchain-aimlapi 集成包。

凭证

前往 aimlapi.com to sign up 并生成 API 密钥。 完成后设置 AIMLAPI_API_KEY 环境变量:
要启用模型调用的自动追踪,请设置您的 LangSmith API key:

安装

LangChain 的 AI/ML API 集成位于 langchain-aimlapi 包中:

实例化

Now we can instantiate our embeddings model and perform embedding operations:

索引与检索

向量嵌入模型常用于检索增强生成 (RAG) 流程中. Below is how to index and retrieve data using the embeddings object we initialized above with InMemoryVectorStore.

直接使用

You can directly call embed_query and embed_documents for custom embedding scenarios.

Embed single text

Embed multiple texts