Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Build a Q&A Bot over Your Company Docs with Pinecone + Claude (Python, SDK v10)

说明与用途

构建一个命令行问答机器人,使用 Pinecone 存储文档嵌入,检索并重新排序相关片段,并使用 Claude 生成带引用的答案。

问题

New hires cannot quickly find internal policies and current rules, and keyword‑based wiki search often fails to surface relevant documents.

结果

The script provides a ready‑to‑run pipeline that ingests markdown/text files, stores embeddings in Pinecone, retrieves and reranks relevant chunks, and generates cited answers with Claude, all while respecting Pinecone Starter plan limits.

工作流

  • Set up Pinecone and Anthropic API keys
  • Install dependencies (pinecone==10.3.0, anthropic==2.4.0)
  • Define environment variables (PINECONE_API_KEY, ANTHROPIC_API_KEY, optional PINECONE_INDEX, PINECONE_NAMESPACE, USE_RERANK)
  • Chunk documents using a 500‑char limit with 80‑char overlap
  • Upsert chunks into a Pinecone index (serverless, AWS us‑east‑1)
  • Query the index with a user question, retrieve top 12 chunks
  • Optionally rerank top 4 chunks with bge‑reranker‑v2‑m3
  • Build a prompt that includes the question and retrieved chunks
  • Send prompt to Claude (claude‑sonnet‑5‑5) via Messages API
  • Return answer with citations
  • Estimate costs and monitor rate limits

证据

Once a company has enough internal docs, the same problems show up: new hires can't find the leave policy, nobody remembers which version of the expense rules is current, and wiki search only works if you guess the exact words the author used

来源

This walkthrough builds a command-line Q&A bot with Pinecone (managed vector database with hosted embedding and rerank models) and Claude (Anthropic's LLM, for answer generation)

来源

The Pinecone SDK changed a lot in v10. Many tutorials still use the v5–v7 style (create_index_for_model, upsert_records, ServerlessSpec), which may fail or emit deprecation warnings.

来源

Embedding, storage and reranking all happen on Pinecone's side, so you don't install PyTorch or host an embedding model.

来源

  • 记录日期: 2026-11-04T02:13:53.878Z