Skip to content

Latest commit

 

History

History
101 lines (74 loc) · 3.59 KB

File metadata and controls

101 lines (74 loc) · 3.59 KB

Framework integrations quickstart (Step 3.8)

Five minutes to plug the AgentContextOS gateway into your framework as a retriever or tool. All adapters live in the Python SDK under agentcontextos.integrations.<framework> and wrap agentcontextos.Client.

0. Start a gateway

uv run uvicorn rag_gateway.app:app --port 8000

1. Install only the integration you need

pip install "agentcontextos[langchain]"        # or [llama-index] / [haystack] / [dspy] /
                                               #    [langgraph] / [crewai] / [autogen] /
                                               #    [semantic-kernel]

pip install agentcontextos alone pulls in no framework — each integration is an optional extra.

2. LangChain — a retriever in three lines

from agentcontextos.integrations.langchain import AgentContextOSRetriever

retriever = AgentContextOSRetriever(
    base_url="http://localhost:8000", tenant_id="acme", principal_id="svc", top_k=5
)
docs = retriever.invoke("How do I rotate signing keys?")

Drop retriever into any chain (RetrievalQA, LCEL) or agent.

3. LlamaIndex / Haystack / DSPy

# LlamaIndex
from agentcontextos.integrations.llama_index import AgentContextOSRetriever
nodes = AgentContextOSRetriever(client=rag, top_k=5).retrieve("...")

# Haystack
from agentcontextos.integrations.haystack import AgentContextOSRetriever
docs = AgentContextOSRetriever(client=rag).run(query="...")["documents"]

# DSPy
import dspy
from agentcontextos.integrations.dspy import AgentContextOSRM
dspy.settings.configure(rm=AgentContextOSRM(client=rag, k=5))
passages = dspy.Retrieve(k=5)("...").passages

rag here is a configured agentcontextos.Client (see guides/sdk-quickstart.md); or pass base_url + identity kwargs instead of client=.

4. Tool-calling frameworks (CrewAI / AutoGen / Semantic Kernel)

These expose the gateway as a search tool the agent calls; it returns a numbered passage block.

# CrewAI
from agentcontextos.integrations.crewai import AgentContextOSSearchTool
tool = AgentContextOSSearchTool(client=rag, top_k=5)        # Agent(tools=[tool])

# AutoGen
from agentcontextos.integrations.autogen import make_search_function
search = make_search_function(client=rag, top_k=5)          # register with an AssistantAgent

# Semantic Kernel
from agentcontextos.integrations.semantic_kernel import AgentContextOSPlugin
kernel.add_plugin(AgentContextOSPlugin(client=rag, top_k=5), plugin_name="agentcontextos")

5. LangGraph — tool + node

from agentcontextos.integrations.langgraph import make_retrieval_tool, make_retrieval_node

tool = make_retrieval_tool(client=rag, top_k=5)             # for a ToolNode
node = make_retrieval_node(client=rag, input_key="question", output_key="docs")
# graph.add_node("retrieve", node)

Configuration recap

Every adapter accepts the same options: a client= (or base_url + tenant_id / principal_id / api_key) plus top_k, corpus_ids, rerank. Retrieval runs /v1/query with packing + generation off, so you get hydrated, scored chunks mapped to the framework's document type with consistent metadata (chunk_id, document_id, score, corpus_id, trust_level, …).

What's next