Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruff: use I rule for isort #1410

Merged
merged 6 commits into from Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions agenthub/SWE_agent/__init__.py
@@ -1,4 +1,5 @@
from opendevin.agent import Agent

from .agent import SWEAgent

Agent.register('SWEAgent', SWEAgent)
14 changes: 7 additions & 7 deletions agenthub/SWE_agent/agent.py
@@ -1,23 +1,23 @@
from typing import List
from opendevin.agent import Agent
from opendevin.llm.llm import LLM
from opendevin.state import State

from opendevin.action import (
Action,
AgentThinkAction,
FileReadAction,
FileWriteAction,
)
from opendevin.agent import Agent
from opendevin.llm.llm import LLM
from opendevin.observation import Observation
from opendevin.state import State

from .parser import parse_command

from .prompts import (
SYSTEM_MESSAGE,
STEP_PROMPT,
CONTEXT_PROMPT,
MEMORY_FORMAT,
NO_ACTION,
CONTEXT_PROMPT
STEP_PROMPT,
SYSTEM_MESSAGE,
)


Expand Down
12 changes: 6 additions & 6 deletions agenthub/SWE_agent/parser.py
@@ -1,17 +1,17 @@
import re

from opendevin.action import (
Action,
AgentEchoAction,
AgentFinishAction,
AgentThinkAction,
BrowseURLAction,
CmdRunAction,
FileReadAction,
FileWriteAction,
BrowseURLAction,
AgentEchoAction,
AgentThinkAction,
)

import re

from .prompts import CUSTOM_DOCS, COMMAND_USAGE
from .prompts import COMMAND_USAGE, CUSTOM_DOCS

# commands: exit, read, write, browse, kill, search_file, search_dir

Expand Down
20 changes: 12 additions & 8 deletions agenthub/__init__.py
@@ -1,17 +1,21 @@
from .micro.registry import all_microagents
from .micro.agent import MicroAgent
from dotenv import load_dotenv

from opendevin.agent import Agent

from dotenv import load_dotenv
from .micro.agent import MicroAgent
from .micro.registry import all_microagents

load_dotenv()


# Import agents after environment variables are loaded
from . import monologue_agent # noqa: E402
from . import codeact_agent # noqa: E402
from . import planner_agent # noqa: E402
from . import SWE_agent # noqa: E402
from . import delegator_agent # noqa: E402
from . import ( # noqa: E402
SWE_agent,
codeact_agent,
delegator_agent,
monologue_agent,
planner_agent,
)

__all__ = ['monologue_agent', 'codeact_agent',
'planner_agent', 'SWE_agent', 'delegator_agent']
Expand Down
1 change: 1 addition & 0 deletions agenthub/codeact_agent/__init__.py
@@ -1,4 +1,5 @@
from opendevin.agent import Agent

from .codeact_agent import CodeActAgent

Agent.register('CodeActAgent', CodeActAgent)
2 changes: 1 addition & 1 deletion agenthub/codeact_agent/codeact_agent.py
Expand Up @@ -13,8 +13,8 @@
AgentMessageObservation,
CmdOutputObservation,
)
from opendevin.sandbox.plugins import JupyterRequirement, PluginRequirement
from opendevin.state import State
from opendevin.sandbox.plugins import PluginRequirement, JupyterRequirement

