Spaces:
Running
Running
cleanup
Browse files- src/pipeline.py +0 -94
src/pipeline.py
CHANGED
|
@@ -1,97 +1,3 @@
|
|
| 1 |
-
# """
|
| 2 |
-
# Complete Multi-Stage MCP Pipeline
|
| 3 |
-
# Orchestrates: Router β Executor β Compiler β Translator
|
| 4 |
-
# """
|
| 5 |
-
|
| 6 |
-
# import time
|
| 7 |
-
# from typing import Dict, Any
|
| 8 |
-
# from openai import OpenAI
|
| 9 |
-
|
| 10 |
-
# from .router import QueryRouter
|
| 11 |
-
# from .executor import MCPExecutor, MCP_SERVER_REGISTRY
|
| 12 |
-
# from .compiler import ResponseCompiler
|
| 13 |
-
# from .translator import FarmerTranslator
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
# class FarmerChatPipeline:
|
| 17 |
-
# """Complete multi-stage MCP pipeline"""
|
| 18 |
-
|
| 19 |
-
# def __init__(self, openai_client: OpenAI, location: Dict[str, Any]):
|
| 20 |
-
# self.location = location
|
| 21 |
-
# self.router = QueryRouter(openai_client, MCP_SERVER_REGISTRY)
|
| 22 |
-
# self.executor = MCPExecutor()
|
| 23 |
-
# self.compiler = ResponseCompiler()
|
| 24 |
-
# self.translator = FarmerTranslator(openai_client)
|
| 25 |
-
|
| 26 |
-
# async def process_query(self, query: str, verbose: bool = False) -> Dict[str, Any]:
|
| 27 |
-
# """
|
| 28 |
-
# Process farmer query through complete pipeline
|
| 29 |
-
|
| 30 |
-
# Returns:
|
| 31 |
-
# {
|
| 32 |
-
# "query": str,
|
| 33 |
-
# "routing": dict,
|
| 34 |
-
# "compiled_data": dict,
|
| 35 |
-
# "advice": str,
|
| 36 |
-
# "pipeline_time_seconds": float
|
| 37 |
-
# }
|
| 38 |
-
# """
|
| 39 |
-
# if verbose:
|
| 40 |
-
# print(f"\nπΎ Processing: {query}")
|
| 41 |
-
# print(f"π Location: {self.location['name']}")
|
| 42 |
-
|
| 43 |
-
# pipeline_start = time.time()
|
| 44 |
-
|
| 45 |
-
# # STAGE 1: Query Routing
|
| 46 |
-
# if verbose:
|
| 47 |
-
# print("π― Stage 1: Routing...")
|
| 48 |
-
|
| 49 |
-
# routing = self.router.route(query, self.location)
|
| 50 |
-
|
| 51 |
-
# if verbose:
|
| 52 |
-
# print(f" β Servers: {', '.join(routing['required_servers'])}")
|
| 53 |
-
|
| 54 |
-
# # STAGE 2: MCP Execution (Parallel)
|
| 55 |
-
# if verbose:
|
| 56 |
-
# print("βοΈ Stage 2: Executing MCP servers...")
|
| 57 |
-
|
| 58 |
-
# raw_results = await self.executor.execute_parallel(
|
| 59 |
-
# routing['required_servers'],
|
| 60 |
-
# self.location['lat'],
|
| 61 |
-
# self.location['lon']
|
| 62 |
-
# )
|
| 63 |
-
|
| 64 |
-
# if verbose:
|
| 65 |
-
# print(f" β Completed in {raw_results['execution_time_seconds']}s")
|
| 66 |
-
|
| 67 |
-
# # STAGE 3: Response Compilation
|
| 68 |
-
# if verbose:
|
| 69 |
-
# print("π Stage 3: Compiling results...")
|
| 70 |
-
|
| 71 |
-
# compiled = self.compiler.compile(raw_results)
|
| 72 |
-
|
| 73 |
-
# if verbose:
|
| 74 |
-
# print(f" β {compiled['completeness']}")
|
| 75 |
-
|
| 76 |
-
# # STAGE 4: Farmer Translation
|
| 77 |
-
# if verbose:
|
| 78 |
-
# print("πΎ Stage 4: Generating advice...")
|
| 79 |
-
|
| 80 |
-
# farmer_advice = self.translator.translate(query, compiled, self.location)
|
| 81 |
-
|
| 82 |
-
# pipeline_time = time.time() - pipeline_start
|
| 83 |
-
|
| 84 |
-
# if verbose:
|
| 85 |
-
# print(f"β
Complete! Total: {pipeline_time:.2f}s\n")
|
| 86 |
-
|
| 87 |
-
# return {
|
| 88 |
-
# "query": query,
|
| 89 |
-
# "routing": routing,
|
| 90 |
-
# "compiled_data": compiled,
|
| 91 |
-
# "advice": farmer_advice,
|
| 92 |
-
# "pipeline_time_seconds": round(pipeline_time, 2)
|
| 93 |
-
# }
|
| 94 |
-
|
| 95 |
"""
|
| 96 |
Farmer.chat Pipeline - Main Orchestrator
|
| 97 |
Coordinates Router β Executor β Compiler stages for alert generation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
"""
|
| 2 |
Farmer.chat Pipeline - Main Orchestrator
|
| 3 |
Coordinates Router β Executor β Compiler stages for alert generation
|