{"library":"pinecone-text","title":"Pinecone Text Client","description":"The Pinecone Text Client is a Python package that provides text utilities for generating sparse, dense, and hybrid vector embeddings. It is designed for seamless integration with Pinecone's vector database to facilitate sparse-dense (hybrid) semantic search. Currently, it is a public preview ('Beta') version, with the latest release being 0.11.0. Release cadence is infrequent, focusing on feature additions and improvements within its beta phase.","language":"python","status":"active","last_verified":"Thu Apr 16","install":{"commands":["pip install pinecone-text"],"cli":null},"imports":["from pinecone_text.dense import OpenAIEncoder","from pinecone_text.dense import AzureOpenAIEncoder","from pinecone_text.sparse import SpladeEncoder","from pinecone_text.sparse import BM25Encoder","from pinecone_text.hybrid import hybrid_convex_scale"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom pinecone_text.dense import OpenAIEncoder\n\n# Ensure OPENAI_API_KEY is set in your environment\n# For quick testing, you can uncomment and set it directly, but prefer environment variables\n# os.environ[\"OPENAI_API_KEY\"] = \"YOUR_OPENAI_API_KEY\"\n\nif not os.environ.get(\"OPENAI_API_KEY\"):\n    print(\"Error: OPENAI_API_KEY environment variable not set.\")\n    print(\"Please set it or uncomment the line above for testing.\")\nelse:\n    try:\n        encoder = OpenAIEncoder() # Defaults to 'text-embedding-3-small'\n        documents = [\n            \"The quick brown fox jumps over the lazy dog\",\n            \"Artificial intelligence is transforming industries\"\n        ]\n        queries = [\n            \"Who jumped over the lazy dog?\",\n            \"What is AI doing?\"\n        ]\n\n        document_vectors = encoder.encode_documents(documents)\n        query_vectors = encoder.encode_queries(queries)\n\n        print(f\"Encoded document 1 vector (first 5 elements): {document_vectors[0][:5]}...\")\n        print(f\"Encoded query 1 vector (first 5 elements): {query_vectors[0][:5]}...\")\n    except Exception as e:\n        print(f\"An error occurred during encoding: {e}\")","lang":"python","description":"This quickstart demonstrates how to initialize the `OpenAIEncoder` and use it to generate dense vector embeddings for both documents and queries. It highlights the necessity of setting the `OPENAI_API_KEY` environment variable.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}