SYSTEM_MESSAGE = """You are a helpful assistant. You will be provided access (as root) to a bash shell to complete user-provided tasks.
You will be able to execute commands in the bash shell, interact with the file system, install packages, and receive the output of your commands.
Expand Down
1 change: 1 addition & 0 deletions agenthub/delegator_agent/__init__.py
@@ -1,4 +1,5 @@
from opendevin.agent import Agent

from .agent import DelegatorAgent

Agent.register('DelegatorAgent', DelegatorAgent)
5 changes: 2 additions & 3 deletions agenthub/delegator_agent/agent.py
@@ -1,11 +1,10 @@
from typing import List

from opendevin.action import Action, AgentDelegateAction, AgentFinishAction
from opendevin.agent import Agent
from opendevin.action import AgentFinishAction, AgentDelegateAction
from opendevin.observation import AgentDelegateObservation
from opendevin.llm.llm import LLM
from opendevin.observation import AgentDelegateObservation
from opendevin.state import State
from opendevin.action import Action


class DelegatorAgent(Agent):
Expand Down
8 changes: 5 additions & 3 deletions agenthub/dummy_agent/agent.py
@@ -1,12 +1,14 @@
"""Module for a Dummy agent."""

from opendevin.action.base import NullAction
from opendevin.state import State
from opendevin.action import Action
from typing import List

from opendevin.action import Action
from opendevin.action.base import NullAction
from opendevin.agent import Agent
from opendevin.controller.agent_controller import AgentController
from opendevin.observation.base import NullObservation, Observation
from opendevin.state import State


class DummyAgent(Agent):
"""A dummy agent that does nothing but can be used in testing."""
Expand Down
8 changes: 4 additions & 4 deletions agenthub/micro/agent.py
@@ -1,13 +1,13 @@
import json
from typing import List, Dict
from typing import Dict, List

from jinja2 import Environment, BaseLoader
from jinja2 import BaseLoader, Environment

from opendevin.action import Action, action_from_dict
from opendevin.agent import Agent
from opendevin.exceptions import LLMOutputError
from opendevin.llm.llm import LLM
from opendevin.state import State
from opendevin.action import Action, action_from_dict
from opendevin.exceptions import LLMOutputError

from .instructions import instructions
from .registry import all_microagents
Expand Down
2 changes: 1 addition & 1 deletion agenthub/micro/instructions.py
@@ -1,5 +1,5 @@
from typing import Dict
import os
from typing import Dict

instructions: Dict = {}

Expand Down
1 change: 1 addition & 0 deletions agenthub/micro/registry.py
@@ -1,4 +1,5 @@
import os

import yaml

all_microagents = {}
Expand Down
1 change: 1 addition & 0 deletions agenthub/monologue_agent/__init__.py
@@ -1,4 +1,5 @@
from opendevin.agent import Agent

from .agent import MonologueAgent

Agent.register('MonologueAgent', MonologueAgent)
37 changes: 18 additions & 19 deletions agenthub/monologue_agent/agent.py
@@ -1,35 +1,34 @@
from typing import List
from opendevin.agent import Agent
from opendevin.state import State
from opendevin.llm.llm import LLM
from opendevin.schema import ActionType
from opendevin.exceptions import AgentNoInstructionError
from opendevin.schema.config import ConfigType
from opendevin import config

import agenthub.monologue_agent.utils.prompts as prompts
from agenthub.monologue_agent.utils.monologue import Monologue
from opendevin import config
from opendevin.action import (
Action,
NullAction,
CmdRunAction,
FileWriteAction,
FileReadAction,
AgentRecallAction,
AgentThinkAction,
BrowseURLAction,
CmdRunAction,
FileReadAction,
FileWriteAction,
GitHubPushAction,
AgentThinkAction,
NullAction,
)

from opendevin.agent import Agent
from opendevin.exceptions import AgentNoInstructionError
from opendevin.llm.llm import LLM
from opendevin.observation import (
Observation,
NullObservation,
CmdOutputObservation,
FileReadObservation,
AgentRecallObservation,
BrowserOutputObservation,
CmdOutputObservation,
FileReadObservation,
NullObservation,
Observation,
)
from opendevin.schema import ActionType
from opendevin.schema.config import ConfigType
from opendevin.state import State

import agenthub.monologue_agent.utils.prompts as prompts
from agenthub.monologue_agent.utils.monologue import Monologue
if config.get(ConfigType.AGENT_MEMORY_ENABLED):
from agenthub.monologue_agent.utils.memory import LongTermMemory

Expand Down
1 change: 1 addition & 0 deletions agenthub/monologue_agent/utils/json.py
@@ -1,4 +1,5 @@
import json

from json_repair import repair_json


Expand Down
15 changes: 10 additions & 5 deletions agenthub/monologue_agent/utils/memory.py
@@ -1,17 +1,22 @@
import llama_index.embeddings.openai.base as llama_openai
import threading

import chromadb
from llama_index.core import Document
import llama_index.embeddings.openai.base as llama_openai
from llama_index.core import Document, VectorStoreIndex
from llama_index.core.retrievers import VectorIndexRetriever
from llama_index.core import VectorStoreIndex
from llama_index.vector_stores.chroma import ChromaVectorStore
from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_random_exponential
from openai._exceptions import APIConnectionError, RateLimitError, InternalServerError
from openai._exceptions import APIConnectionError, InternalServerError, RateLimitError
from tenacity import (
retry,
retry_if_exception_type,
stop_after_attempt,
wait_random_exponential,
)

from opendevin import config
from opendevin.logger import opendevin_logger as logger
from opendevin.schema.config import ConfigType

from . import json

num_retries = config.get(ConfigType.LLM_NUM_RETRIES)
Expand Down
4 changes: 2 additions & 2 deletions agenthub/monologue_agent/utils/monologue.py
@@ -1,8 +1,8 @@

from opendevin.llm.llm import LLM
from opendevin.exceptions import AgentEventTypeError
import agenthub.monologue_agent.utils.json as json
import agenthub.monologue_agent.utils.prompts as prompts
from opendevin.exceptions import AgentEventTypeError
from opendevin.llm.llm import LLM
from opendevin.logger import opendevin_logger as logger


Expand Down
15 changes: 7 additions & 8 deletions agenthub/monologue_agent/utils/prompts.py
@@ -1,21 +1,20 @@
from typing import List

from . import json
from json import JSONDecodeError

import re
from json import JSONDecodeError
from typing import List

from opendevin import config
from opendevin.action import (
action_from_dict,
Action,
action_from_dict,
)
from opendevin.exceptions import LLMOutputError
from opendevin.observation import (
CmdOutputObservation,
)
from opendevin.exceptions import LLMOutputError
from opendevin import config
from opendevin.schema.config import ConfigType

from . import json

ACTION_PROMPT = """
You're a thoughtful robot. Your main task is this:
%(task)s
Expand Down
1 change: 1 addition & 0 deletions agenthub/planner_agent/__init__.py
@@ -1,4 +1,5 @@
from opendevin.agent import Agent

