add run/check scripts and revert llm to OpenRouter
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,30 @@
|
|||||||
|
import asyncio, json
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
load_dotenv()
|
||||||
|
from src.agent.mcp_client import load_journal_toolsets, JOURNAL_PREFIX
|
||||||
|
from src.agent.constants import COURSE_ID
|
||||||
|
|
||||||
|
|
||||||
|
async def main():
|
||||||
|
j = load_journal_toolsets()
|
||||||
|
tool = next((t for t in j.tasks_submissions_tools if t.name == f"{JOURNAL_PREFIX}tasks_list"), None)
|
||||||
|
if not tool:
|
||||||
|
print("tasks_list not found")
|
||||||
|
return
|
||||||
|
raw = await tool.ainvoke({"courseId": COURSE_ID})
|
||||||
|
if isinstance(raw, list):
|
||||||
|
for item in raw:
|
||||||
|
if isinstance(item, dict) and item.get("type") == "text":
|
||||||
|
raw = item.get("text", "")
|
||||||
|
break
|
||||||
|
data = json.loads(raw) if isinstance(raw, str) else raw
|
||||||
|
items = data.get("tasks", data) if isinstance(data, dict) else data
|
||||||
|
for item in items:
|
||||||
|
t = item.get("task", item) if isinstance(item, dict) else {}
|
||||||
|
tid = t.get("id", "")
|
||||||
|
status = item.get("status", "")
|
||||||
|
title = t.get("title", "")
|
||||||
|
print(f" {tid[:8]} {status:25} {title}")
|
||||||
|
|
||||||
|
|
||||||
|
asyncio.run(main())
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
from dotenv import load_dotenv
|
||||||
|
load_dotenv()
|
||||||
|
from src.agent.gitea_tools import _get
|
||||||
|
from src.agent.constants import GITEA_OWNER
|
||||||
|
|
||||||
|
result = _get("/api/v1/repos/search", limit=50, token="")
|
||||||
|
repos = result.get("data", result) if isinstance(result, dict) else result
|
||||||
|
for r in sorted(repos, key=lambda x: x.get("updated", ""), reverse=True):
|
||||||
|
print(f" {r.get('name',''):40} {r.get('updated','')[:10]}")
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
"""Запуск пайплайна для выполнения заданий курса."""
|
||||||
|
import asyncio
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
os.environ["PYTHONIOENCODING"] = "utf-8"
|
||||||
|
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
load_dotenv()
|
||||||
|
|
||||||
|
from langchain_core.messages import HumanMessage
|
||||||
|
from src.agent.graph.pipeline import pipeline
|
||||||
|
|
||||||
|
|
||||||
|
async def main():
|
||||||
|
print("=== Запуск пайплайна BroJS ===")
|
||||||
|
result = await pipeline.ainvoke(
|
||||||
|
{
|
||||||
|
"tasks": [],
|
||||||
|
"current_index": 0,
|
||||||
|
"results": [],
|
||||||
|
"errors": [],
|
||||||
|
},
|
||||||
|
{"configurable": {"thread_id": "pipeline-main"}},
|
||||||
|
)
|
||||||
|
print("\n=== Результат пайплайна ===")
|
||||||
|
for r in result.get("results", []):
|
||||||
|
print(f" Task {r['task_id'][:8]}: {r['status']} (mode={r['mode']}, retries={r['retries']})")
|
||||||
|
for e in result.get("errors", []):
|
||||||
|
print(f" ОШИБКА: {e}")
|
||||||
|
print("=== Готово ===")
|
||||||
|
|
||||||
|
|
||||||
|
asyncio.run(main())
|
||||||
+3
-5
@@ -1,4 +1,4 @@
|
|||||||
"""Инициализация LLM через BroJS Inference API (токены учитываются на платформе)."""
|
"""Инициализация LLM через OpenRouter."""
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
@@ -6,11 +6,9 @@ from langchain_openai import ChatOpenAI
|
|||||||
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
|
||||||
# Используем BroJS Inference API — тот же JOURNAL_TOKEN (jrnl_...)
|
|
||||||
# Токены учитываются на платформе platform.brojs.ru
|
|
||||||
llm = ChatOpenAI(
|
llm = ChatOpenAI(
|
||||||
model="openai/gpt-oss-20b:free",
|
model="openai/gpt-oss-20b:free",
|
||||||
base_url="https://platform.brojs.ru/jrnl-bh/api/inference/v1",
|
base_url="https://openrouter.ai/api/v1",
|
||||||
api_key=os.getenv("JOURNAL_TOKEN", "YOUR_JOURNAL_TOKEN_HERE"),
|
api_key=os.getenv("OPENAI_API_KEY", "YOUR_OPENROUTER_KEY_HERE"),
|
||||||
temperature=0.0,
|
temperature=0.0,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user