Generates an answer from the assistant with structured citations.
Server errors are retried according to PineconeConfiguration.maxRetries.
Messages and optional model, file filter, and response settings.
The answer in message, with citations and token usage.
Errors.PineconeArgumentError if the messages or model fail validation.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const assistant = pc.assistant({ name: 'support-guide' });
const response = await assistant.chat({
messages: [{ role: 'user', content: 'How do I return an order?' }],
});
console.log(response.message, response.citations);
Assistant.chatStream for streamed answers; Assistant.chatCompletion for completion-style responses.
Generates an assistant answer in a chat completion response format.
Server errors are retried according to PineconeConfiguration.maxRetries.
Messages and optional model, temperature, and file metadata filter.
Response choices containing the answer, with model and token usage.
Errors.PineconeArgumentError if the messages or model fail validation.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const assistant = pc.assistant({ name: 'support-guide' });
const response = await assistant.chatCompletion({
messages: [{ role: 'user', content: 'How do I return an order?' }],
});
console.log(response.choices);
Assistant.chat for structured citations and additional response options.
Streams an assistant answer in a chat completion response format.
Requires a Node.js runtime. Server errors are retried according to PineconeConfiguration.maxRetries before streaming begins.
Messages and optional model, temperature, and file metadata filter.
An async iterable of completion chunks; each choice contains incremental updates in delta.
Errors.PineconeArgumentError if the messages or model fail validation.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const assistant = pc.assistant({ name: 'support-guide' });
const stream = await assistant.chatCompletionStream({
messages: [{ role: 'user', content: 'How do I return an order?' }],
});
for await (const chunk of stream) {
for (const choice of chunk.choices) {
if (choice.delta.content) console.log(choice.delta.content);
}
}
Assistant.chatCompletion for a complete response; Assistant.chatStream for structured citation chunks.
Streams an assistant answer and its structured citations.
Requires a Node.js runtime. Server errors are retried according to PineconeConfiguration.maxRetries before streaming begins.
Messages and optional model, file filter, and context settings.
An async iterable of message, content, citation, and completion chunks.
Errors.PineconeArgumentError if the messages or model fail validation.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const assistant = pc.assistant({ name: 'support-guide' });
const stream = await assistant.chatStream({
messages: [{ role: 'user', content: 'How do I return an order?' }],
});
for await (const chunk of stream) {
if (chunk.type === 'content_chunk') console.log(chunk.delta.content);
}
Assistant.chat for a complete answer; Assistant.chatCompletionStream for completion-style chunks.
Retrieves relevant context snippets without generating an answer.
A query or conversation messages, with optional file filter and snippet settings.
Relevant snippets with source references and usage information.
Errors.PineconeArgumentError if neither query nor messages is supplied.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const assistant = pc.assistant({ name: 'support-guide' });
const response = await assistant.context({ query: 'How do I return an order?' });
console.log(response.snippets);
Assistant.chat to generate an answer from the context.
Deletes a file from the assistant asynchronously.
The ID of the file to delete.
An operation to track deletion with Assistant.describeOperation.
Errors.PineconeArgumentError if fileId is empty.
Gets file details and processing status.
The file ID returned by an upload operation or file listing.
Include a signed download URL; defaults to true.
File details, including status and a download URL when requested.
Errors.PineconeArgumentError if fileId is empty.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const assistant = pc.assistant({ name: 'support-guide' });
const file = await assistant.describeFile('1a56ddd0-c6d8-4295-80c0-9bfd6f5cb87b');
console.log(file.status);
Assistant.listFiles to find file IDs.
Gets the current status of an asynchronous file operation.
Call again to check progress; this call does not wait for completion.
The operation ID returned by a file upload, upsert, deletion, or operation listing.
Operation details including status and any error.
Errors.PineconeArgumentError if operationId is empty.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const assistant = pc.assistant({ name: 'support-guide' });
const operation = await assistant.uploadFile({ path: 'returns-policy.pdf' });
const result = await assistant.describeOperation(operation.id);
console.log(result.status);
Assistant.listOperations to find operations.
Lists files uploaded to the assistant.
Optionaloptions: ListFilesOptions
Optional file metadata filter; omit to list files without filtering.
File details in files, including processing status.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const assistant = pc.assistant({ name: 'support-guide' });
const result = await assistant.listFiles({
filter: { category: { $eq: 'returns' } },
});
console.log(result.files);
Assistant.describeFile for details of one file.
Lists one page of asynchronous operations on the assistant.
Optionaloptions: ListOperationsOptions
Optional operation filters, page size, and pagination token.
Operations and pagination information; pass pagination.next as paginationToken for the next page.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const assistant = pc.assistant({ name: 'support-guide' });
const page = await assistant.listOperations({ status: 'Processing' });
console.log(page.operations);
if (page.pagination?.next) {
const nextPage = await assistant.listOperations({
status: 'Processing',
paginationToken: page.pagination.next,
});
console.log(nextPage.operations);
}
Assistant.describeOperation for the status of one operation.
Uploads a new file for the assistant to use.
Processing continues asynchronously; check the returned operation with Assistant.describeOperation. Stream inputs are sent in a single attempt.
A local path, or file plus fileName, with optional metadata and multimodal processing.
An operation whose id tracks processing and whose fileId identifies the file.
Errors.PineconeArgumentError if file input or its required filename is missing.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const assistant = pc.assistant({ name: 'support-guide' });
const operation = await assistant.uploadFile({
path: 'returns-policy.pdf',
metadata: { category: 'returns' },
});
console.log(operation.id);
Assistant.upsertFile to create or replace a file at an ID you supply.
Creates or replaces a file at an ID you supply.
Processing continues asynchronously; check the returned operation with Assistant.describeOperation. Stream inputs are sent in a single attempt.
The assistantFileId and a local path, or file plus fileName, with optional multimodal processing.
An operation whose id tracks processing and whose fileId identifies the file.
Errors.PineconeArgumentError if the file ID, file input, or required filename is missing.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const assistant = pc.assistant({ name: 'support-guide' });
const operation = await assistant.upsertFile({
assistantFileId: '1a56ddd0-c6d8-4295-80c0-9bfd6f5cb87b',
path: 'returns-policy.pdf',
});
console.log(operation.id);
Assistant.uploadFile to create a file with an assigned ID and optional metadata.
An assistant answers questions using the files you provide.
Access it through Pinecone.assistant; do not construct it directly. Use Assistants through
pc.assistantsto create and manage assistants.Example