Loading…
Loading…
Features · Connect · RAG
Wire shipit's RAG into an agent with one parameter, rag=. The agent gains rag_search, rag_fetch_chunk and rag_list_sources, and its prompt asks it to cite the passages it used.
from shipit_agent import Agentfrom shipit_agent.rag import RAG, HashingEmbedderrag = RAG.default(embedder=HashingEmbedder(dimension=512))rag.index_text("Shipit supports Python 3.10+.", source="readme.md")rag.index_text("Agents stream events in real time.", source="streaming.md")agent = Agent(llm=my_llm, rag=rag)
Index
text, files, PDFs
Hybrid search
vectors plus BM25
Agent
searches and reads
Answer
with [N] citations
The code is a checked example from the docs; the output is an example of what it prints.
from shipit_agent import Agent
from shipit_agent.rag import RAG, HashingEmbedder
rag = RAG.default(embedder=HashingEmbedder(dimension=512))
rag.index_text("Shipit supports Python 3.10+.", source="readme.md")
rag.index_text("Agents stream events in real time.", source="streaming.md")
agent = Agent(llm=my_llm, rag=rag)
result = agent.run("What Python version does Shipit support?")
print(result.output)6 more ways to use it
Each example is from the docs and checked against the library.
from shipit_agent import Agent
from shipit_agent.rag import RAG, HashingEmbedder
rag = RAG.default(embedder=HashingEmbedder(dimension=512))
rag.index_text("Shipit supports Python 3.10+.", source="readme.md")
rag.index_text("Agents stream events in real time.", source="streaming.md")
agent = Agent(llm=my_llm, rag=rag)
result = agent.run("What Python version does Shipit support?")
print(result.output)
# "Shipit supports Python 3.10+. [1]"
for src in result.rag_sources:
print(f"[{src.index}] {src.source} (chunk {src.chunk_id}, score {src.score:.2f})")
print(f" {src.text}")One parameter
rag= adds the search tools and the citation instructions.
Hybrid retrieval
Vector and keyword search, fused; a reranker is optional.
Your backends
Swap in Chroma, Qdrant, pgvector or your own store.
Shared indexes
One RAG can serve many agents at once.
| Parameter | Default | What it does |
|---|---|---|
| rag | None | A RAG the agent searches and cites. RAG with an agent. |