Skip to content

Commit

Permalink
refactor: move TargetResponse to targets.TargetResponse for better or…
Browse files Browse the repository at this point in the history
…ganization
  • Loading branch information
tonykchen committed May 21, 2024
1 parent eb85e7e commit b11224e
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 20 deletions.
2 changes: 1 addition & 1 deletion docs/reference/target_response.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::: src.agenteval.target_response
::: src.agenteval.targets.target_response
11 changes: 4 additions & 7 deletions docs/targets/custom_targets.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

If you want to test an agent that is not natively supported, you can bring your own Target by defining a Python module containing a subclass of [BaseTarget](../reference/base_target.md#src.agenteval.targets.base_target.BaseTarget). The name of this module must contain the suffix `_target` (e.g. `my_custom_target`).

The subclass should implement the `invoke` method to invoke your agent and return a [TargetResponse](../reference/target_response.md#src.agenteval.target_response.TargetResponse).
The subclass should implement the `invoke` method to invoke your agent and return a [TargetResponse](../reference/target_response.md#src.agenteval.targets.target_response.TargetResponse).

```python title="my_custom_target.py"
from agenteval.targets import BaseTarget
from agenteval import TargetResponse
from agenteval.targets import BaseTarget, TargetResponse
from my_agent import MyAgent

class MyCustomTarget(BaseTarget):
Expand Down Expand Up @@ -49,8 +48,7 @@ We will implement a custom Target that invokes an agent exposed as a REST API.
import requests
from agenteval.targets import BaseTarget
from agenteval import TargetResponse
from agenteval.targets import BaseTarget, TargetResponse
class MyAPITarget(BaseTarget):
Expand Down Expand Up @@ -98,8 +96,7 @@ We will create a simple [LangChain](https://python.langchain.com/docs/modules/ag
from langchain import hub
from langchain.agents import AgentExecutor, create_xml_agent
from agenteval.targets import BaseTarget
from agenteval import TargetResponse
from agenteval.targets import BaseTarget, TargetResponse
llm = Bedrock(model_id="anthropic.claude-v2:1")
Expand Down
3 changes: 1 addition & 2 deletions src/agenteval/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
from rich.logging import RichHandler

from .hook import Hook
from .target_response import TargetResponse

__all__ = ["Hook", "TargetResponse"]
__all__ = ["Hook"]
__version__ = version("agent-evaluation")


Expand Down
3 changes: 2 additions & 1 deletion src/agenteval/targets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

from .target_response import TargetResponse
from .base_target import BaseTarget
from .boto3_target import Boto3Target
from .target_factory import TargetFactory

__all__ = ["BaseTarget", "TargetFactory", "Boto3Target"]
__all__ = ["TargetResponse", "BaseTarget", "TargetFactory", "Boto3Target"]
2 changes: 1 addition & 1 deletion src/agenteval/targets/base_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from abc import ABC, abstractmethod

from agenteval import TargetResponse
from agenteval.targets import TargetResponse


class BaseTarget(ABC):
Expand Down
3 changes: 1 addition & 2 deletions src/agenteval/targets/bedrock_agent/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

import uuid

from agenteval import TargetResponse
from agenteval.targets import Boto3Target
from agenteval.targets import Boto3Target, TargetResponse

_SERVICE_NAME = "bedrock-agent-runtime"

Expand Down
3 changes: 1 addition & 2 deletions src/agenteval/targets/bedrock_knowledge_base/target.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

from agenteval import TargetResponse
from agenteval.targets import Boto3Target
from agenteval.targets import Boto3Target, TargetResponse

_SERVICE_NAME = "bedrock-agent-runtime"

Expand Down
3 changes: 1 addition & 2 deletions src/agenteval/targets/q_business/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

from typing import Optional

from agenteval import TargetResponse
from agenteval.targets import Boto3Target
from agenteval.targets import Boto3Target, TargetResponse

_SERVICE_NAME = "qbusiness"

Expand Down
3 changes: 1 addition & 2 deletions src/agenteval/targets/sagemaker_endpoint/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

from jsonpath_ng import parse

from agenteval import TargetResponse
from agenteval.targets import Boto3Target
from agenteval.targets import Boto3Target, TargetResponse

_SERVICE_NAME = "sagemaker-runtime"
_CONTENT_TYPE = "application/json"
Expand Down
File renamed without changes.

0 comments on commit b11224e

Please sign in to comment.