From fe47b791292c7d34dbc267dc5b934040e8dfb178 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D0=B5=D0=BC=20=D0=92=D0=BB=D0=B0=D0=B4?= =?UTF-8?q?=D0=B8=D0=BC=D0=B8=D1=80=D0=BE=D0=B2=D0=B8=D1=87=20=D0=91=D0=B0?= =?UTF-8?q?=D0=B1=D0=B0=D0=B9=D0=BA=D0=B8=D0=BD?= Date: Thu, 28 May 2026 16:29:47 +0000 Subject: [PATCH] feat: solution for unknown --- solutions/unknown/solution.py | 92 +++++++++++++++++++++++++++++------ 1 file changed, 78 insertions(+), 14 deletions(-) diff --git a/solutions/unknown/solution.py b/solutions/unknown/solution.py index 74bb834..24602b5 100644 --- a/solutions/unknown/solution.py +++ b/solutions/unknown/solution.py @@ -1,18 +1,82 @@ -def main(): - if len(sys.argv) < 2: - print("Usage: python script.py --task-text 'текст задания'") - return - # Find the flag and its value - try: - idx = sys.argv.index("--task-text") - task_text = sys.argv[idx + 1] - except (ValueError, IndexError): - print("Error: '--task-text' flag not found or missing value.") - return +from langchain_openai import ChatOpenAI +from pydantic import BaseModel, Field, SecretStr +from langchain.agents import create_agent +import sys - # Here you would normally process the task text with your orchestrator logic. - # For demonstration, we simply echo it back. - print(f"Received task text: {task_text}") +# LLM placeholder configuration +llm = ChatOpenAI( + model="openai/gpt-oss-20b", + base_url='https://platform.brojs.ru/jrnl-bh/api/inference/v1', + api_key=SecretStr("jrnl_30283ab953615cbb6846ff9940a1eedce0b76d7b2f59a2394f29e74643e6a90d"), + temperature=0.7, +) + +# ---------- Pydantic models ---------- +class PersonInfo(BaseModel): + """Information about a person.""" + name: str = Field(description="Full name of the person") + age: int | None = Field(default=None, description="Age in years, optional") + profession: str = Field(description="Current occupation or job title") + skills: list[str] = Field(description="List of professional skills") + +class MeetingNotes(BaseModel): + """Summary of a meeting.""" + date: str = Field(description="Date of the meeting (ISO format)") + participants: list[str] = Field(description="Names of attendees") + topics: list[str] = Field(description="Main discussion topics") + decisions: list[str] = Field(description="Decisions made during the meeting") + next_steps: list[str] = Field(description="Action items for follow‑up") + +# ---------- Agent creation ---------- +agent_person = create_agent( + model=llm, + response_format=PersonInfo, + system_prompt="You are an assistant that extracts structured person information from a single sentence.", +) + +agent_meeting = create_agent( + model=llm, + response_format=MeetingNotes, + system_prompt="You are an assistant that extracts structured meeting notes from a paragraph of text.", +) + +# ---------- Simple heuristic to choose schema ---------- +def detect_schema(text: str) -> str: + """Return 'person' or 'meeting' based on simple keyword heuristics.""" + lower = text.lower() + if any(word in lower for word in ("profession", "skills", "age")): + return "person" + if any(word in lower for word in ("meeting", "participants", "decisions", "next steps")): + return "meeting" + # Default to person if ambiguous + return "person" + +# ---------- CLI ---------- +def main(): + examples = [ + "Анна, 28 лет, Python-разработчик. Навыки: FastAPI, Docker.", + ("Встреча с командой по проекту X прошла 2024-05-20.\n" + "Участники: Иван, Мария, Алексей.\n" + "Темы: планирование спринта, распределение задач.\n" + "Решения: назначить ответственных за каждый модуль.\n" + "Next steps: подготовить спецификации к 2024-05-27."), + ] + + if len(sys.argv) > 1: + texts = [" ".join(sys.argv[1:])] + else: + texts = examples + + for txt in texts: + print("\n=== Input ===") + print(txt) + schema_type = detect_schema(txt) + agent = agent_person if schema_type == "person" else agent_meeting + result = agent.invoke({"messages": [{"role": "user", "content": txt}]}) + structured = result["structured_response"] + print("\n=== Output ===") + print(structured.model_dump(indent=2)) + print("\n---") if __name__ == "__main__": main() \ No newline at end of file