Skip to content

Commit eda3c05

Browse files
authored
ModelAdapter Chat (#17)
* implemented model chat * fixed tests * improved testing * improved call logs * fixed test file * fixed docs
1 parent 131f59a commit eda3c05

19 files changed

Lines changed: 3489 additions & 327 deletions

File tree

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
**ModelAdapter Chat Interface**
13+
14+
- Added `chat()` method to `ModelAdapter` as the primary interface for LLM inference, accepting a list of messages in OpenAI format and returning a `ChatResponse` object and accepting tools
15+
- Added `ChatResponse` dataclass containing `content`, `tool_calls`, `role`, `usage`, `model`, and `stop_reason` fields for structured response handling
16+
17+
**AnthropicModelAdapter**
18+
19+
- New `AnthropicModelAdapter` for direct integration with Anthropic Claude models via the official Anthropic SDK
20+
- Handles Anthropic-specific message format conversion (system messages, tool_use/tool_result blocks) internally while accepting OpenAI-compatible input
21+
- Added `anthropic` optional dependency: `pip install maseval[anthropic]`
22+
1223
### Changed
1324

1425
### Fixed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Anthropic Inference Adapter
2+
3+
This page documents the [Anthropic](https://docs.anthropic.com/) model adapter for MASEval.
4+
5+
[:material-github: View source](https://github.com/parameterlab/maseval/blob/main/maseval/interface/inference/anthropic.py){ .md-source-file }
6+
7+
::: maseval.interface.inference.anthropic.AnthropicModelAdapter

docs/reference/model.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,11 @@ The following adapter classes implement the ModelAdapter interface for specific
2525
[:material-github: View source](https://github.com/parameterlab/maseval/blob/main/maseval/interface/inference/google_genai.py){ .md-source-file }
2626

2727
::: maseval.interface.inference.google_genai.GoogleGenAIModelAdapter
28+
29+
[:material-github: View source](https://github.com/parameterlab/maseval/blob/main/maseval/interface/inference/litellm.py){ .md-source-file }
30+
31+
::: maseval.interface.inference.litellm.LiteLLMModelAdapter
32+
33+
[:material-github: View source](https://github.com/parameterlab/maseval/blob/main/maseval/interface/inference/anthropic.py){ .md-source-file }
34+
35+
::: maseval.interface.inference.anthropic.AnthropicModelAdapter

maseval/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
ToolSimulatorError,
2323
UserSimulatorError,
2424
)
25-
from .core.model import ModelAdapter
25+
from .core.model import ModelAdapter, ChatResponse
2626
from .core.user import User, TerminationReason
2727
from .core.evaluator import Evaluator
2828
from .core.history import MessageHistory, ToolInvocationHistory
@@ -67,8 +67,10 @@
6767
# History and tracing
6868
"MessageHistory",
6969
"ToolInvocationHistory",
70-
"ModelAdapter",
7170
"TraceableMixin",
71+
# Model adapters
72+
"ModelAdapter",
73+
"ChatResponse",
7274
# Exceptions and validation
7375
"MASEvalError",
7476
"AgentError",

0 commit comments

Comments
 (0)