-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
529 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"""Mock agenta module for testing""" | ||
from typing import Any, Dict, Type, TypeVar, Optional | ||
from dataclasses import dataclass | ||
|
||
T = TypeVar('T') | ||
|
||
@dataclass | ||
class ConfigManager: | ||
"""Mock ConfigManager""" | ||
@staticmethod | ||
def get_from_route(schema: Type[T]) -> T: | ||
return schema() | ||
|
||
def route(path: str = "", config_schema: Optional[Type[Any]] = None): | ||
"""Mock route decorator""" | ||
def decorator(func): | ||
return func | ||
return decorator | ||
|
||
def instrument(): | ||
"""Mock instrument decorator""" | ||
def decorator(func): | ||
return func | ||
return decorator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import pytest | ||
from typing import List, Optional, Dict, Any | ||
from dataclasses import dataclass | ||
|
||
@dataclass | ||
class Message: | ||
role: str | ||
content: str | ||
tool_calls: Optional[List[Dict[str, Any]]] = None | ||
|
||
@dataclass | ||
class Choice: | ||
message: Message | ||
index: int = 0 | ||
finish_reason: str = "stop" | ||
|
||
@dataclass | ||
class Response: | ||
choices: List[Choice] | ||
model: str = "gpt-4" | ||
id: str = "mock-response-id" | ||
|
||
class MockLiteLLM: | ||
"""Mock LiteLLM for testing""" | ||
|
||
async def acompletion(self, **kwargs): | ||
"""Mock async completion""" | ||
model = kwargs.get("model", "gpt-4") | ||
messages = kwargs.get("messages", []) | ||
tools = kwargs.get("tools", []) | ||
response_format = kwargs.get("response_format", None) | ||
|
||
# Simulate different response types based on input | ||
if tools: | ||
# Function calling response | ||
tool_calls = [{ | ||
"id": "call_123", | ||
"type": "function", | ||
"function": { | ||
"name": "get_weather", | ||
"arguments": '{"location": "London", "unit": "celsius"}' | ||
} | ||
}] | ||
message = Message( | ||
role="assistant", | ||
content=None, | ||
tool_calls=tool_calls | ||
) | ||
elif response_format and response_format["type"] == "json_object": | ||
# JSON response | ||
message = Message( | ||
role="assistant", | ||
content='{"colors": ["red", "blue", "green"]}' | ||
) | ||
else: | ||
# Regular text response | ||
message = Message( | ||
role="assistant", | ||
content="This is a mock response" | ||
) | ||
|
||
return Response( | ||
choices=[Choice(message=message)], | ||
model=model | ||
) | ||
|
||
@pytest.fixture | ||
def mock_litellm(): | ||
"""Fixture to provide mock LiteLLM instance""" | ||
return MockLiteLLM() |
Oops, something went wrong.