IssueTriage can now interact with task in YouTrack and it is idempotent
This commit is contained in:
@@ -5,8 +5,9 @@ from contextlib import asynccontextmanager
|
||||
import httpx
|
||||
from dotenv import load_dotenv
|
||||
from fastapi import FastAPI, HTTPException
|
||||
from agents.issue_reader.IssueReaderAgent import IssueReaderAgent
|
||||
from agents.issue_reader.context_builder import YouTrackContextBuilder
|
||||
from agents.issue_triage.IssueTriageAgent import IssueTriageAgent
|
||||
from agents.issue_triage.context_builder import YouTrackContextBuilder
|
||||
from agents.registry import AgentRegistry
|
||||
from common.llm_client import LLMClient
|
||||
from common.youtrack_mcp_client import YouTrackMCPClient, IssueNotFound
|
||||
|
||||
@@ -26,6 +27,13 @@ async def lifespan(app: FastAPI):
|
||||
str(os.getenv('YOUTRACK_MCP_SERVER')),
|
||||
str(os.getenv('YOUTRACK_MCP_TOKEN')),
|
||||
).connect()
|
||||
#
|
||||
#
|
||||
# res = await mcp.call_tool(
|
||||
# "add_issue_comment",
|
||||
# {"issueId": "ARCH-229", "text": "test"}
|
||||
# )
|
||||
# logger.info(res)
|
||||
|
||||
http_for_attachments = httpx.AsyncClient(
|
||||
headers={"Authorization": f"Bearer {env('YOUTRACK_MCP_TOKEN')}"},
|
||||
@@ -34,13 +42,15 @@ async def lifespan(app: FastAPI):
|
||||
follow_redirects=True,
|
||||
)
|
||||
|
||||
app.state.issue_reader_agent = IssueReaderAgent(
|
||||
app.state.issue_reader_agent = IssueTriageAgent(
|
||||
YouTrackContextBuilder(mcp, http_for_attachments),
|
||||
LLMClient(
|
||||
base_url=env("LLM_ADDRESS"),
|
||||
api_key=env("LLM_API_KEY"),
|
||||
model=env("LLM_MODEL"),
|
||||
),
|
||||
AgentRegistry(),
|
||||
mcp
|
||||
)
|
||||
|
||||
yield
|
||||
@@ -59,14 +69,14 @@ async def say_hello(name: str):
|
||||
return {"message": f"Hello {name}"}
|
||||
|
||||
|
||||
@app.get("/decomposing")
|
||||
@app.get("/consume_task")
|
||||
async def decomposing_issue(issue: str):
|
||||
agent: IssueReaderAgent = app.state.issue_reader_agent
|
||||
agent: IssueTriageAgent = app.state.issue_reader_agent
|
||||
try:
|
||||
logger.info(f"Received an issue: {issue}")
|
||||
plan = await agent.plan_issue(issue)
|
||||
logger.info("Task planning successful.")
|
||||
print(agent.render(plan))
|
||||
logger.info(plan.render())
|
||||
return {"plan": plan}
|
||||
except IssueNotFound:
|
||||
logger.error(f"Issue {issue} not found.")
|
||||
|
||||
Reference in New Issue
Block a user