agent-factory: generate agent auto-retrieve-files-from-a-reposito
This commit is contained in:
0
app/nodes/__init__.py
Normal file
0
app/nodes/__init__.py
Normal file
26
app/nodes/core_node.py
Normal file
26
app/nodes/core_node.py
Normal file
@@ -0,0 +1,26 @@
|
||||
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"}
|
||||
Reference in New Issue
Block a user