mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-04-29 03:00:45 -04:00
* add generic llm client * fix lint errors * fix lint issues * a potential suggestion for llm wrapper to keep all the function sigatures for ide * use completion partial * fix resp * remove unused args * add back truncation logic * fix add_event * fix merge issues * more merge issues fixed * fix codeact agent * remove dead code * remove import * unused imports * fix ruff * update requirements * mypy fixes * more lint fixes * fix browser errors * fix up observation conversion * fix format of error * change max iter default back to 100 * fix kill action * fix docker cleanup * add RUN_AS_DEVIN flag * fix condense * revert some files * unused imports --------- Co-authored-by: Xingyao Wang <xingyao6@illinois.edu> Co-authored-by: Robert Brennan <rbren@Roberts-MacBook-Pro.local>
56 lines
1.6 KiB
Python
56 lines
1.6 KiB
Python
import asyncio
|
|
import argparse
|
|
|
|
from typing import Type
|
|
|
|
import agenthub # noqa F401 (we import this to get the agents registered)
|
|
from opendevin.agent import Agent
|
|
from opendevin.controller import AgentController
|
|
from opendevin.llm.llm import LLM
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser(description="Run an agent with a specific task")
|
|
parser.add_argument(
|
|
"-d",
|
|
"--directory",
|
|
required=True,
|
|
type=str,
|
|
help="The working directory for the agent",
|
|
)
|
|
parser.add_argument(
|
|
"-t",
|
|
"--task",
|
|
required=True,
|
|
type=str,
|
|
help="The task for the agent to perform",
|
|
)
|
|
parser.add_argument(
|
|
"-c",
|
|
"--agent-cls",
|
|
default="LangchainsAgent",
|
|
type=str,
|
|
help="The agent class to use",
|
|
)
|
|
parser.add_argument(
|
|
"-m",
|
|
"--model-name",
|
|
default="gpt-4-0125-preview",
|
|
type=str,
|
|
help="The (litellm) model name to use",
|
|
)
|
|
parser.add_argument(
|
|
"-i",
|
|
"--max-iterations",
|
|
default=100,
|
|
type=int,
|
|
help="The maximum number of iterations to run the agent",
|
|
)
|
|
args = parser.parse_args()
|
|
|
|
print(f"Running agent {args.agent_cls} (model: {args.model_name}, directory: {args.directory}) with task: \"{args.task}\"")
|
|
llm = LLM(args.model_name)
|
|
AgentCls: Type[Agent] = Agent.get_cls(args.agent_cls)
|
|
agent = AgentCls(llm=llm)
|
|
controller = AgentController(agent, workdir=args.directory, max_iterations=args.max_iterations)
|
|
asyncio.run(controller.start_loop(args.task))
|