from .agent import PlannerAgent

Agent.register('PlannerAgent', PlannerAgent)
6 changes: 3 additions & 3 deletions agenthub/planner_agent/agent.py
@@ -1,11 +1,11 @@
from typing import List
from .prompt import get_prompt, parse_response

from opendevin.action import Action, AgentFinishAction
from opendevin.agent import Agent
from opendevin.action import AgentFinishAction
from opendevin.llm.llm import LLM
from opendevin.state import State
from opendevin.action import Action

from .prompt import get_prompt, parse_response


class PlannerAgent(Agent):
Expand Down
30 changes: 15 additions & 15 deletions agenthub/planner_agent/prompt.py
@@ -1,29 +1,29 @@
import json
from typing import List, Tuple, Dict, Type
from opendevin.plan import Plan
from opendevin.action import Action, action_from_dict
from opendevin.observation import Observation
from opendevin.schema import ActionType
from opendevin.logger import opendevin_logger as logger
from typing import Dict, List, Tuple, Type

from opendevin.action import (
NullAction,
CmdRunAction,
CmdKillAction,
Action,
AddTaskAction,
AgentFinishAction,
AgentRecallAction,
AgentSummarizeAction,
AgentThinkAction,
BrowseURLAction,
CmdKillAction,
CmdRunAction,
FileReadAction,
FileWriteAction,
AgentRecallAction,
AgentThinkAction,
AgentFinishAction,
AgentSummarizeAction,
AddTaskAction,
ModifyTaskAction,
NullAction,
action_from_dict,
)

from opendevin.logger import opendevin_logger as logger
from opendevin.observation import (
NullObservation,
Observation,
)
from opendevin.plan import Plan
from opendevin.schema import ActionType

ACTION_TYPE_TO_CLASS: Dict[str, Type[Action]] = {
ActionType.RUN: CmdRunAction,
Expand Down
1 change: 1 addition & 0 deletions dev_config/python/ruff.toml
Expand Up @@ -7,6 +7,7 @@ select = [
"E",
"W",
"F",
"I",
"Q",
]

Expand Down