Skip to content

Commit 6d2b05b

Browse files
authored
Checkpoint from Copilot CLI for coding agent session (#77)
1 parent ddceabd commit 6d2b05b

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

plans/castchat.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# castchat
2+
3+
### Overview
4+
5+
With podcast episodes transcribed and the transcription data indexed,
6+
we want an interactive REPL to ask questions of the indexed data.
7+
8+
We use chromadb and PydanticAI to implement the tool enabled and RAG
9+
based chat for cli application named `castchat`. We want to be able to
10+
invoke this cli as a subcommand of retrocast, e.g. `retrocast
11+
castchat`.
12+
13+
Below is an example of creating a tool to integrate with Pydantic’s
14+
`clai` agentic REPL toolkit.
15+
16+
```python
17+
from pydantic_ai import Agent
18+
from pydantic_ai.models.anthropic import AnthropicModel
19+
import chromadb
20+
21+
# Setup ChromaDB
22+
chroma_client = chromadb.Client()
23+
collection = chroma_client.get_or_create_collection("docs")
24+
25+
# Add sample documents (do this once)
26+
collection.add(
27+
documents=[
28+
"Our refund policy: Full refunds within 30 days of purchase",
29+
"Customer support: Email [email protected] or call 1-800-HELP",
30+
"Shipping: Free shipping on orders over $50, 5-7 business days"
31+
],
32+
ids=["doc1", "doc2", "doc3"]
33+
)
34+
35+
# Create agent
36+
model = AnthropicModel('claude-sonnet-4-20250514')
37+
agent = Agent(model=model)
38+
39+
@agent.tool
40+
def search_docs(query: str) -> str:
41+
"""Search internal documentation for relevant information.
42+
43+
Args:
44+
query: The search query text
45+
"""
46+
results = collection.query(
47+
query_texts=[query],
48+
n_results=3
49+
)
50+
51+
if results["documents"] and results["documents"][0]:
52+
docs = "\n\n".join(results["documents"][0])
53+
return f"Found relevant documentation:\n{docs}"
54+
return "No relevant documents found"
55+
```
56+
57+
Here’s an example of firing up `clai` to interact using that tool
58+
59+
````bash
60+
# Start interactive session
61+
clai --agent search_agent.py:agent
62+
63+
# Or specify model explicitly
64+
clai --agent search_agent.py:agent --model anthropic:claude-sonnet-4-20250514
65+
```
66+
67+
**3. Example conversation:**
68+
```
69+
You: What's the refund policy?
70+
Agent: [calls search_docs tool, then responds with the policy]
71+
72+
You: How do I contact support?
73+
Agent: [searches and provides contact info]
74+
````
75+
76+

0 commit comments

Comments
 (0)