# To use the Python SDK, install the plugin:
# pip install --upgrade pinecone pinecone-plugin-assistant
from pinecone import Pinecone
pc = Pinecone(api_key="YOUR_API_KEY")
# Get the assistant.
assistant = pc.assistant.Assistant(
assistant_name="example-assistant",
)
# Upload a file from a local path.
response = assistant.upload_file(
file_path="/Users/jdoe/Downloads/example_file.txt",
metadata={"published": "2024-01-01", "document_type": "manuscript"},
timeout=None
)
# Upload from an in-memory binary stream.
from io import BytesIO
# Create a BytesIO stream with some content.
md_text = "# Title\n\ntext"
stream = BytesIO(md_text.encode("utf-8"))
# Upload the stream.
response_bytes_stream = assistant.upload_bytes_stream(
stream=stream,
file_name="example_file.md",
timeout=None
)
{
"name": "example-file.txt",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"metadata": "{ 'published': '2024-01-01', 'document_type': 'manuscript' }",
"created_on": "2023-11-07T05:31:56Z",
"updated_on": "2023-11-07T05:31:56Z",
"status": "Processing",
"percent_done": 50,
"signed_url": "https://storage.googleapis.com/bucket/file.pdf",
"error_message": "<string>"
}
Upload file to assistant
Upload a file to the specified assistant.
For guidance and examples, see Manage files.
# To use the Python SDK, install the plugin:
# pip install --upgrade pinecone pinecone-plugin-assistant
from pinecone import Pinecone
pc = Pinecone(api_key="YOUR_API_KEY")
# Get the assistant.
assistant = pc.assistant.Assistant(
assistant_name="example-assistant",
)
# Upload a file from a local path.
response = assistant.upload_file(
file_path="/Users/jdoe/Downloads/example_file.txt",
metadata={"published": "2024-01-01", "document_type": "manuscript"},
timeout=None
)
# Upload from an in-memory binary stream.
from io import BytesIO
# Create a BytesIO stream with some content.
md_text = "# Title\n\ntext"
stream = BytesIO(md_text.encode("utf-8"))
# Upload the stream.
response_bytes_stream = assistant.upload_bytes_stream(
stream=stream,
file_name="example_file.md",
timeout=None
)
{
"name": "example-file.txt",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"metadata": "{ 'published': '2024-01-01', 'document_type': 'manuscript' }",
"created_on": "2023-11-07T05:31:56Z",
"updated_on": "2023-11-07T05:31:56Z",
"status": "Processing",
"percent_done": 50,
"signed_url": "https://storage.googleapis.com/bucket/file.pdf",
"error_message": "<string>"
}
Documentation Index
Fetch the complete documentation index at: https://docs.pinecone.io/llms.txt
Use this file to discover all available pages before exploring further.
# To use the Python SDK, install the plugin:
# pip install --upgrade pinecone pinecone-plugin-assistant
from pinecone import Pinecone
pc = Pinecone(api_key="YOUR_API_KEY")
# Get the assistant.
assistant = pc.assistant.Assistant(
assistant_name="example-assistant",
)
# Upload a file from a local path.
response = assistant.upload_file(
file_path="/Users/jdoe/Downloads/example_file.txt",
metadata={"published": "2024-01-01", "document_type": "manuscript"},
timeout=None
)
# Upload from an in-memory binary stream.
from io import BytesIO
# Create a BytesIO stream with some content.
md_text = "# Title\n\ntext"
stream = BytesIO(md_text.encode("utf-8"))
# Upload the stream.
response_bytes_stream = assistant.upload_bytes_stream(
stream=stream,
file_name="example_file.md",
timeout=None
)
{
"name": "example-file.txt",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"metadata": "{ 'published': '2024-01-01', 'document_type': 'manuscript' }",
"created_on": "2023-11-07T05:31:56Z",
"updated_on": "2023-11-07T05:31:56Z",
"status": "Processing",
"percent_done": 50,
"signed_url": "https://storage.googleapis.com/bucket/file.pdf",
"error_message": "<string>"
}
Authorizations
Pinecone API Key
Path Parameters
The name of the assistant to upload files to.
Query Parameters
Optional JSON-encoded metadata for files.
Body
The desired file to be uploaded and processed into the assistant.
The file to upload.
Response
File upload has been accepted.
AssistantFileModel is the response format to a successful file upload request.
Processing, Available, Deleting, ProcessingFailed The percentage of the file that has been processed
A signed URL that provides temporary, read-only access to the underlying file. Anyone with the link can access the file, so treat it as sensitive data. Expires after a short time.
"https://storage.googleapis.com/bucket/file.pdf?..."
A message describing any error during file processing, provided only if an error occurs.
Was this page helpful?