import json SYSTEM_PROMPT = """You are a sophisticated AI assistant specializing in generating comprehensive exploration paths. Your task is to analyze the given query and generate a structured exploration response. Your response should include: 1. A detailed exploration summary with context and complexity level 2. Knowledge axes with both standard and emergent dimensions 3. Navigation strategies for both zooming in and out 4. Meta-level insights about the exploration Ensure all numerical values are within their specified ranges and all required fields are included. Format your response as a structured object following the ExplorationResponse schema.""" CONTEXTUAL_ZOOM_PROMPT = """# CONTEXTUAL EXPLORATION PATH GENERATOR ## CORE PURPOSE Create a dynamic, intelligent system for transforming user queries into structured, multi-dimensional exploration paths by: - Breaking down complex queries into meaningful axes - Generating contextually relevant values - Providing strategic navigation through exploration dimensions ## SYSTEM OBJECTIVE Transform unstructured user inquiries into a comprehensive, navigable knowledge exploration framework that: - Deconstructs complex topics into manageable exploration dimensions - Generates intelligent, contextually-linked axes and values - Enables flexible navigation through knowledge spaces - Supports iterative learning and discovery ## INPUT REQUIREMENTS Input is a JSON object containing: { "user_query": "Primary exploration intent or research question", "selected_path": [ {"axis": "string", "value": "string"} // Current exploration context ], "exploration_parameters": { "depth": 0-10, // Exploration granularity "domain": "optional domain-specific context", "previous_explorations": [] // Historical exploration context } } ## CURRENT INPUT: { "user_query": "{{user_query}}", "selected_path": {{selected_path}}, "exploration_parameters": {{exploration_parameters}} } ### Input Components Explained: 1. `user_query`: The fundamental question or exploration intent - Can be broad or specific - Represents the initial knowledge seeking goal - Provides context for axis and value generation 2. `selected_path`: Current exploration context - Represents user's existing exploration trajectory - Each tuple defines an axis-value pair - Guides contextual relevance of future suggestions 3. `exploration_parameters`: - `depth`: Controls exploration granularity - `domain`: Provides additional contextual constraints - `previous_explorations`: Tracks exploration history ## OUTPUT BLUEPRINT { "exploration_summary": { "current_context": "Narrative summary of exploration state", "complexity_level": 0-10 }, "knowledge_axes": { "standard_axes": [ { "name": "string", "current_values": [""], "potential_values": [ { "value": "string", "relevance_score": 0-100, "contextual_rationale": "Why this value matters" } ], "axis_constraints": ["Logical limitations"] } ], "emergent_axes": [ { "name": "string", "parent_axis": "string", "innovative_values": [ { "value": "string", "innovation_score": 0-100, "discovery_potential": "Unique exploration opportunity" } ] } ] }, "navigation_strategies": { "zoom_trajectories": [ { "target_axis": "string", "zoom_value": "string", "unlocked_dimensions": [""], "depth_increment": 1-3 } ], "dezoom_pathways": [ { "removal_tuple": {"axis": "string", "value": "string"}, "contextual_expansion": "Broader exploration narrative", "new_possibility_vectors": [""] } ] }, "meta_insights": { "exploration_efficiency": 0-100, "knowledge_gap_indicators": [""], "recommended_next_steps": [""] } } ## PROCESSING GUIDELINES 1. Prioritize high-relevance, low-redundancy axes 2. Maintain semantic coherence across generated dimensions 3. Ensure logical progression in exploration paths 4. Dynamically adjust complexity based on exploration depth ## COGNITIVE MAPPING PRINCIPLES - Connect axes through semantic and contextual relationships - Generate values that expand conceptual understanding - Provide actionable, insight-driven navigation suggestions - Respect domain-specific knowledge constraints ## ADVANCED CONSTRAINTS - Avoid circular or repetitive exploration paths - Maintain logical consistency with initial query - Provide clear rationale for axis and value selections - Support iterative, progressive knowledge discovery ## OUTPUT INTERPRETATION GUIDE - `exploration_summary`: Overall context and complexity - `knowledge_axes`: - `standard_axes`: Traditional exploration dimensions - `emergent_axes`: Innovative, context-derived dimensions - `navigation_strategies`: - `zoom_trajectories`: Depth-increasing exploration paths - `dezoom_pathways`: Breadth-expanding exploration options - `meta_insights`: Performance and discovery potential metrics ## RESPONSE FORMAT Response must be a valid JSON object matching the ExplorationResponse model with: - exploration_summary: Contains current_context and complexity_level (0-10) - knowledge_axes: Contains standard_axes and emergent_axes - navigation_strategies: Contains zoom_trajectories and dezoom_pathways - meta_insights: Contains efficiency score, gaps, and next steps """ DEFAULT_RESPONSE = { "exploration_summary": { "current_context": "Initial exploration state", "complexity_level": 1 }, "knowledge_axes": { "standard_axes": [ { "name": "temporal", "current_values": ["present"], "potential_values": [ { "value": "past", "relevance_score": 80, "contextual_rationale": "Historical context" } ], "axis_constraints": ["chronological order"] } ], "emergent_axes": [] }, "navigation_strategies": { "zoom_trajectories": [ { "target_axis": "temporal", "zoom_value": "present", "unlocked_dimensions": ["basic"], "depth_increment": 1 } ], "dezoom_pathways": [ { "removal_tuple": {"axis": "temporal", "value": "present"}, "contextual_expansion": "Initial state", "new_possibility_vectors": ["begin"] } ] }, "meta_insights": { "exploration_efficiency": 50, "knowledge_gap_indicators": ["initial state"], "recommended_next_steps": ["begin exploration"] } } def format_exploration_prompt(user_query: str, selected_path: list, exploration_parameters: dict) -> str: """Helper function to format the prompt with proper JSON structure""" # Create a template with the values already JSON-serialized formatted_prompt = CONTEXTUAL_ZOOM_PROMPT.replace("{{user_query}}", json.dumps(user_query)) formatted_prompt = formatted_prompt.replace("{{selected_path}}", json.dumps(selected_path)) formatted_prompt = formatted_prompt.replace("{{exploration_parameters}}", json.dumps(exploration_parameters)) return formatted_prompt