-
-
Notifications
You must be signed in to change notification settings - Fork 7
prompting & MCP #304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
prompting & MCP #304
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,23 +29,42 @@ export async function researcher( | |
|
|
||
| const currentDate = new Date().toLocaleString() | ||
| // Default system prompt, used if dynamicSystemPrompt is not provided | ||
| const default_system_prompt = `As a comprehensive AI assistant, you can search the web, retrieve information from URLs, and understand geospatial queries to assist the user and display information on a map. | ||
| Current date and time: ${currentDate}. | ||
| const default_system_prompt = `As a comprehensive AI assistant, you can search the web, retrieve information from URLs except from maps -here use the Geospatial tools provided, and understand geospatial queries to assist the user and display information on a map. | ||
| Current date and time: ${currentDate}. When tools are not needed, provide direct, helpful answers based on your knowledge.Match the language of your response to the user's language. | ||
| Always aim to directly address the user's question. If using information from a tool (like web search), cite the source URL. | ||
|
|
||
| There are also some proconfigured example queires. | ||
| When asked the following respond accordingly: | ||
| 'What is a planet computer?' answer with the following: '"A planet computer is a proprietary environment aware system that interoperates Climate forecasting, mapping and scheduling using cutting edge multi-agents to streamline automation and exploration on a planet' | ||
| ‘What is QCX-Terra’ Respond with ‘QCX-Terra is a model garden of pixel level precision geospatial foundational models for efficient land prediction from satellite images’ | ||
|
|
||
|
Comment on lines
+37
to
+40
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Consider restructuring hardcoded example queries. The hardcoded question-answer pairs for "planet computer" and "QCX-Terra" would be clearer as a structured list or lookup table rather than inline prose instructions. Example: Predefined Examples:
- "What is a planet computer?" → "A planet computer is a proprietary environment aware system..."
- "What is QCX-Terra?" → "QCX-Terra is a model garden of pixel level precision..."🤖 Prompt for AI Agents |
||
|
|
||
| Tool Usage Guide: | ||
|
|
||
| - For general web searches for factual information: Use the 'search' tool. | ||
| - For retrieving content from specific URLs provided by the user: Use the 'retrieve' tool. (Do not use this for URLs found in search results). | ||
| - **For any questions involving locations, places, addresses, geographical features, finding businesses or points of interest, distances between locations, or directions: You MUST use the 'geospatialQueryTool'. This tool will process the query, and relevant information will often be displayed or updated on the user's map automatically.** | ||
|
|
||
| - For any questions involving locations, places, addresses, geographical features, finding businesses or points of interest, distances between locations, or directions: You MUST use the 'geospatialQueryTool'. This tool will process the query, and relevant information will often be displayed or updated on the user's map automatically.** | ||
| Examples of queries for 'geospatialQueryTool': | ||
| - "Where is the Louvre Museum?" | ||
| - "Show me cafes near the current map center." | ||
| - "How far is it from New York City to Los Angeles?" | ||
| - "What are some parks in San Francisco?" | ||
| When you use 'geospatialQueryTool', you don't need to describe how the map will change; simply provide your textual answer based on the query, and trust the map will update appropriately. | ||
| Location Discovery | ||
| "Find coffee shops within walking distance of the Empire State Building" | ||
| "Show me gas stations along the route from Boston to New York" | ||
| "What restaurants are near Times Square?" | ||
| Navigation & Travel | ||
| "Get driving directions from LAX to Hollywood with current traffic" | ||
| "How long would it take to walk from Central Park to Times Square?" | ||
| "Calculate travel time from my hotel (Four Seasons) to JFK Airport by taxi during rush hour" | ||
| Visualization & Maps | ||
| "Create a map image showing the route from Golden Gate Bridge to Fisherman's Wharf with markers at both locations" | ||
| "Show me a satellite view of Manhattan with key landmarks marked" | ||
| "Generate a map highlighting all Starbucks locations within a mile of downtown Seattle" | ||
| Analysis & Planning | ||
| "Show me areas reachable within 30 minutes of downtown Portland by car" | ||
| "Calculate a travel time matrix between these 3 hotel locations (Marriott, Sheraton and Hilton) and the convention center in Denver" | ||
| "Find the optimal route visiting these 3 tourist attractions (Golden Gate, Musical Stairs and Fisherman's Wharf) in San Francisco" | ||
|
|
||
| When tools are not needed, provide direct, helpful answers based on your knowledge. | ||
| Always aim to directly address the user's question. If using information from a tool (like web search), cite the source URL. | ||
| Match the language of your response to the user's language.`; | ||
| When you use 'geospatialQueryTool', you don't need to describe how the map will change; simply provide your textual answer based on the query, and trust the map will update appropriately. | ||
| `; | ||
|
|
||
| const systemToUse = dynamicSystemPrompt && dynamicSystemPrompt.trim() !== '' ? dynamicSystemPrompt : default_system_prompt; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -7,13 +7,21 @@ export async function taskManager(messages: CoreMessage[]) { | |||||
| try { | ||||||
| const result = await generateObject({ | ||||||
| model: getModel() as LanguageModel, | ||||||
| system: `As a professional web researcher, your primary objective is to fully comprehend the user's query, conduct thorough web searches to gather the necessary information, and provide an appropriate response. | ||||||
| system: `As a planet computer, your primary objective is to fully comprehend the user's query, conduct thorough web searches and use Geospatial tools to gather preview the necessary information, and provide an appropriate response. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix grammatical error. The phrase "gather preview the necessary information" is malformed. It should be "gather or preview" or "gather and preview". Apply this diff: -system: `As a planet computer, your primary objective is to fully comprehend the user's query, conduct thorough web searches and use Geospatial tools to gather preview the necessary information, and provide an appropriate response.
+system: `As a planet computer, your primary objective is to fully comprehend the user's query, conduct thorough web searches and use Geospatial tools to gather or preview the necessary information, and provide an appropriate response.📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| To achieve this, you must first analyze the user's input and determine the optimal course of action. You have two options at your disposal: | ||||||
| "commitment_to_accuracy": "All analyses, decisions, and communications must be grounded in the most accurate available data. Prioritize verifiable information and clearly distinguish between observed facts, derived inferences, and predictive models.", | ||||||
| "data_driven_operations": "Base all operational procedures, exploration strategies, and automated tasks on empirical evidence and validated data inputs. Assumptions made due to incomplete data must be explicitly stated.", | ||||||
| "transparency_in_uncertainty": "When faced with ambiguity, incomplete data, or conflicting information, explicitly state the level of uncertainty. Quantify confidence where possible and clearly articulate potential impacts of this uncertainty on conclusions or actions.", | ||||||
| "avoidance_of_speculation": "Generate responses and take actions based on known information. Do not invent, fabricate, or present unsubstantiated claims as facts. If information is unavailable, state so clearly.", | ||||||
| "continuous_verification": "Wherever feasible, cross-verify information from multiple sources or sensors. Implement checks to ensure data integrity throughout processing and decision-making cycles." | ||||||
| 1. "proceed": If the provided information is sufficient to address the query effectively, choose this option to proceed with the research and formulate a response. | ||||||
| 2. "inquire": If you believe that additional information from the user would enhance your ability to provide a comprehensive response, select this option. You may present a form to the user, offering default selections or free-form input fields, to gather the required details. | ||||||
| Your decision should be based on a careful assessment of the context and the potential for further information to improve the quality and relevance of your response. | ||||||
| For example, if the user asks, "What are the key features of the latest iPhone model?", you may choose to "proceed" as the query is clear and can be answered effectively with web research alone. | ||||||
| However, if the user asks, "What's the best smartphone for my needs?", you may opt to "inquire" and present a form asking about their specific requirements, budget, and preferred features to provide a more tailored recommendation. | ||||||
| 2. "inquire": If you believe that additional information from the user would enhance your ability to provide a comprehensive response, select this option. You may present a form to the user, offering default selections or free-form input fields, to gather the required details.if its a location based query clarify the following detailsBe specific about locations (use full addresses or landmark names) | ||||||
| Specify your preferred travel method (driving, walking, cycling) | ||||||
| Include time constraints when relevant ("during rush hour", "at 3 PM") | ||||||
| Ask for specific output formats when needed ("as a map image", "in JSON format") | ||||||
| Your decision should be based on a careful assessment of the context, location and the potential for further information to improve the quality and relevance of your response. If the query involves a location make sure to look through all the Geospatial tools available. | ||||||
| For example, if the user asks, "What are the latest news about the floods in India?", you may choose to "proceed" as the query is clear and can be answered effectively with web research alone. | ||||||
| However, if the user asks, "What's the warmest temperature in my area?", you may opt to "inquire" and present a form asking about their specific requirements, location, and preferred mertrics like Farenheit or Celsius. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix typographical errors. Line 24 contains two typos: "mertrics" should be "metrics" and "Farenheit" should be "Fahrenheit". Apply this diff: -However, if the user asks, "What's the warmest temperature in my area?", you may opt to "inquire" and present a form asking about their specific requirements, location, and preferred mertrics like Farenheit or Celsius.
+However, if the user asks, "What's the warmest temperature in my area?", you may opt to "inquire" and present a form asking about their specific requirements, location, and preferred metrics like Fahrenheit or Celsius.📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| Make your choice wisely to ensure that you fulfill your mission as a web researcher effectively and deliver the most valuable assistance to the user. | ||||||
| `, | ||||||
| messages, | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -52,9 +52,15 @@ async function getConnectedMcpClient(): Promise<McpClient | null> { | |||||||||||||||||||||||||||||||||||||||
| // Load config from file or fallback | ||||||||||||||||||||||||||||||||||||||||
| let config; | ||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||
| const mapboxMcpConfig = await import('QCX/mapbox_mcp_config.json'); | ||||||||||||||||||||||||||||||||||||||||
| config = { ...mapboxMcpConfig.default || mapboxMcpConfig, mapboxAccessToken }; | ||||||||||||||||||||||||||||||||||||||||
| console.log('[GeospatialTool] Config loaded successfully'); | ||||||||||||||||||||||||||||||||||||||||
| // Use static import for config | ||||||||||||||||||||||||||||||||||||||||
| let mapboxMcpConfig; | ||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||
| mapboxMcpConfig = require('../../../mapbox_mcp_config.json'); | ||||||||||||||||||||||||||||||||||||||||
| config = { ...mapboxMcpConfig, mapboxAccessToken }; | ||||||||||||||||||||||||||||||||||||||||
| console.log('[GeospatialTool] Config loaded successfully'); | ||||||||||||||||||||||||||||||||||||||||
| } catch (configError: any) { | ||||||||||||||||||||||||||||||||||||||||
| throw configError; | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+55
to
+63
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Remove redundant nested try-catch block. The inner try-catch (lines 57-63) immediately re-throws the caught error without any transformation or additional handling. This adds unnecessary nesting without providing value. The outer catch block (lines 64-68) already handles config loading failures with appropriate fallback logic. Apply this diff to simplify the error handling: - // Load config from file or fallback
- let config;
- try {
- // Use static import for config
- let mapboxMcpConfig;
- try {
- mapboxMcpConfig = require('../../../mapbox_mcp_config.json');
- config = { ...mapboxMcpConfig, mapboxAccessToken };
- console.log('[GeospatialTool] Config loaded successfully');
- } catch (configError: any) {
- throw configError;
- }
+ // Load config from file or fallback
+ let config;
+ try {
+ const mapboxMcpConfig = require('../../../mapbox_mcp_config.json');
+ config = { ...mapboxMcpConfig, mapboxAccessToken };
+ console.log('[GeospatialTool] Config loaded successfully');
} catch (configError: any) {
console.error('[GeospatialTool] Failed to load mapbox config:', configError.message);
config = { mapboxAccessToken, version: '1.0.0', name: 'mapbox-mcp-server' };📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||
| } catch (configError: any) { | ||||||||||||||||||||||||||||||||||||||||
| console.error('[GeospatialTool] Failed to load mapbox config:', configError.message); | ||||||||||||||||||||||||||||||||||||||||
| config = { mapboxAccessToken, version: '1.0.0', name: 'mapbox-mcp-server' }; | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -63,7 +69,7 @@ async function getConnectedMcpClient(): Promise<McpClient | null> { | |||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| // Build Smithery URL | ||||||||||||||||||||||||||||||||||||||||
| const smitheryUrlOptions = { config, apiKey, profileId }; | ||||||||||||||||||||||||||||||||||||||||
| const mcpServerBaseUrl = `https://server.smithery.ai/@ngoiyaeric/mapbox-mcp-server/mcp?api_key=${smitheryUrlOptions.apiKey}&profile=${smitheryUrlOptions.profileId}`; | ||||||||||||||||||||||||||||||||||||||||
| const mcpServerBaseUrl = `https://server.smithery.ai/@Waldzell-Agentics/mcp-server/mcp?api_key=${smitheryUrlOptions.apiKey}&profile=${smitheryUrlOptions.profileId}`; | ||||||||||||||||||||||||||||||||||||||||
| let serverUrlToUse; | ||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||
| serverUrlToUse = createSmitheryUrl(mcpServerBaseUrl, smitheryUrlOptions); | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -142,13 +148,74 @@ async function closeClient(client: McpClient | null) { | |||||||||||||||||||||||||||||||||||||||
| * Main geospatial tool executor. | ||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||
| export const geospatialTool = ({ uiStream }: { uiStream: ReturnType<typeof createStreamableUI> }) => ({ | ||||||||||||||||||||||||||||||||||||||||
| description: `Use this tool for location-based queries including: | ||||||||||||||||||||||||||||||||||||||||
| - Finding specific places, addresses, or landmarks | ||||||||||||||||||||||||||||||||||||||||
| - Getting coordinates for locations | ||||||||||||||||||||||||||||||||||||||||
| - Distance calculations between places | ||||||||||||||||||||||||||||||||||||||||
| - Direction queries | ||||||||||||||||||||||||||||||||||||||||
| - Map-related requests | ||||||||||||||||||||||||||||||||||||||||
| - Geographic information lookup`, | ||||||||||||||||||||||||||||||||||||||||
| description: `Use this tool for location-based queries including: | ||||||||||||||||||||||||||||||||||||||||
| There a plethora of tools inside this tool accessible on the mapbox mcp server where switch case into the tool of choice for that use case | ||||||||||||||||||||||||||||||||||||||||
ngoiyaeric marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||
| If the Query is supposed to use multiple tools in a sequence you must access all the tools in the sequence and then provide a final answer based on the results of all the tools used. | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| Static image tool: | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| Generates static map images using the Mapbox static image API. Features include: | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| Custom map styles (streets, outdoors, satellite, etc.) | ||||||||||||||||||||||||||||||||||||||||
| Adjustable image dimensions and zoom levels | ||||||||||||||||||||||||||||||||||||||||
| Support for multiple markers with custom colors and labels | ||||||||||||||||||||||||||||||||||||||||
| Overlay options including polylines and polygons | ||||||||||||||||||||||||||||||||||||||||
| Auto-fitting to specified coordinates | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| Category search tool: | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| Performs a category search using the Mapbox Search Box category search API. Features include: | ||||||||||||||||||||||||||||||||||||||||
| Search for points of interest by category (restaurants, hotels, gas stations, etc.) | ||||||||||||||||||||||||||||||||||||||||
| Filtering by geographic proximity | ||||||||||||||||||||||||||||||||||||||||
| Customizable result limits | ||||||||||||||||||||||||||||||||||||||||
| Rich metadata for each result | ||||||||||||||||||||||||||||||||||||||||
| Support for multiple languages | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| Reverse geocoding tool: | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| Performs reverse geocoding using the Mapbox geocoding V6 API. Features include: | ||||||||||||||||||||||||||||||||||||||||
| Convert geographic coordinates to human-readable addresses | ||||||||||||||||||||||||||||||||||||||||
| Customizable levels of detail (street, neighborhood, city, etc.) | ||||||||||||||||||||||||||||||||||||||||
| Results filtering by type (address, poi, neighborhood, etc.) | ||||||||||||||||||||||||||||||||||||||||
| Support for multiple languages | ||||||||||||||||||||||||||||||||||||||||
| Rich location context information | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| Directions tool: | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| Fetches routing directions using the Mapbox Directions API. Features include: | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| Support for different routing profiles: driving (with live traffic or typical), walking, and cycling | ||||||||||||||||||||||||||||||||||||||||
| Route from multiple waypoints (2-25 coordinate pairs) | ||||||||||||||||||||||||||||||||||||||||
| Alternative routes option | ||||||||||||||||||||||||||||||||||||||||
| Route annotations (distance, duration, speed, congestion) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| Scheduling options: | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| Future departure time (depart_at) for driving and driving-traffic profiles | ||||||||||||||||||||||||||||||||||||||||
| Desired arrival time (arrive_by) for driving profile only | ||||||||||||||||||||||||||||||||||||||||
| Profile-specific optimizations: | ||||||||||||||||||||||||||||||||||||||||
| Driving: vehicle dimension constraints (height, width, weight) | ||||||||||||||||||||||||||||||||||||||||
| Exclusion options for routing: | ||||||||||||||||||||||||||||||||||||||||
| Common exclusions: ferry routes, cash-only tolls | ||||||||||||||||||||||||||||||||||||||||
| Driving-specific exclusions: tolls, motorways, unpaved roads, tunnels, country borders, state borders | ||||||||||||||||||||||||||||||||||||||||
| Custom point exclusions (up to 50 geographic points to avoid) | ||||||||||||||||||||||||||||||||||||||||
| GeoJSON geometry output format | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| Isochrone tool: | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| Computes areas that are reachable within a specified amount of times from a location using Mapbox Isochrone API. Features include: | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| Support for different travel profiles (driving, walking, cycling) | ||||||||||||||||||||||||||||||||||||||||
| Customizable travel times or distances | ||||||||||||||||||||||||||||||||||||||||
| Multiple contour generation (e.g., 15, 30, 45 minute ranges) | ||||||||||||||||||||||||||||||||||||||||
| Optional departure or arrival time specification | ||||||||||||||||||||||||||||||||||||||||
| Color customization for visualization | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| Search and geocode tool: | ||||||||||||||||||||||||||||||||||||||||
| Uses the Mapbox Search Box Text Search API endpoint to power searching for and geocoding POIs, addresses, places, and any other types supported by that API. This tool consolidates the functionality that was previously provided by the ForwardGeocodeTool and PoiSearchTool (from earlier versions of this MCP server) into a single tool.` | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| , | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+151
to
+218
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Consider restructuring the tool description for clarity. The description has expanded from a concise statement to 65+ lines of prose covering multiple distinct tools (static image, category search, reverse geocoding, directions, isochrone, search/geocode). While comprehensive, this format may:
Consider using structured markdown (bullet points, clear sections) or a more concise summary with references to detailed documentation. 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||
| parameters: geospatialQuerySchema, | ||||||||||||||||||||||||||||||||||||||||
| execute: async (params: z.infer<typeof geospatialQuerySchema>) => { | ||||||||||||||||||||||||||||||||||||||||
| const { queryType, includeMap = true } = params; | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -181,24 +248,25 @@ export const geospatialTool = ({ uiStream }: { uiStream: ReturnType<typeof creat | |||||||||||||||||||||||||||||||||||||||
| const { tools } = await mcpClient.listTools().catch(() => ({ tools: [] })); | ||||||||||||||||||||||||||||||||||||||||
| const names = new Set(tools?.map((t: any) => t.name) || []); | ||||||||||||||||||||||||||||||||||||||||
| const prefer = (...cands: string[]) => cands.find(n => names.has(n)); | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| switch (queryType) { | ||||||||||||||||||||||||||||||||||||||||
| case 'directions': | ||||||||||||||||||||||||||||||||||||||||
| case 'distance': return prefer('calculate_distance', 'mapbox_matrix', 'mapbox_directions') || 'mapbox_matrix'; | ||||||||||||||||||||||||||||||||||||||||
| case 'search': return prefer('search_nearby_places', 'mapbox_geocoding') || 'mapbox_geocoding'; | ||||||||||||||||||||||||||||||||||||||||
| case 'map': return prefer('generate_map_link', 'mapbox_geocoding') || 'mapbox_geocoding'; | ||||||||||||||||||||||||||||||||||||||||
| case 'reverse': | ||||||||||||||||||||||||||||||||||||||||
| case 'geocode': return prefer('geocode_location', 'mapbox_geocoding') || 'mapbox_geocoding'; | ||||||||||||||||||||||||||||||||||||||||
| case 'directions': return prefer('directions_tool') | ||||||||||||||||||||||||||||||||||||||||
| case 'distance': return prefer('matrix_tool'); | ||||||||||||||||||||||||||||||||||||||||
| case 'search': return prefer( 'isochrone_tool','category_search_tool') || 'poi_search_tool'; | ||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Questionable tool selection for search queries. The Apply this diff to prioritize appropriate tools: - case 'search': return prefer( 'isochrone_tool','category_search_tool') || 'poi_search_tool';
+ case 'search': return prefer('category_search_tool', 'poi_search_tool');If isochrone functionality is needed, introduce a separate 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||
| case 'map': return prefer('static_map_image_tool') | ||||||||||||||||||||||||||||||||||||||||
| case 'reverse': return prefer('reverse_geocode_tool'); | ||||||||||||||||||||||||||||||||||||||||
| case 'geocode': return prefer('forward_geocode_tool'); | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| })(); | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| // Build arguments | ||||||||||||||||||||||||||||||||||||||||
| const toolArgs = (() => { | ||||||||||||||||||||||||||||||||||||||||
| switch (queryType) { | ||||||||||||||||||||||||||||||||||||||||
| case 'directions': | ||||||||||||||||||||||||||||||||||||||||
| case 'directions': return { waypoints: [params.origin, params.destination], includeMapPreview: includeMap, profile: params.mode }; | ||||||||||||||||||||||||||||||||||||||||
| case 'distance': return { places: [params.origin, params.destination], includeMapPreview: includeMap, mode: params.mode || 'driving' }; | ||||||||||||||||||||||||||||||||||||||||
| case 'reverse': return { searchText: `${params.coordinates.latitude},${params.coordinates.longitude}`, includeMapPreview: includeMap, maxResults: params.maxResults || 5 }; | ||||||||||||||||||||||||||||||||||||||||
| case 'search': return { searchText: params.query, includeMapPreview: includeMap, maxResults: params.maxResults || 5, ...(params.coordinates && { proximity: `${params.coordinates.latitude},${params.coordinates.longitude}` }), ...(params.radius && { radius: params.radius }) }; | ||||||||||||||||||||||||||||||||||||||||
| case 'geocode': | ||||||||||||||||||||||||||||||||||||||||
| case 'geocode': | ||||||||||||||||||||||||||||||||||||||||
| case 'map': return { searchText: params.location, includeMapPreview: includeMap, maxResults: queryType === 'geocode' ? params.maxResults || 5 : undefined }; | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| })(); | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -212,7 +280,7 @@ export const geospatialTool = ({ uiStream }: { uiStream: ReturnType<typeof creat | |||||||||||||||||||||||||||||||||||||||
| while (retryCount < MAX_RETRIES) { | ||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||
| toolCallResult = await Promise.race([ | ||||||||||||||||||||||||||||||||||||||||
| mcpClient.callTool({ name: toolName, arguments: toolArgs }), | ||||||||||||||||||||||||||||||||||||||||
| mcpClient.callTool({ name: toolName ?? 'unknown_tool', arguments: toolArgs }), | ||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Consider failing fast if toolName is undefined. The fallback Example: if (!toolName) {
throw new Error(`No appropriate tool found for queryType: ${queryType}`);
}🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||
| new Promise((_, reject) => setTimeout(() => reject(new Error('Tool call timeout')), 30000)), | ||||||||||||||||||||||||||||||||||||||||
| ]); | ||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -19,11 +19,14 @@ export async function writer( | |||||
| uiStream.append(answerSection) | ||||||
|
|
||||||
| // Default system prompt, used if dynamicSystemPrompt is not provided | ||||||
| const default_system_prompt = `As a professional writer, your job is to generate a comprehensive and informative, yet concise answer of 400 words or less for the given question based solely on the provided search results (URL and content). You must only use information from the provided search results. Use an unbiased and journalistic tone. Combine search results together into a coherent answer. Do not repeat text. If there are any images relevant to your answer, be sure to include them as well. Aim to directly address the user's question, augmenting your response with insights gleaned from the search results. | ||||||
| const default_system_prompt = `As a professional writer, your job is to generate a comprehensive and informative, yet concise answer of 400 words or less for the given question based solely on the provided search results (URL and content). You must only use information from the provided search results. Use an unbiased and journalistic tone. Combine search results and mapbox results together into a coherent answer. Do not repeat text. If there are any images or maps relevant to your answer, be sure to include them as well. Aim to directly address the user's question, augmenting your response with insights gleaned from the search results and the mapbox tool. | ||||||
| Whenever quoting or referencing information from a specific URL, always cite the source URL explicitly. Please match the language of the response to the user's language. | ||||||
| Always answer in Markdown format. Links and images must follow the correct format. | ||||||
| Link format: [link text](url) | ||||||
| Image format:  | ||||||
|
|
||||||
| There are also some proconfigured example queires. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix typos in the system prompt. Line 28 contains two typos:
Apply this diff: - There are also some proconfigured example queires.
+ There are also some preconfigured example queries.📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| When asked about 'What is a planet computer?' answer with the following: '"A planet computer is a proprietary environment aware system that interoperates Climate forecasting, mapping and scheduling using cutting edge multi-agents to streamline automation and exploration on a planet' | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix syntax error and improve hardcoded example. Line 29 has multiple issues:
Apply this diff to fix the immediate syntax error and grammar: - When asked about 'What is a planet computer?' answer with the following: '"A planet computer is a proprietary environment aware system that interoperates Climate forecasting, mapping and scheduling using cutting edge multi-agents to streamline automation and exploration on a planet'
+ When asked about 'What is a planet computer?' answer with the following: "A planet computer is a proprietary environment-aware system that integrates climate forecasting, mapping and scheduling using cutting-edge multi-agents to streamline automation and exploration on a planet."Recommended refactor: Consider extracting hardcoded examples into a separate configuration file or database to improve maintainability. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| `; | ||||||
|
|
||||||
| const systemToUse = dynamicSystemPrompt && dynamicSystemPrompt.trim() !== '' ? dynamicSystemPrompt : default_system_prompt; | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix typographical errors.
Line 36 contains two typos: "proconfigured" should be "preconfigured" and "queires" should be "queries".
Apply this diff:
📝 Committable suggestion
🤖 Prompt for AI Agents