Files
auto-retrieve-files-from-a-…/app/nodes/core_node.py

26 lines
1.1 KiB
Python

async def process(state: dict) -> dict:
"""
This node retrieves files from a repository based on the provided URL and update scope.
It uses an LLM to analyze and extract relevant workflow files from the repository.
"""
from app.agent import llm
from langchain_core.messages import SystemMessage, HumanMessage
try:
repository_url = state.get("repository_url", "")
update_scope = state.get("update_scope", "")
if not repository_url or not update_scope:
raise ValueError("Both 'repository_url' and 'update_scope' must be provided.")
messages = [
SystemMessage(content="You are an assistant that retrieves workflow files from a repository."),
HumanMessage(content=f"Repository URL: {repository_url}\nUpdate Scope: {update_scope}")
]
response = await llm.ainvoke(messages)
workflow_files = response.content.splitlines() # Assuming the LLM returns file names as newline-separated strings.
return {"workflow_files": workflow_files, "phase": "complete"}
except Exception as exc:
return {"error": str(exc), "phase": "failed"}