feat: solution for 'Повторный экзамен #2: Сравнительный обзор 3 сущностей (Tavily)'
This commit is contained in:
+21
-20
@@ -1,44 +1,45 @@
|
||||
import argparse
|
||||
from typing import List
|
||||
import os
|
||||
from src.graph import build_graph
|
||||
from src.state import CompareState
|
||||
|
||||
from .state import CompareState
|
||||
from .graph import create_graph
|
||||
|
||||
def parse_entities(arg: str) -> List[str]:
|
||||
def parse_entities(arg: str) -> list[str]:
|
||||
return [e.strip() for e in arg.split(",") if e.strip()]
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="LangGraph Comparative Review Agent")
|
||||
parser = argparse.ArgumentParser(description="Research Brief Generator")
|
||||
parser.add_argument(
|
||||
"-e",
|
||||
"--entities",
|
||||
type=str,
|
||||
help="Comma-separated list of three entities to compare. "
|
||||
"If omitted, defaults to Chroma, FAISS, Qdrant.",
|
||||
help="Comma-separated list of 3 entities to compare",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.entities:
|
||||
entities = parse_entities(args.entities)
|
||||
if len(entities) != 3:
|
||||
raise ValueError("Please provide exactly three entities.")
|
||||
print("Please provide exactly 3 entities.")
|
||||
return
|
||||
else:
|
||||
# Default entities
|
||||
entities = ["Chroma", "FAISS", "Qdrant"]
|
||||
|
||||
initial_state: CompareState = {
|
||||
# Initial state
|
||||
state: CompareState = {
|
||||
"entities": entities,
|
||||
"criteria": [],
|
||||
"findings": {},
|
||||
"final_brief": None,
|
||||
"verdict": None,
|
||||
}
|
||||
|
||||
graph = create_graph()
|
||||
final_state = graph.invoke(initial_state)
|
||||
graph = build_graph()
|
||||
final_state = graph.invoke(state)
|
||||
|
||||
print("\n=== Comparison Criteria ===")
|
||||
for idx, crit in enumerate(final_state["criteria"], 1):
|
||||
print(f"{idx}. {crit}")
|
||||
|
||||
print("\n=== Findings Table ===")
|
||||
print(final_state["final_table"])
|
||||
|
||||
print("\n=== Verdict ===")
|
||||
print("\n=== Research Brief ===\n")
|
||||
print(final_state["final_brief"])
|
||||
print("\n=== Verdict ===\n")
|
||||
print(final_state["verdict"])
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user