Skip to content

Commit

Permalink
AzureAI: Use Model Inference API (preview) for implementation of mode…
Browse files Browse the repository at this point in the history
…l client (#807)

* add azure-ai-inference to dev dependencies

* remove self-signed workaround

* initial work on azure inference api

* remove unused

* initial azureai tests

* use tool calling fallback for llama on azureai

* remove unused imports

* playback tool calls to model

* prevent azure logging

* update changelog

* increase context window; handle bad request errors

* tag as content_filter

---------

Co-authored-by: aisi-inspect <[email protected]>
  • Loading branch information
jjallaire-aisi and aisi-inspect authored Nov 5, 2024
1 parent a02829b commit 9dae6c5
Show file tree
Hide file tree
Showing 10 changed files with 303 additions and 182 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased

- AzureAI: Use Model Inference API (preview) for implementation of model client.
- Fix issue with correctly logging task_args for eval-set tasks which are interrupted.
- Move `INSPECT_DISABLE_MODEL_API` into `generate()` (as opposed to `get_model()`)
- Always treat `.eval` files as logs (don't apply file name pattern restrictions as we do with `.json`).
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ inspect = "inspect_ai._cli.main:main"
dev = [
"anthropic",
"aioboto3",
"azure-ai-inference",
"google-cloud-aiplatform",
"google-generativeai",
"groq",
Expand Down
6 changes: 5 additions & 1 deletion src/inspect_ai/_display/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ def __init__(self, levelno: int, transcript_levelno: int) -> None:
@override
def emit(self, record: LogRecord) -> None:
# demote httpx and return notifications to log_level http
if record.name == "httpx" or "Retrying request" in record.getMessage():
if (
record.name == "httpx"
or "http" in record.name
or "Retrying request" in record.getMessage()
):
record.levelno = HTTP
record.levelname = HTTP_LOG_LEVEL

Expand Down
3 changes: 1 addition & 2 deletions src/inspect_ai/_util/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ class ContentImage(BaseModel):
detail: Literal["auto", "low", "high"] = Field(default="auto")
"""Specifies the detail level of the image.
Currently only supported for OpenAI. Learn more in the
[Vision guide](https://platform.openai.com/docs/guides/vision/low-or-high-fidelity-image-understanding).
Currently only supported for OpenAI. Learn more in the [Vision guide](https://platform.openai.com/docs/guides/vision/low-or-high-fidelity-image-understanding).
"""


Expand Down
15 changes: 15 additions & 0 deletions src/inspect_ai/model/_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from copy import copy

from pydantic import JsonValue

from inspect_ai._util.constants import BASE_64_DATA_REMOVED


def image_url_filter(key: JsonValue | None, value: JsonValue) -> JsonValue:
# remove images from raw api call
if key == "image_url" and isinstance(value, dict) and "url" in value:
url = str(value.get("url"))
if url.startswith("data:"):
value = copy(value)
value.update(url=BASE_64_DATA_REMOVED)
return value
Loading

0 comments on commit 9dae6c5

Please sign in to comment.