From 15dfca8f563d7994df502506e2e8d20afd1906a0 Mon Sep 17 00:00:00 2001 From: dongyuanjushi Date: Wed, 19 Mar 2025 09:00:59 -0400 Subject: [PATCH 1/9] fix agent submit --- aios/hooks/modules/agent.py | 57 ++++++++++++++++--------- aios/hooks/stores/processes.py | 29 ++++++++++++- runtime/launch.py | 78 ++++++++++++++++++++++------------ 3 files changed, 115 insertions(+), 49 deletions(-) diff --git a/aios/hooks/modules/agent.py b/aios/hooks/modules/agent.py index abbee188..3d3cd164 100644 --- a/aios/hooks/modules/agent.py +++ b/aios/hooks/modules/agent.py @@ -32,30 +32,34 @@ def submitAgent(declaration_params: AgentSubmitDeclaration) -> int: int: A unique process ID for the submitted agent. """ def run_agent(agent_name: str, task): - is_local = False + # is_local = False - if agent_name.count('/') >= 3: - is_local = True + # if agent_name.count('/') >= 3: + # is_local = True try: author, name, version = manager.download_agent( author=agent_name.split('/')[0], name=agent_name.split('/')[1] ) + agent_class, config = manager.load_agent(author, name, version) + except: - is_local = True + raise Exception("Agent not found") + # is_local = True - if is_local: - agent_class, config = manager.load_agent(local=True, path=agent_name) - else: - agent_class, config = manager.load_agent(author, name, version) + # if is_local: + # else: + # agent_class, config = manager.load_agent(author, name, version) - agent = agent_class(agent_name, task, config) + agent = agent_class(agent_name) - agent.send_request = send_request + # agent.send_request = send_request - return agent.run() + return agent.run(task) + + # print(declaration_params.agent_name, declaration_params.task_input) _submitted_agent: Future = thread_pool.submit( run_agent, @@ -64,15 +68,15 @@ def run_agent(agent_name: str, task): ) # Generate a unique process ID - random_code = randint(100000, 999999) - while random_code in ids: - random_code = randint(100000, 999999) + process_id = randint(100000, 999999) + while process_id in ids: + process_id = randint(100000, 999999) - ProcessStore.addProcess(_submitted_agent, random_code) + ProcessStore.addProcess(_submitted_agent, process_id) - print(ProcessStore.AGENT_PROCESSES) + # print(ProcessStore.AGENT_PROCESSES) - return random_code + return process_id def awaitAgentExecution(process_id: str) -> Dict[str, Any]: """ @@ -89,11 +93,22 @@ def awaitAgentExecution(process_id: str) -> Dict[str, Any]: """ future = ProcessStore.AGENT_PROCESSES.get(process_id) - - if future: - return future.result() - else: + + if not future: raise ValueError(f"Process with ID '{process_id}' not found.") + + # Check if the future is done before trying to get the result + if future.done(): + try: + result = future.result() + print(f"Execution completed for process {process_id}: {result}") + return result + except Exception as e: + print(f"Execution failed for process {process_id}: {str(e)}") + raise e + else: + # Return None to indicate the process is still running + return None return submitAgent, awaitAgentExecution diff --git a/aios/hooks/stores/processes.py b/aios/hooks/stores/processes.py index 1be9f4fe..876fb128 100644 --- a/aios/hooks/stores/processes.py +++ b/aios/hooks/stores/processes.py @@ -11,4 +11,31 @@ def addProcess(p: Future, pi: str) -> None: def clearProcesses() -> None: AGENT_PROCESSES.clear() -# def addId +def getProcessStatus(process_id: str) -> dict: + """ + Get the status of a process without blocking. + + Args: + process_id (str): The ID of the process to check. + + Returns: + dict: A dictionary containing the process status. + + Raises: + ValueError: If the process ID is not found. + """ + future = AGENT_PROCESSES.get(process_id) + + if not future: + raise ValueError(f"Process with ID '{process_id}' not found") + + status = { + "id": process_id, + "running": not future.done(), + "cancelled": future.cancelled(), + "done": future.done(), + "exception": future.exception() if future.done() and not future.cancelled() else None, + } + + return status + diff --git a/runtime/launch.py b/runtime/launch.py index 819c87ac..643a4b59 100644 --- a/runtime/launch.py +++ b/runtime/launch.py @@ -321,15 +321,16 @@ def restart_kernel(): """Restart kernel service and reload configuration""" try: # Clean up existing components - for component in ["llms", "memory", "storage", "tool"]: - if active_components[component]: - if hasattr(active_components[component], "cleanup"): - active_components[component].cleanup() - active_components[component] = None + # for component in ["llms", "memory", "storage", "tool"]: + # if active_components[component]: + # if hasattr(active_components[component], "cleanup"): + # active_components[component].cleanup() + # active_components[component] = None # Initialize new components - if not initialize_components(): - raise Exception("Failed to initialize components") + active_components = initialize_components() + # if not initialize_components(): + # raise Exception("Failed to initialize components") print("✅ All components reinitialized successfully") @@ -424,20 +425,23 @@ async def list_agent_processes(): """List all agent processes and their status""" try: processes = [] - for proc_file in PROC_DIR.glob("*.json"): + for process_id in ProcessStore.AGENT_PROCESSES: try: - with open(proc_file) as f: - process_info = json.load(f) - processes.append(process_info) + status = ProcessStore.getProcessStatus(process_id) + processes.append(status) except Exception as e: - print(f"Failed to read process file {proc_file}: {str(e)}") - continue + print(f"Failed to get status for process {process_id}: {str(e)}") + processes.append({ + "id": process_id, + "error": str(e) + }) - # Sort by execution ID - processes.sort(key=lambda x: x["execution_id"]) + # Sort by process ID + processes.sort(key=lambda x: x["id"]) return { "status": "success", + "count": len(processes), "processes": processes } except Exception as e: @@ -449,6 +453,7 @@ async def list_agent_processes(): @app.post("/agents/submit") async def submit_agent(config: AgentSubmit): """Submit an agent for execution using the agent factory.""" + # breakpoint() if "factory" not in active_components or not active_components["factory"]: raise HTTPException(status_code=400, detail="Agent factory not initialized") @@ -462,11 +467,12 @@ async def submit_agent(config: AgentSubmit): agent_name=config.agent_id, task_input=config.agent_config["task"] ) - save_agent_process_info( - agent_id=config.agent_id, - execution_id=execution_id, - config=config.agent_config - ) + # save_agent_process_info( + # agent_id=config.agent_id, + # execution_id=execution_id, + # config=config.agent_config + # ) + return { "status": "success", @@ -499,10 +505,28 @@ async def get_agent_status(execution_id: int): await_execution = active_components["factory"]["await"] try: + # Try to get the result, but it might return None if still running result = await_execution(int(execution_id)) - except FileNotFoundError as e: + except ValueError as e: + # Process not found raise HTTPException(status_code=404, detail=str(e)) + except Exception as e: + # Other errors from the future execution + error_msg = str(e) + stack_trace = traceback.format_exc() + print(f"[ERROR] Agent execution failed: {error_msg}") + print(f"[ERROR] Stack Trace:\n{stack_trace}") + + return { + "status": "error", + "error": { + "message": error_msg, + "traceback": stack_trace + }, + "execution_id": execution_id + } + # If result is None, the agent is still running if result is None: return { "status": "running", @@ -510,7 +534,7 @@ async def get_agent_status(execution_id: int): "execution_id": execution_id } - update_agent_process_status(execution_id, "completed", result) + # update_agent_process_status(execution_id, "completed", result) return { "status": "completed", @@ -549,11 +573,11 @@ async def cleanup_components(): active_components[component].cleanup() active_components[component] = None - for proc_file in PROC_DIR.glob("*.json"): - try: - proc_file.unlink() - except Exception as e: - print(f"Failed to remove process file {proc_file}: {str(e)}") + # for proc_file in PROC_DIR.glob("*.json"): + # try: + # proc_file.unlink() + # except Exception as e: + # print(f"Failed to remove process file {proc_file}: {str(e)}") return {"status": "success", "message": "All components cleaned up"} except Exception as e: From d562e34fe5cfe63be4d9edfca5947b1db311a8ac Mon Sep 17 00:00:00 2001 From: dongyuanjushi Date: Wed, 19 Mar 2025 09:01:30 -0400 Subject: [PATCH 2/9] update scripts --- scripts/run_agent.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/scripts/run_agent.sh b/scripts/run_agent.sh index ba38269a..8a25fa7a 100644 --- a/scripts/run_agent.sh +++ b/scripts/run_agent.sh @@ -31,4 +31,21 @@ run-agent \ --llm_backend ollama \ --agent_name_or_path demo_author/demo_agent \ --task "Tell me what is core idea of AIOS" \ - --aios_kernel_url http://localhost:8000 \ No newline at end of file + --aios_kernel_url http://localhost:8000 + + +curl -X POST http://localhost:8000/agents/submit \ + -H "Content-Type: application/json" \ + -d '{ + "agent_id": "example/academic_agent", + "agent_config": { + "task": "Tell me what is core idea of AIOS" + } + }' + +curl -X GET http://localhost:8000/agents/646303/status + +curl -X POST http://localhost:8000/core/refresh + +# curl -X POST http://localhost:8000/core/cleanup + From f322b1aaa4f3d736424b2761892a9019257af74a Mon Sep 17 00:00:00 2001 From: dongyuanjushi Date: Wed, 19 Mar 2025 09:12:01 -0400 Subject: [PATCH 3/9] update process --- aios/hooks/stores/processes.py | 28 ------------------- runtime/launch.py | 51 ++++++++++------------------------ 2 files changed, 15 insertions(+), 64 deletions(-) diff --git a/aios/hooks/stores/processes.py b/aios/hooks/stores/processes.py index 876fb128..f6c56893 100644 --- a/aios/hooks/stores/processes.py +++ b/aios/hooks/stores/processes.py @@ -11,31 +11,3 @@ def addProcess(p: Future, pi: str) -> None: def clearProcesses() -> None: AGENT_PROCESSES.clear() -def getProcessStatus(process_id: str) -> dict: - """ - Get the status of a process without blocking. - - Args: - process_id (str): The ID of the process to check. - - Returns: - dict: A dictionary containing the process status. - - Raises: - ValueError: If the process ID is not found. - """ - future = AGENT_PROCESSES.get(process_id) - - if not future: - raise ValueError(f"Process with ID '{process_id}' not found") - - status = { - "id": process_id, - "running": not future.done(), - "cancelled": future.cancelled(), - "done": future.done(), - "exception": future.exception() if future.done() and not future.cancelled() else None, - } - - return status - diff --git a/runtime/launch.py b/runtime/launch.py index 643a4b59..cb6f0cae 100644 --- a/runtime/launch.py +++ b/runtime/launch.py @@ -425,23 +425,20 @@ async def list_agent_processes(): """List all agent processes and their status""" try: processes = [] - for process_id in ProcessStore.AGENT_PROCESSES: + for proc_file in PROC_DIR.glob("*.json"): try: - status = ProcessStore.getProcessStatus(process_id) - processes.append(status) + with open(proc_file) as f: + process_info = json.load(f) + processes.append(process_info) except Exception as e: - print(f"Failed to get status for process {process_id}: {str(e)}") - processes.append({ - "id": process_id, - "error": str(e) - }) + print(f"Failed to read process file {proc_file}: {str(e)}") + continue - # Sort by process ID - processes.sort(key=lambda x: x["id"]) + # Sort by execution ID + processes.sort(key=lambda x: x["execution_id"]) return { "status": "success", - "count": len(processes), "processes": processes } except Exception as e: @@ -467,11 +464,11 @@ async def submit_agent(config: AgentSubmit): agent_name=config.agent_id, task_input=config.agent_config["task"] ) - # save_agent_process_info( - # agent_id=config.agent_id, - # execution_id=execution_id, - # config=config.agent_config - # ) + save_agent_process_info( + agent_id=config.agent_id, + execution_id=execution_id, + config=config.agent_config + ) return { @@ -505,28 +502,10 @@ async def get_agent_status(execution_id: int): await_execution = active_components["factory"]["await"] try: - # Try to get the result, but it might return None if still running result = await_execution(int(execution_id)) - except ValueError as e: - # Process not found + except FileNotFoundError as e: raise HTTPException(status_code=404, detail=str(e)) - except Exception as e: - # Other errors from the future execution - error_msg = str(e) - stack_trace = traceback.format_exc() - print(f"[ERROR] Agent execution failed: {error_msg}") - print(f"[ERROR] Stack Trace:\n{stack_trace}") - - return { - "status": "error", - "error": { - "message": error_msg, - "traceback": stack_trace - }, - "execution_id": execution_id - } - # If result is None, the agent is still running if result is None: return { "status": "running", @@ -534,7 +513,7 @@ async def get_agent_status(execution_id: int): "execution_id": execution_id } - # update_agent_process_status(execution_id, "completed", result) + update_agent_process_status(execution_id, "completed", result) return { "status": "completed", From ae47c5fb10b3a27d57fc92e973ea0467807b3008 Mon Sep 17 00:00:00 2001 From: dongyuanjushi Date: Wed, 19 Mar 2025 09:12:33 -0400 Subject: [PATCH 4/9] update scripts --- scripts/run_agent.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/run_agent.sh b/scripts/run_agent.sh index 8a25fa7a..430fdc6f 100644 --- a/scripts/run_agent.sh +++ b/scripts/run_agent.sh @@ -43,7 +43,7 @@ curl -X POST http://localhost:8000/agents/submit \ } }' -curl -X GET http://localhost:8000/agents/646303/status +curl -X GET http://localhost:8000/agents/225269/status curl -X POST http://localhost:8000/core/refresh From 7fcfd0ceb95570db5d9f148de42269fbf64020dc Mon Sep 17 00:00:00 2001 From: dongyuanjushi Date: Wed, 19 Mar 2025 09:21:30 -0400 Subject: [PATCH 5/9] update routing strategy --- aios/llm_core/adapter.py | 2 +- aios/llm_core/strategy.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/aios/llm_core/adapter.py b/aios/llm_core/adapter.py index 8b2c3715..8c941711 100644 --- a/aios/llm_core/adapter.py +++ b/aios/llm_core/adapter.py @@ -85,7 +85,7 @@ def __init__( api_key: Optional[Union[str, List[str]]] = None, log_mode: str = "console", use_context_manager: bool = False, - strategy: Optional[RouterStrategy] = RouterStrategy.SIMPLE, + strategy: Optional[RouterStrategy] = RouterStrategy.Sequential, ): """ Initialize the LLMAdapter. diff --git a/aios/llm_core/strategy.py b/aios/llm_core/strategy.py index fc165956..99a21e34 100644 --- a/aios/llm_core/strategy.py +++ b/aios/llm_core/strategy.py @@ -38,11 +38,11 @@ """ class RouterStrategy(Enum): - SIMPLE = 0, + Sequential = 0, -class SimpleStrategy: +class SequentialRouting: """ - The SimpleStrategy class implements a round-robin selection strategy for load-balancing LLM requests. + The SequentialRouting class implements a round-robin selection strategy for load-balancing LLM requests. It iterates through a list of selected language models and returns their corresponding index based on the request count. @@ -206,9 +206,9 @@ def get_model_idxs(self, selected_llms: List[str], n_queries: int=1): return results -class EccosRStrategy: +class SmartRouting: """ - The EccosRStrategy class implements a cost-performance optimized selection strategy for LLM requests. + The SmartRouting class implements a cost-performance optimized selection strategy for LLM requests. It uses historical performance data to predict which models will perform best for a given query while minimizing cost. From ce1585a0f662404bffca2884a4aa5bdb5d4a6eef Mon Sep 17 00:00:00 2001 From: dongyuanjushi Date: Wed, 19 Mar 2025 09:22:42 -0400 Subject: [PATCH 6/9] update scripts --- scripts/run_agent.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/run_agent.sh b/scripts/run_agent.sh index 430fdc6f..4ec1b831 100644 --- a/scripts/run_agent.sh +++ b/scripts/run_agent.sh @@ -43,7 +43,7 @@ curl -X POST http://localhost:8000/agents/submit \ } }' -curl -X GET http://localhost:8000/agents/225269/status +# curl -X GET http://localhost:8000/agents/225269/status curl -X POST http://localhost:8000/core/refresh From c7763c4a4036fb3866b6a6eee08aae61de906768 Mon Sep 17 00:00:00 2001 From: dongyuanjushi Date: Wed, 19 Mar 2025 09:26:39 -0400 Subject: [PATCH 7/9] fix strategy --- aios/llm_core/adapter.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/aios/llm_core/adapter.py b/aios/llm_core/adapter.py index 8c941711..ad7e4b2b 100644 --- a/aios/llm_core/adapter.py +++ b/aios/llm_core/adapter.py @@ -1,5 +1,5 @@ from aios.context.simple_context import SimpleContextManager -from aios.llm_core.strategy import RouterStrategy, SimpleStrategy +from aios.llm_core.strategy import RouterStrategy, SequentialRouting, SmartRouting from aios.llm_core.local import HfLocalBackend from aios.utils.id_generator import generator_tool_call_id from cerebrum.llm.apis import LLMQuery, LLMResponse @@ -106,8 +106,8 @@ def __init__( self._setup_api_keys() self._initialize_llms() - if strategy == RouterStrategy.SIMPLE: - self.strategy = SimpleStrategy(self.llm_configs) + if strategy == RouterStrategy.Sequential: + self.strategy = SequentialRouting(self.llm_configs) def _setup_api_keys(self) -> None: """ From b9a51c82f90cb19f7912b23213f24bf41ae9e4c6 Mon Sep 17 00:00:00 2001 From: dongyuanjushi Date: Wed, 2 Apr 2025 22:21:17 -0400 Subject: [PATCH 8/9] update routing script --- aios/llm_core/adapter.py | 10 ++++++---- aios/llm_core/local.py | 3 ++- aios/llm_core/{strategy.py => routing.py} | 1 + 3 files changed, 9 insertions(+), 5 deletions(-) rename aios/llm_core/{strategy.py => routing.py} (99%) diff --git a/aios/llm_core/adapter.py b/aios/llm_core/adapter.py index ad7e4b2b..5303c6d5 100644 --- a/aios/llm_core/adapter.py +++ b/aios/llm_core/adapter.py @@ -1,5 +1,5 @@ from aios.context.simple_context import SimpleContextManager -from aios.llm_core.strategy import RouterStrategy, SequentialRouting, SmartRouting +from aios.llm_core.routing import RouterStrategy, SequentialRouting, SmartRouting from aios.llm_core.local import HfLocalBackend from aios.utils.id_generator import generator_tool_call_id from cerebrum.llm.apis import LLMQuery, LLMResponse @@ -85,7 +85,7 @@ def __init__( api_key: Optional[Union[str, List[str]]] = None, log_mode: str = "console", use_context_manager: bool = False, - strategy: Optional[RouterStrategy] = RouterStrategy.Sequential, + routing_strategy: Optional[RouterStrategy] = RouterStrategy.Sequential, ): """ Initialize the LLMAdapter. @@ -95,7 +95,7 @@ def __init__( api_key: API key(s) for the LLM services log_mode: Mode of logging the LLM processing status use_context_manager: Whether to use context management - strategy: Strategy for routing requests + routing_strategy: Strategy for routing requests """ self.log_mode = log_mode self.use_context_manager = use_context_manager @@ -106,8 +106,10 @@ def __init__( self._setup_api_keys() self._initialize_llms() - if strategy == RouterStrategy.Sequential: + if routing_strategy == RouterStrategy.Sequential: self.strategy = SequentialRouting(self.llm_configs) + elif routing_strategy == RouterStrategy.Smart: + self.strategy = SmartRouting(self.llm_configs) def _setup_api_keys(self) -> None: """ diff --git a/aios/llm_core/local.py b/aios/llm_core/local.py index 49cfd9c9..0f2eefd2 100644 --- a/aios/llm_core/local.py +++ b/aios/llm_core/local.py @@ -105,7 +105,8 @@ def generate( response = self.model.generate( **inputs, temperature=temperature, - max_length=max_tokens, + # max_length=max_tokens, + max_new_tokens=max_tokens, top_k=10, num_beams=4, early_stopping=True, diff --git a/aios/llm_core/strategy.py b/aios/llm_core/routing.py similarity index 99% rename from aios/llm_core/strategy.py rename to aios/llm_core/routing.py index 99a21e34..d6296cf8 100644 --- a/aios/llm_core/strategy.py +++ b/aios/llm_core/routing.py @@ -39,6 +39,7 @@ class RouterStrategy(Enum): Sequential = 0, + Smart = 1 class SequentialRouting: """ From 323831592a55951e68944540d865ae0f50a3e1fb Mon Sep 17 00:00:00 2001 From: dongyuanjushi Date: Thu, 3 Apr 2025 11:07:09 -0400 Subject: [PATCH 9/9] update launching script --- aios/config/config.yaml.example | 73 ++++++++++++++++++--------------- aios/config/config_manager.py | 14 +++++++ runtime/launch.py | 14 ++++++- runtime/launch_kernel.sh | 2 +- 4 files changed, 68 insertions(+), 35 deletions(-) diff --git a/aios/config/config.yaml.example b/aios/config/config.yaml.example index aec72647..612f77c5 100644 --- a/aios/config/config.yaml.example +++ b/aios/config/config.yaml.example @@ -2,53 +2,60 @@ # API Keys Configuration api_keys: - openai: "" # OpenAI API key - gemini: "" # Google Gemini API key - groq: "" # Groq API key + openai: "" # OpenAI API key + gemini: "" # Google Gemini API key + groq: "" # Groq API key anthropic: "" # Anthropic API key huggingface: - auth_token: "" # HuggingFace auth token - home: "" # Optional: HuggingFace models path + auth_token: "" # Your HuggingFace auth token for authorized models + cache_dir: "" # Your cache directory for saving huggingface models # LLM Configuration llms: models: - # - name: "gpt-4o-mini" - # backend: "openai" - # max_new_tokens: 1024 - # temperature: 1.0 - - - name: "gemini-1.5-flash" - backend: "google" - max_new_tokens: 1024 - temperature: 1.0 + # OpenAI Models # - name: "gpt-4o-mini" # backend: "openai" - # max_new_tokens: 1024 - # temperature: 1.0 - # - name: "qwen2.5:7b" - # backend: "ollama" - # max_new_tokens: 1024 - # temperature: 1.0 - # hostname: "http://localhost:11434" # Make sure to run ollama server - # - # - name: "meta-llama/Meta-Llama-3.1-8B-Instruct" + # Google Models + # - name: "gemini-1.5-flash" + # backend: "google" + + + # Anthropic Models + # - name: "claude-3-opus" + # backend: "anthropic" + + # Ollama Models + - name: "qwen2.5:7b" + backend: "ollama" + hostname: "http://localhost:11434" # Make sure to run ollama server + + # HuggingFace Models + # - name: "meta-llama/Llama-3.1-8B-Instruct" # backend: "huggingface" - # max_new_tokens: 1024 - # temperature: 1.0 - # max_gpu_memory: - + # max_gpu_memory: {0: "48GB"} # GPU memory allocation + # eval_device: "cuda:0" # Device for model evaluation + + # vLLM Models + # To use vllm as backend, you need to install vllm and run the vllm server https://docs.vllm.ai/en/latest/serving/openai_compatible_server.html + # An example command to run the vllm server is: + # vllm serve meta-llama/Llama-3.2-3B-Instruct --port 8091 + # - name: "meta-llama/Llama-3.1-8B-Instruct" + # backend: "vllm" + # hostname: "http://localhost:8091" + + + + log_mode: "console" - # use_context_manager: false - use_context_manager: false # set as true to enable context interrupt and switch + use_context_manager: false memory: - memory_limit: 524288 # 512KB - eviction_k: 3 - + log_mode: "console" + storage: root_dir: "root" use_vector_db: true @@ -62,4 +69,4 @@ agent_factory: server: host: "localhost" - port: 8000 + port: 8000 \ No newline at end of file diff --git a/aios/config/config_manager.py b/aios/config/config_manager.py index f4fdbc28..0c3d2765 100644 --- a/aios/config/config_manager.py +++ b/aios/config/config_manager.py @@ -227,6 +227,20 @@ def get_agent_factory_config(self) -> dict: """ return self.config.get("agent_factory", {}) + def get_server_config(self) -> dict: + """ + Retrieves the server configuration settings. + + Returns: + dict: Dictionary containing server configurations + + Example: + server_config = config_manager.get_server_config() + host = server_config.get("host") + port = server_config.get("port") + """ + return self.config.get("server", {}) + # def get_kernel_config(self) -> dict: # """Get kernel configuration""" # return self.config.get("kernel", {}) diff --git a/runtime/launch.py b/runtime/launch.py index cb6f0cae..a6ab59f8 100644 --- a/runtime/launch.py +++ b/runtime/launch.py @@ -32,6 +32,8 @@ from fastapi.middleware.cors import CORSMiddleware +import uvicorn + # from cerebrum.llm.layer import LLMLayer as LLMConfig # from cerebrum.memory.layer import MemoryLayer as MemoryConfig # from cerebrum.storage.layer import StorageLayer as StorageConfig @@ -631,4 +633,14 @@ async def update_config(request: Request): raise HTTPException( status_code=500, detail=f"Failed to update configuration: {str(e)}" - ) \ No newline at end of file + ) + +# Add a main function to run the app directly +if __name__ == "__main__": + # Get server config from config.yaml + server_config = config.get_server_config() + host = server_config.get("host", "localhost") + port = server_config.get("port", 8000) + + # print(f"Starting AIOS server on {host}:{port}") + uvicorn.run("runtime.launch:app", host=host, port=port, reload=False) \ No newline at end of file diff --git a/runtime/launch_kernel.sh b/runtime/launch_kernel.sh index 31a720c8..65cdeef0 100644 --- a/runtime/launch_kernel.sh +++ b/runtime/launch_kernel.sh @@ -1 +1 @@ -python -m uvicorn runtime.launch:app --port 8000 +python -m runtime.launch