33 lines
1.4 KiB
Python
33 lines
1.4 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.
|
|
|
|
Input Schema:
|
|
- repository_url: The URL of the repository to retrieve files from.
|
|
- update_scope: The scope or context for the update (e.g., branch, directory).
|
|
|
|
Output Schema:
|
|
- workflow_files: A list of workflow file names retrieved 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"Retrieve workflow files from the repository at {repository_url} within the scope '{update_scope}'.")
|
|
]
|
|
|
|
response = await llm.ainvoke(messages)
|
|
workflow_files = response.content.splitlines() # Assuming the response lists files line by line.
|
|
|
|
return {"workflow_files": workflow_files, "phase": "complete"}
|
|
except Exception as exc:
|
|
return {"error": str(exc), "phase": "failed"} |