mirror of
https://github.com/katanemo/plano.git
synced 2026-06-23 15:38:07 +02:00
pending tmo work
This commit is contained in:
parent
bb71d041a0
commit
22c84fb689
17 changed files with 1626 additions and 94 deletions
0
demos/use_cases/rag_agent/README.md
Normal file
0
demos/use_cases/rag_agent/README.md
Normal file
38
demos/use_cases/rag_agent/arch_config.yaml
Normal file
38
demos/use_cases/rag_agent/arch_config.yaml
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
version: v0.1.0
|
||||
|
||||
agents:
|
||||
- name: rag_assistant
|
||||
description: t-mobile virtual assistant for device contracts.
|
||||
instructions: |
|
||||
You are a virtual assistant, here to help users answer questions from device contracts team.
|
||||
Use following instructions to process the user request,
|
||||
1. Use query_processor_agent to understand user queries
|
||||
2. Use search_documents to fetch relevant information
|
||||
3. Use response_generator_agent to formulate clear responses
|
||||
model: openai/gpt-4o
|
||||
tools:
|
||||
- name: query_processor_agent
|
||||
# Parses user queries and extracts metadata, also handles clarification workflow
|
||||
protocol: mcp
|
||||
endpoint: https://localhost:10500
|
||||
- name: search_documents
|
||||
# Searches the document store for relevant information
|
||||
protocol: mcp
|
||||
endpoint: https://localhost:10501
|
||||
- name: response_generator_agent
|
||||
# Generates a final response based on user query and retrieved context
|
||||
protocol: mcp
|
||||
endpoint: https://localhost:10502
|
||||
listener:
|
||||
port: 8000
|
||||
protocol: openai
|
||||
path: /v1/chat/completions
|
||||
|
||||
llm_providers_v2:
|
||||
default:
|
||||
listener:
|
||||
port: 12000
|
||||
protocol: openai
|
||||
providers:
|
||||
- access_key: ${OPENAI_API_KEY}
|
||||
model: openai/gpt-4o
|
||||
4
demos/use_cases/rag_agent/cookies.txt
Normal file
4
demos/use_cases/rag_agent/cookies.txt
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# Netscape HTTP Cookie File
|
||||
# https://curl.se/docs/http-cookies.html
|
||||
# This file was generated by libcurl! Edit at your own risk.
|
||||
|
||||
19
demos/use_cases/rag_agent/pyproject.toml
Normal file
19
demos/use_cases/rag_agent/pyproject.toml
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
[project]
|
||||
name = "rag_agent"
|
||||
version = "0.1.0"
|
||||
description = "RAG Agent"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.10"
|
||||
dependencies = [
|
||||
"click>=8.2.1",
|
||||
"mcp>=1.13.1",
|
||||
"fastmcp>=2.12.2",
|
||||
"pydantic>=2.11.7",
|
||||
]
|
||||
|
||||
[project.scripts]
|
||||
rag_agent = "rag_agent:main"
|
||||
|
||||
[build-system]
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
30
demos/use_cases/rag_agent/src/rag_agent/__init__.py
Normal file
30
demos/use_cases/rag_agent/src/rag_agent/__init__.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import click
|
||||
from mcp.server.fastmcp import FastMCP
|
||||
|
||||
mcp = None
|
||||
|
||||
@click.command()
|
||||
@click.option('--transport', 'transport', default='stdio')
|
||||
@click.option('--host', 'host', default='localhost')
|
||||
@click.option('--port', 'port', default=10101)
|
||||
@click.option('--agent', 'agent', default=None)
|
||||
def main(host, port, agent, transport):
|
||||
print(f"Starting agent(s): {agent if agent else 'all'}")
|
||||
global mcp
|
||||
mcp = FastMCP("RAG Agent Demo", host=host, port=port)
|
||||
|
||||
if agent == "query_parser":
|
||||
import rag_agent.query_parser
|
||||
elif agent == "document_store":
|
||||
import rag_agent.document_store
|
||||
elif agent == "response_generator":
|
||||
import rag_agent.response_generator
|
||||
else:
|
||||
import rag_agent.query_parser
|
||||
import rag_agent.document_store
|
||||
import rag_agent.response_generator
|
||||
print("All agents loaded.")
|
||||
mcp.run(transport=transport)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
16
demos/use_cases/rag_agent/src/rag_agent/document_store.py
Normal file
16
demos/use_cases/rag_agent/src/rag_agent/document_store.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
from pydantic import BaseModel
|
||||
from . import mcp
|
||||
|
||||
class QueryRequest(BaseModel):
|
||||
query: str
|
||||
metadata: dict | None = None
|
||||
|
||||
|
||||
class QueryResponse(BaseModel):
|
||||
query: str
|
||||
results: list
|
||||
|
||||
@mcp.tool()
|
||||
def query_rag_store(request: QueryRequest):
|
||||
"""Query the RAG document store."""
|
||||
return {"query": request.query, "results": []}
|
||||
13
demos/use_cases/rag_agent/src/rag_agent/query_parser.py
Normal file
13
demos/use_cases/rag_agent/src/rag_agent/query_parser.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
from pydantic import BaseModel
|
||||
from . import mcp
|
||||
|
||||
class Response(BaseModel):
|
||||
query: str
|
||||
metadata: dict
|
||||
|
||||
@mcp.tool()
|
||||
def parse_query(query):
|
||||
"""Parse the user query and returns metadata extracted from query."""
|
||||
return Response(query=query, metadata={
|
||||
"is_valid": True
|
||||
})
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
from . import mcp
|
||||
|
||||
@mcp.tool()
|
||||
def generate_response(query, context):
|
||||
"""Generate a response based on the user query and context."""
|
||||
return {"query": query, "context": context, "response": "This is a generated response."}
|
||||
35
demos/use_cases/rag_agent/test.hurl
Normal file
35
demos/use_cases/rag_agent/test.hurl
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
# Step 1: Initialize session
|
||||
POST http://localhost:10101/mcp
|
||||
Content-Type: application/json
|
||||
Accept: application/json, text/event-stream
|
||||
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"method": "initialize",
|
||||
"params": {
|
||||
"protocolVersion": "2024-11-05",
|
||||
"capabilities": {},
|
||||
"clientInfo": {
|
||||
"name": "ExampleClient",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HTTP 200
|
||||
[Captures]
|
||||
session_id: header "mcp-session-id"
|
||||
|
||||
# # Step 2: List tools (use session ID from previous response)
|
||||
POST http://localhost:10101/mcp
|
||||
Content-Type: application/json
|
||||
Accept: application/json, text/event-stream
|
||||
mcp-session-id: 07603206a9b44a3d91d76f6b16f24faa
|
||||
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 2,
|
||||
"method": "tools/list",
|
||||
"params": {}
|
||||
}
|
||||
31
demos/use_cases/rag_agent/test.rest
Normal file
31
demos/use_cases/rag_agent/test.rest
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
### Step 1: Initialize session
|
||||
POST http://localhost:10101/mcp
|
||||
Content-Type: application/json
|
||||
Accept: application/json, text/event-stream
|
||||
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"method": "initialize",
|
||||
"params": {
|
||||
"protocolVersion": "2024-11-05",
|
||||
"capabilities": {},
|
||||
"clientInfo": {
|
||||
"name": "ExampleClient",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
### Step 2: List tools (use session ID from previous response)
|
||||
POST http://localhost:10101/mcp
|
||||
Content-Type: application/json
|
||||
Accept: application/json, text/event-stream
|
||||
mcp-session-id: af2e2dace64c48f99ac3536faeaa3c68
|
||||
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 2,
|
||||
"method": "tools/list",
|
||||
"params": {}
|
||||
}
|
||||
1224
demos/use_cases/rag_agent/uv.lock
generated
Normal file
1224
demos/use_cases/rag_agent/uv.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
0
demos/use_cases/travel_assistant_uv/weather.py
Normal file
0
demos/use_cases/travel_assistant_uv/weather.py
Normal file
Loading…
Add table
Add a link
Reference in a new issue