Skip to main content

langchain-cos-vectors

腾讯云 COS 向量存储桶(CosVectors)的 LangChain VectorStore 集成。

CosVectors 是腾讯云对象存储(COS)推出的向量存储桶产品,支持向量的存储、检索和相似度搜索。

安装

pip install langchain-cos-vectors

快速开始

from langchain_cos_vectors import CosVectors
from langchain_openai import OpenAIEmbeddings

# 方式一:通过构造函数创建
cos_vectors = CosVectors(
    embedding=OpenAIEmbeddings(),
    cos_config={
        "Region": "ap-beijing",
        "SecretId": "your-secret-id",
        "SecretKey": "your-secret-key",
    },
    bucket="your-vector-bucket",
    index="your-index",
    endpoint="vectors.ap-beijing.coslake.com",  # 可选,自定义 Endpoint
)

# 添加文本
ids = cos_vectors.add_texts(
    texts=["hello world", "foo bar"],
    metadatas=[{"source": "test"}, {"source": "test"}],
)

# 相似度搜索
docs = cos_vectors.similarity_search("hello", k=2)

# 方式二:通过 from_texts 快速创建
cos_vectors = CosVectors.from_texts(
    texts=["hello", "world"],
    embedding=OpenAIEmbeddings(),
    cos_region="ap-beijing",
    cos_secret_id="your-secret-id",
    cos_secret_key="your-secret-key",
    bucket="my-vector-bucket",
    index="my-index",
    endpoint="vectors.ap-beijing.coslake.com",
)

环境变量

也可以通过环境变量配置认证信息:

export COS_SECRET_ID="your-secret-id"
export COS_SECRET_KEY="your-secret-key"
export COS_REGION="ap-beijing"

Metadata

Release files for langchain-cos-vectors 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-cos-vectors 0.1.0
File Size Uploaded
langchain_cos_vectors-0.1.0.tar.gz 8.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-cos-vectors 0.1.0
File Interpreter ABI Platform
langchain_cos_vectors-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 18.1 kB

Release files / langchain_cos_vectors-0.1.0.tar.gz

Download URL langchain_cos_vectors-0.1.0.tar.gz
Size 8.8 kB
Tags Source
SHA-256 checksum
How to use checksums
adfaf125bef7c7712798ea41b35fe89693f211f1392f5d2dc0001b9be934c834
BLAKE2b-256 checksum
How to use checksums
b12b857e4da323e9144440d602db3868b86337906bba0ea35389c53e079975ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / langchain_cos_vectors-0.1.0-py3-none-any.whl

Download URL langchain_cos_vectors-0.1.0-py3-none-any.whl
Size 9.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8597a55df00996762d074b80636a55d1a971cf6f478db13925811309d2d0cb98
BLAKE2b-256 checksum
How to use checksums
d31be8857e02bf1d1b91fbbe66867b0d5a91b17b47bd8ebd721bdff5c875f142
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page