Add src/cli.py
This commit is contained in:
+37
@@ -0,0 +1,37 @@
|
|||||||
|
"""Command‑line interface for the research brief generator.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
python -m src.cli "Your research question"
|
||||||
|
|
||||||
|
The CLI will:
|
||||||
|
1. Build the LangGraph.
|
||||||
|
2. Run the graph with the supplied topic.
|
||||||
|
3. Print the outline, step‑by‑step notes, and final brief.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import asyncio
|
||||||
|
import sys
|
||||||
|
from .brief import build_graph
|
||||||
|
|
||||||
|
def main():
|
||||||
|
if len(sys.argv) < 2:
|
||||||
|
print("Usage: python -m src.cli \"Your research question\"")
|
||||||
|
sys.exit(1)
|
||||||
|
topic = sys.argv[1]
|
||||||
|
graph = build_graph()
|
||||||
|
state = {
|
||||||
|
"topic": topic,
|
||||||
|
"outline": None,
|
||||||
|
"step_index": 0,
|
||||||
|
"notes": [],
|
||||||
|
"final_brief": None,
|
||||||
|
}
|
||||||
|
result = asyncio.run(graph.invoke(state))
|
||||||
|
# The graph already prints progress.
|
||||||
|
# Print final brief if not already printed.
|
||||||
|
if result.get("final_brief"):
|
||||||
|
print("\n=== Final Brief ===")
|
||||||
|
print(result["final_brief"])
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user