mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-18 12:04:45 +08:00
fix: fix coordinator prompt
This commit is contained in:
103
main.py
103
main.py
@@ -3,13 +3,86 @@ Entry point script for the Lite Deep Researcher project.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
from InquirerPy import inquirer
|
||||
|
||||
from src.workflow import run_agent_workflow
|
||||
from src.config.questions import BUILT_IN_QUESTIONS, BUILT_IN_QUESTIONS_ZH_CN
|
||||
|
||||
|
||||
def ask(question, debug=False, max_plan_iterations=1, max_step_num=3):
|
||||
"""Run the agent workflow with the given question.
|
||||
|
||||
Args:
|
||||
question: The user's query or request
|
||||
debug: If True, enables debug level logging
|
||||
max_plan_iterations: Maximum number of plan iterations
|
||||
max_step_num: Maximum number of steps in a plan
|
||||
"""
|
||||
run_agent_workflow(
|
||||
user_input=question,
|
||||
debug=debug,
|
||||
max_plan_iterations=max_plan_iterations,
|
||||
max_step_num=max_step_num,
|
||||
)
|
||||
|
||||
|
||||
def main(debug=False, max_plan_iterations=1, max_step_num=3):
|
||||
"""Interactive mode with built-in questions.
|
||||
|
||||
Args:
|
||||
debug: If True, enables debug level logging
|
||||
max_plan_iterations: Maximum number of plan iterations
|
||||
max_step_num: Maximum number of steps in a plan
|
||||
"""
|
||||
# First select language
|
||||
language = inquirer.select(
|
||||
message="Select language / 选择语言:",
|
||||
choices=["English", "中文"],
|
||||
).execute()
|
||||
|
||||
# Choose questions based on language
|
||||
questions = (
|
||||
BUILT_IN_QUESTIONS if language == "English" else BUILT_IN_QUESTIONS_ZH_CN
|
||||
)
|
||||
ask_own_option = (
|
||||
"[Ask my own question]" if language == "English" else "[自定义问题]"
|
||||
)
|
||||
|
||||
# Select a question
|
||||
initial_question = inquirer.select(
|
||||
message=(
|
||||
"What do you want to know?" if language == "English" else "您想了解什么?"
|
||||
),
|
||||
choices=[ask_own_option] + questions,
|
||||
).execute()
|
||||
|
||||
if initial_question == ask_own_option:
|
||||
initial_question = inquirer.text(
|
||||
message=(
|
||||
"What do you want to know?"
|
||||
if language == "English"
|
||||
else "您想了解什么?"
|
||||
),
|
||||
).execute()
|
||||
|
||||
# Pass all parameters to ask function
|
||||
ask(
|
||||
question=initial_question,
|
||||
debug=debug,
|
||||
max_plan_iterations=max_plan_iterations,
|
||||
max_step_num=max_step_num,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Set up argument parser
|
||||
parser = argparse.ArgumentParser(description="Run the Lite Deep Researcher")
|
||||
parser.add_argument("query", nargs="*", help="The query to process")
|
||||
parser.add_argument(
|
||||
"--interactive",
|
||||
action="store_true",
|
||||
help="Run in interactive mode with built-in questions",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--max_plan_iterations",
|
||||
type=int,
|
||||
@@ -26,16 +99,24 @@ if __name__ == "__main__":
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# Parse user input from command line arguments or user input
|
||||
if args.query:
|
||||
user_query = " ".join(args.query)
|
||||
if args.interactive:
|
||||
# Pass command line arguments to main function
|
||||
main(
|
||||
debug=args.debug,
|
||||
max_plan_iterations=args.max_plan_iterations,
|
||||
max_step_num=args.max_step_num,
|
||||
)
|
||||
else:
|
||||
user_query = input("Enter your query: ")
|
||||
# Parse user input from command line arguments or user input
|
||||
if args.query:
|
||||
user_query = " ".join(args.query)
|
||||
else:
|
||||
user_query = input("Enter your query: ")
|
||||
|
||||
# Run the agent workflow with the provided parameters
|
||||
run_agent_workflow(
|
||||
user_input=user_query,
|
||||
debug=args.debug,
|
||||
max_plan_iterations=args.max_plan_iterations,
|
||||
max_step_num=args.max_step_num,
|
||||
)
|
||||
# Run the agent workflow with the provided parameters
|
||||
ask(
|
||||
question=user_query,
|
||||
debug=args.debug,
|
||||
max_plan_iterations=args.max_plan_iterations,
|
||||
max_step_num=args.max_step_num,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user