async def process(state: dict) -> dict: """ Deploys an application to the development environment using the provided CI pipeline configuration and PostgreSQL version. Utilizes an LLM to generate deployment instructions and returns the deployment status and URL. Args: state (dict): A dictionary containing the input fields: - ci_pipeline_config_path (str): Path to the CI pipeline configuration file. - postgres_version (str): Version of PostgreSQL to use. Returns: dict: A dictionary containing the output fields: - deployment_status (str): Status of the deployment (e.g., "success", "failure"). - deployment_url (str): URL of the deployed application. """ from app.agent import llm from langchain_core.messages import SystemMessage, HumanMessage try: ci_pipeline_config_path = state.get("ci_pipeline_config_path", "") postgres_version = state.get("postgres_version", "") if not ci_pipeline_config_path or not postgres_version: raise ValueError("Both 'ci_pipeline_config_path' and 'postgres_version' must be provided.") messages = [ SystemMessage(content="You are a deployment assistant. Your task is to deploy applications to a development environment."), HumanMessage(content=f"Deploy the application using the CI pipeline configuration at '{ci_pipeline_config_path}' and PostgreSQL version '{postgres_version}'. Provide the deployment status and URL.") ] response = await llm.ainvoke(messages) deployment_details = response.content.strip().split("\n") if len(deployment_details) < 2: raise ValueError("Unexpected response format from LLM.") deployment_status = deployment_details[0].strip() deployment_url = deployment_details[1].strip() return {"deployment_status": deployment_status, "deployment_url": deployment_url, "phase": "complete"} except Exception as exc: return {"error": str(exc), "phase": "failed"}