Skip to content

Commit afb7c85

Browse files
authored
fix: optimize tool desc (#26)
1 parent 5652088 commit afb7c85

File tree

7 files changed

+162
-8
lines changed

7 files changed

+162
-8
lines changed

opencontext/tools/operation_tools/web_search_tool.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,41 @@ def get_name(cls) -> str:
4343

4444
@classmethod
4545
def get_description(cls) -> str:
46-
return "Search the internet for the latest information. Supports keyword search, returns relevant webpage titles, summaries, and links. Suitable for obtaining real-time information, news, technical documentation, etc."
46+
return """Internet search tool for retrieving real-time information from the web. Returns relevant webpage titles, snippets, and URLs based on search queries.
47+
48+
**When to use this tool:**
49+
- When you need current, real-time information not in the local knowledge base
50+
- When looking for recent news, events, or updates
51+
- When seeking external references, documentation, or resources
52+
- When the user's question requires up-to-date information beyond the system's stored context
53+
- When verifying facts or finding additional sources
54+
55+
**When NOT to use this tool:**
56+
- For searching stored contexts or history → use text_search, filter_context
57+
- For entity lookups within the system → use profile_entity instead
58+
- When the answer can be found in local context → prioritize local tools first
59+
- For information that doesn't require real-time data
60+
61+
**Key features:**
62+
- Keyword-based web search with natural language support
63+
- Returns webpage titles, summaries, and links
64+
- Configurable result count (1-20, default 5)
65+
- Language preference support (zh-cn, en, ja, etc.)
66+
- Uses DuckDuckGo for privacy-focused search
67+
- Automatic proxy support for restricted networks
68+
69+
**Best practices:**
70+
- Use specific, focused search queries for better results
71+
- Specify language preference when appropriate
72+
- Combine with local search tools to provide comprehensive answers
73+
- Use when local context is insufficient or outdated
74+
75+
**Use cases:**
76+
- "What's the latest news about AI developments?" → web_search
77+
- "Find documentation for library X version Y" → web_search
78+
- "What happened in the world today?" → web_search
79+
- "Current price of Bitcoin" → web_search
80+
"""
4781

4882
@classmethod
4983
def get_parameters(cls) -> Dict[str, Any]:

opencontext/tools/profile_tools/profile_entity_tool.py

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,49 @@ def get_name(cls) -> str:
4545

4646
@classmethod
4747
def get_description(cls) -> str:
48-
return "Unified entity management tool, supports exact search, similar search, relationship checking, creation and update of entities"
48+
return """Entity profile management tool for finding, matching, and exploring entities (people, projects, organizations, etc.) and their relationships. Provides intelligent entity resolution and relationship network analysis.
49+
50+
**When to use this tool:**
51+
- When you need detailed information about a specific entity (person, project, team, organization)
52+
- When resolving entity names to their canonical forms (e.g., "John" → "John Smith")
53+
- When checking relationships between two entities (e.g., "Is Alice related to Project X?")
54+
- When exploring an entity's relationship network (friends, collaborators, team members)
55+
- When finding similar entities based on names or descriptions
56+
57+
**When NOT to use this tool:**
58+
- For general content searches → use text_search instead
59+
- For time-based filtering → use filter_context instead
60+
- When searching for contexts mentioning entities → use text_search or filter_context with entity filter
61+
62+
**Supported operations:**
63+
- **find_exact_entity**: Lookup entity by exact canonical name or alias
64+
- **find_similar_entity**: Find entities with similar names or descriptions (fuzzy matching)
65+
- **match_entity**: Intelligent entity resolution (exact match → semantic search → LLM-based judgment)
66+
- **check_entity_relationships**: Check if two entities are related and how
67+
- **get_entity_relationship_network**: Explore entity's relationship graph with configurable depth (1-5 hops)
68+
69+
**Key features:**
70+
- Canonical name resolution with alias support
71+
- Intelligent fuzzy matching and entity disambiguation
72+
- Relationship type identification (colleague, team_member, supervisor, etc.)
73+
- Multi-hop relationship network traversal
74+
- Entity metadata enrichment (description, properties, relationships)
75+
- LLM-powered entity matching for ambiguous cases
76+
77+
**Entity types supported:**
78+
- person (people, individuals, users)
79+
- project (projects, initiatives, products)
80+
- team (teams, groups, departments)
81+
- organization (companies, institutions, external entities)
82+
- other (generic named entities)
83+
84+
**Use cases:**
85+
- "Who is Alice?" → find_exact_entity
86+
- "Find people similar to 'John'" → find_similar_entity
87+
- "Match 'XYZ Corp' to known organization" → match_entity
88+
- "Are Alice and Bob related?" → check_entity_relationships
89+
- "Show me Bob's network of collaborators" → get_entity_relationship_network
90+
"""
4991

5092
@classmethod
5193
def get_parameters(cls) -> Dict[str, Any]:

opencontext/tools/retrieval_tools/document_retrieval_tool.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,40 @@ def get_name(cls) -> str:
4848
@classmethod
4949
def get_description(cls) -> str:
5050
"""Get tool description - dynamically generate supported context types"""
51-
return "Document retrieval tool providing document-level and chunk-level exact and semantic search. Supports raw_id retrieval, document aggregation and context expansion"
51+
return """Document-level retrieval tool specialized for finding and aggregating information from structured documents. Retrieves by document identifiers or searches semantically across document chunks with intelligent aggregation.
52+
53+
**When to use this tool:**
54+
- When you need to retrieve a specific document by its identifier (raw_type and raw_id)
55+
- When searching within document collections (e.g., "find documents about project planning")
56+
- When you want document-level aggregation rather than scattered chunks
57+
- When exploring related document chunks with context expansion
58+
- When retrieving from specific document types (vaults, files, etc.)
59+
60+
**When NOT to use this tool:**
61+
- For general context searches across all types → use text_search or filter_context instead
62+
- For entity-specific lookups → use profile_entity instead
63+
- For simple time-based filtering → use filter_context instead
64+
65+
**Retrieval modes:**
66+
- **document**: Retrieves and aggregates at document level (best for getting complete documents)
67+
- **chunk**: Returns individual chunks without aggregation (best for precise chunk-level results)
68+
- **hybrid**: Combines chunk-level precision with document-level aggregation (balanced approach)
69+
- **context**: Expands search to include related chunks from same document (best for comprehensive context)
70+
71+
**Key features:**
72+
- Document-level aggregation (groups chunks by raw_id)
73+
- Supports both exact match (by raw_id) and semantic search
74+
- Context expansion to find related chunks within documents
75+
- Flexible filtering by document type (raw_type), entities, and time range
76+
- Configurable aggregation and result count (top_k: 1-100, default 10)
77+
- Returns document metadata including chunk count and relevance scores
78+
79+
**Use cases:**
80+
- "Get document by vault ID 'abc123'"
81+
- "Find all notes about machine learning with document aggregation"
82+
- "Search within technical documentation with context expansion"
83+
- "Retrieve chunks from specific file type with high relevance scores"
84+
"""
5285

5386
@classmethod
5487
def get_parameters(cls) -> Dict[str, Any]:

opencontext/tools/retrieval_tools/filter_context_tool.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,29 @@ def get_description(cls) -> str:
3434
desc_info = ContextSimpleDescriptions[context_type]
3535
context_descriptions.append(f"- {context_type.value}: {desc_info['description']}")
3636
descriptions_text = '\n'.join(context_descriptions)
37-
return f"""Directly retrieve context records of specified types through precise filter conditions without semantic matching. Suitable for exact retrieval scenarios with clear query conditions, such as searching by time range, filtering by entities, retrieving by context type, and other structured queries. Supports multi-dimensional combination filtering and flexible sorting methods, efficiently locating target records from large amounts of data. Supports the following context types:\n{descriptions_text}"""
37+
return f"""Direct filter-based retrieval tool that returns records matching exact criteria without semantic analysis. Uses structured filtering for precise, deterministic results.
38+
39+
**When to use this tool:**
40+
- When you need records from a specific time range (e.g., "all activities from yesterday", "contexts between 10am-2pm")
41+
- When filtering by specific entities (e.g., "contexts mentioning person X", "all records related to project Y")
42+
- When you need to retrieve all records of a specific context type without searching by content
43+
- When combining multiple exact filters (time + entities + type)
44+
- When you want chronologically sorted results (newest/oldest first)
45+
46+
**When NOT to use this tool:**
47+
- For semantic or conceptual searches → use text_search instead
48+
- When query involves understanding meaning or intent → use text_search instead
49+
50+
**Key features:**
51+
- Supports precise time range filtering with flexible time types (event_time, create_time, update_time)
52+
- Supports entity-based filtering (find all contexts mentioning specific people/projects)
53+
- Configurable sort order (time ascending/descending, update time ascending/descending)
54+
- Returns results deterministically based on filter criteria
55+
- Efficient for large-scale filtering operations
56+
- Configurable result count (top_k: 1-100, default 20)
57+
58+
**Supported context types:**
59+
{descriptions_text}"""
3860

3961
@classmethod
4062
def get_parameters(cls) -> Dict[str, Any]:

opencontext/tools/retrieval_tools/text_search_tool.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,38 @@ def get_description(cls) -> str:
3434
desc_info = ContextSimpleDescriptions[context_type]
3535
context_descriptions.append(f"- {context_type.value}: {desc_info['description']}")
3636
descriptions_text = '\n'.join(context_descriptions)
37-
return f"""Intelligent semantic search using natural language queries, finding the most relevant content from specified types of context records based on vector similarity matching. Suitable for fuzzy queries, concept search, content understanding and other scenarios, capable of understanding query intent and returning semantically related results. Supports advanced features such as time range filtering and entity screening. Supports the following context types:\n{descriptions_text}"""
37+
return f"""Semantic search tool for finding contextually relevant information using natural language queries. Returns ranked results based on meaning and relevance rather than exact keyword matches.
38+
39+
**When to use this tool:**
40+
- When the query involves concepts, themes, or topics (e.g., "learning activities about machine learning", "discussions about project planning")
41+
- When looking for information semantically related to a description or question
42+
- When exact keywords are unknown but the general topic or meaning is clear
43+
- When exploring historical activities, knowledge, or discussions by topic
44+
- When filtering by context type (activity, intent, semantic, procedural, state, entity)
45+
- When time-based filtering or entity screening is needed
46+
47+
**When NOT to use this tool:**
48+
- For precise entity lookups → use profile_entity instead
49+
- For structured data filtering → use filter_context instead
50+
51+
**Key features:**
52+
- Understands query intent and finds semantically similar content
53+
- Supports time range filtering (start/end timestamps with timezone)
54+
- Supports entity-based filtering (find contexts mentioning specific people/projects)
55+
- Configurable result count (top_k: 1-100, default 20)
56+
57+
**Supported context types:**
58+
{descriptions_text}"""
3859

3960
@classmethod
4061
def get_parameters(cls) -> Dict[str, Any]:
4162
"""Get tool parameter definitions"""
4263
# Dynamically generate context_type description
4364
context_descriptions = []
4465
for context_type in ContextType:
45-
desc_info = ContextSimpleDescriptions[context_type]
66+
if context_type == ContextType.ENTITY_CONTEXT:
67+
continue
68+
desc_info = ContextSimpleDescriptions[context_type.value]
4669
context_descriptions.append(f"- {context_type.value}: {desc_info['description']}. {desc_info['purpose']}")
4770
context_type_desc = "Detailed description of context types:\n" + '\n'.join(context_descriptions)
4871

opencontext/tools/tool_definitions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
BASIC_RETRIEVAL_TOOLS = [
1010
{"type": "function", "function": TextSearchTool.get_definition()},
1111
{"type": "function", "function": FilterContextTool.get_definition()},
12-
{"type": "function", "function": DocumentRetrievalTool.get_definition()},
12+
# {"type": "function", "function": DocumentRetrievalTool.get_definition()},
1313
]
1414

1515
ALL_RETRIEVAL_TOOL_DEFINITIONS = (

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ dependencies = [
3131
"openai",
3232
"jinja2",
3333
"json-repair",
34-
"duckduckgo-search",
34+
"ddgs",
3535
"pypdf",
3636
"openpyxl",
3737
"chromadb",

0 commit comments

Comments
 (0)