Vector embeddings generation and storage for Scrapy
Project description
scrapy-vectors
Vector embeddings generation and storage for Scrapy spiders.
Features
- Embeddings Pipeline: Generate vector embeddings using LiteLLM (supports OpenAI, Cohere, and other providers)
- S3 Vectors Storage: Store embeddings in AWS S3 Vectors service
Installation
pip install scrapy-vectors
Quick Start
In your scrapy_settings.py:
ITEM_PIPELINES = {
# Outputs as jsonlines in Pinecone format, which s3-vectors can use
"scrapy_vectors.EmbeddingsLiteLLMPipeline": 300,
}
EXTENSIONS = {
"scrapy.extensions.feedexport.FeedExporter": None, # Disable standard
"scrapy_vectors.S3VectorsFeedExporter": 300, # Use custom
}
FEED_STORAGES = {
"s3-vectors": "scrapy_vectors.S3VectorsFeedStorage",
}
FEEDS = {
"s3-vectors://vectors-bucket/vectors-index": {
"format": "jsonlines",
"batch_item_count": 100,
}
}
# LiteLLM will route for you
LITELLM_API_KEY = "your_provider_api_key" # (e.g. OpenAI API Key)
LITELLM_EMBEDDING_MODEL = "text-embedding-3-small" # This is default when unspecified
AWS_REGION_NAME = "us-east-1"
AWS_ACCESS_KEY_ID = "access_key_id"
AWS_SECRET_ACCESS_KEY = "access_key"
In your scraper:
import scrapy
class MySpider(scrapy.Spider):
name = "example"
start_urls = ["https://example.com"]
# Must yield with: id, page_content, and metadata
def parse(self, response):
yield {
"id": response.url,
"page_content": response.css("article::text").get(),
"metadata": {
"title": response.css("h1::text").get(),
"url": response.url,
}
}
Configuration
Embeddings Pipeline Settings
LITELLM_API_KEY: API key for your embedding provider (required)LITELLM_EMBEDDING_MODEL: Model to use (default: OpenAI'stext-embedding-3-small)
S3 Vectors Storage Settings
AWS_REGION_NAME: AWS region (required)AWS_ACCESS_KEY_ID: AWS access keyAWS_SECRET_ACCESS_KEY: AWS secret key
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
scrapy_vectors-0.2.1.tar.gz
(6.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file scrapy_vectors-0.2.1.tar.gz.
File metadata
- Download URL: scrapy_vectors-0.2.1.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5adda0989986896e73f3fbdf8423589445620534a7832cd1b0c6c020dc629327
|
|
| MD5 |
0529cf70a77d7ec0e115338acc3fb8a5
|
|
| BLAKE2b-256 |
87acfb3935a3795cf91464ae128bfacf780bd9c168b1e8a84443b44eb7dcb769
|
File details
Details for the file scrapy_vectors-0.2.1-py3-none-any.whl.
File metadata
- Download URL: scrapy_vectors-0.2.1-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e2b8329fa153995cf0cb79ee4092950f63ec6f4d96a50c3444a908816e354e9
|
|
| MD5 |
0c13c63da54b69516dbbe48e926db60f
|
|
| BLAKE2b-256 |
08f933c6e02717b342c379421af5b707111addca0e181a5fea01f0127e5558ad
|