Compare commits
2 Commits
09939111a8
...
1af194f05d
| Author | SHA1 | Date | |
|---|---|---|---|
| 1af194f05d | |||
| 46171a9a2b |
@@ -59,11 +59,10 @@ def embed(text, input_type):
|
|||||||
assert resp.embeddings.float_ is not None
|
assert resp.embeddings.float_ is not None
|
||||||
return resp.embeddings.float_[0]
|
return resp.embeddings.float_[0]
|
||||||
|
|
||||||
def search(query, roles: list[str], limit: int = 5) -> list[dict]:
|
def search(query, roles: list[str], limit: int = 3, max_content_length: int = 1500) -> list[dict]:
|
||||||
query_embedding = embed(query, 'search_query')
|
query_embedding = embed(query, 'search_query')
|
||||||
|
|
||||||
if not roles:
|
if not roles:
|
||||||
# No roles = no results
|
|
||||||
return []
|
return []
|
||||||
|
|
||||||
rows = conn.execute(
|
rows = conn.execute(
|
||||||
@@ -71,7 +70,13 @@ def search(query, roles: list[str], limit: int = 5) -> list[dict]:
|
|||||||
(roles, query_embedding, limit)
|
(roles, query_embedding, limit)
|
||||||
).fetchall()
|
).fetchall()
|
||||||
|
|
||||||
return [{'key': row['key'], 'content': row['content']} for row in rows]
|
docs = []
|
||||||
|
for row in rows:
|
||||||
|
content = row['content'] or ''
|
||||||
|
if len(content) > max_content_length:
|
||||||
|
content = content[:max_content_length] + '...[truncated, use get_document_page for full text]'
|
||||||
|
docs.append({'key': row['key'], 'content': content})
|
||||||
|
return docs
|
||||||
|
|
||||||
@mcp.tool
|
@mcp.tool
|
||||||
def get_cave_location(cave: str, state: str, county: str) -> list[dict]:
|
def get_cave_location(cave: str, state: str, county: str) -> list[dict]:
|
||||||
|
|||||||
@@ -64,13 +64,13 @@ def check_mcp_available(url: str, timeout: float = 5.0) -> bool:
|
|||||||
AGENT_INSTRUCTIONS = """Caving assistant. Help with exploration, safety, surveying, locations, geology, equipment, history, conservation.
|
AGENT_INSTRUCTIONS = """Caving assistant. Help with exploration, safety, surveying, locations, geology, equipment, history, conservation.
|
||||||
|
|
||||||
Rules:
|
Rules:
|
||||||
1. Cite sources when possible.
|
1. ALWAYS cite sources at the end of every reply. Use the 'key' from search results (e.g., "Source: vpi/trog/2021-trog.pdf/page-19.pdf").
|
||||||
2. Say when uncertain. Never hallucinate.
|
2. Say when uncertain. Never hallucinate.
|
||||||
3. Be safety-conscious.
|
3. Be safety-conscious.
|
||||||
4. Can create ascii diagrams/maps.
|
4. Can create ascii diagrams/maps.
|
||||||
5. Be direct—no sycophantic phrases.
|
5. Be direct—no sycophantic phrases.
|
||||||
6. Keep responses concise.
|
6. Keep responses concise.
|
||||||
7. Use tools sparingly—one search usually suffices. Answer from your knowledge when possible."""
|
7. Use tools sparingly—one search usually suffices."""
|
||||||
|
|
||||||
|
|
||||||
def create_agent(user_roles: list[str] | None = None):
|
def create_agent(user_roles: list[str] | None = None):
|
||||||
|
|||||||
Reference in New Issue
Block a user