Files
auto-retrieveapplicationdef…/app/nodes/core_node.py

28 lines
1.1 KiB
Python

async def process(state: dict) -> dict:
"""
This node retrieves the application definition from a given repository URL
using an LLM to analyze and extract relevant information.
Input:
state["repository_url"]: The URL of the repository containing the application definition.
Output:
Returns a dictionary with the extracted application definition as an object.
"""
from app.agent import llm
from langchain_core.messages import SystemMessage, HumanMessage
try:
repository_url = state.get("repository_url", "")
if not repository_url:
raise ValueError("Missing 'repository_url' in state.")
messages = [
SystemMessage(content="You are an expert in analyzing repository contents and extracting application definitions."),
HumanMessage(content=f"Retrieve the application definition from the repository at this URL: {repository_url}")
]
response = await llm.ainvoke(messages)
return {"application_definition": response.content, "phase": "complete"}
except Exception as exc:
return {"error": str(exc), "phase": "failed"}