Skip to content

Commit

Permalink
Merge branch 'release/v1.10' into support-mistral-vision-models
Browse files Browse the repository at this point in the history
  • Loading branch information
willbakst authored Nov 21, 2024
2 parents 3c0476b + 37afeaf commit d6c72c3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
12 changes: 9 additions & 3 deletions docs/learn/async.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,14 @@ __Decorator Parameter:__

{% if provider == "LiteLLM" %}
```python
{% elif provider in ["OpenAI", "Mistral", "Vertex AI"] %}
{% elif provider in ["OpenAI", "Vertex AI"] %}
```python hl_lines="2 5"
{% elif provider == "Azure AI" %}
```python hl_lines="1-2 8-10"
{% elif provider == "Bedrock" %}
```python hl_lines="7-10 14"
{% elif provider == "Mistral" %}
```python hl_lines="4 8"
{% else %}
```python hl_lines="1 5"
{% endif %}
Expand All @@ -198,12 +200,14 @@ __Dynamic Configuration:__

{% if provider == "LiteLLM" %}
```python
{% elif provider in ["OpenAI", "Mistral", "Vertex AI"] %}
{% elif provider in ["OpenAI", "Vertex AI"] %}
```python hl_lines="2 11"
{% elif provider == "Azure AI" %}
```python hl_lines="1-2 12-14"
{% elif provider == "Bedrock" %}
```python hl_lines="5-8 17"
{% elif provider == "Mistral" %}
```python hl_lines="4 15"
{% else %}
```python hl_lines="1 11"
{% endif %}
Expand All @@ -217,12 +221,14 @@ __Dynamic Configuration:__

{% if provider == "LiteLLM" %}
```python
{% elif provider in ["OpenAI", "Mistral", "Vertex AI"] %}
{% elif provider in ["OpenAI", "Vertex AI"] %}
```python hl_lines="2 9"
{% elif provider == "Azure AI" %}
```python hl_lines="1-2 10-12"
{% elif provider == "Bedrock" %}
```python hl_lines="5-8 15"
{% elif provider == "Mistral" %}
```python hl_lines="4 11"
{% else %}
```python hl_lines="1 9"
{% endif %}
Expand Down
8 changes: 7 additions & 1 deletion docs/learn/calls.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,12 +362,14 @@ You can pass a client to the `call` decorator using the `client` parameter:

{% if provider == "LiteLLM" %}
```python
{% elif provider in ["OpenAI", "Mistral", "Vertex AI"] %}
{% elif provider in ["OpenAI", "Vertex AI"] %}
```python hl_lines="2 5"
{% elif provider == "Azure AI" %}
```python hl_lines="1-2 8-10"
{% elif provider == "Bedrock" %}
```python hl_lines="1 6"
{% elif provider == "Mistral" %}
```python hl_lines="4 8"
{% else %}
```python hl_lines="1 5"
{% endif %}
Expand Down Expand Up @@ -395,6 +397,8 @@ You can also configure the client dynamically at runtime through the dynamic con
```python hl_lines="1-2 12-14"
{% elif provider == "Bedrock" %}
```python hl_lines="1 11"
{% elif provider == "Mistral" %}
```python hl_lines="4 13"
{% else %}
```python hl_lines="2 11"
{% endif %}
Expand All @@ -412,6 +416,8 @@ You can also configure the client dynamically at runtime through the dynamic con
```python hl_lines="1-2 10-11"
{% elif provider == "Bedrock" %}
```python hl_lines="1 11"
{% elif provider == "Mistral" %}
```python hl_lines="4 11"
{% else %}
```python hl_lines="2 9"
{% endif %}
Expand Down
4 changes: 3 additions & 1 deletion mirascope/core/base/_utils/_setup_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def setup_call(
convert_common_call_params: ConvertCommonParamsFunc[_BaseCallParamsT],
) -> tuple[
str | None,
Sequence[BaseMessageParam | Any],
list[BaseMessageParam | Any],
list[type[_BaseToolT]] | None,
BaseCallKwargs,
]:
Expand All @@ -50,6 +50,8 @@ def setup_call(
if dynamic_config is not None:
tools = dynamic_config.get("tools", tools)
messages = dynamic_config.get("messages", None)
if messages is not None and not isinstance(messages, list):
messages = list(messages)
dynamic_call_params = dynamic_config.get("call_params", None)
if dynamic_call_params:
call_kwargs |= dynamic_call_params
Expand Down
11 changes: 7 additions & 4 deletions tests/core/base/_utils/test_setup_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from typing import cast

import pytest

from mirascope.core.base import BaseCallParams, CommonCallParams
from mirascope.core.base._utils._setup_call import setup_call
from mirascope.core.base.dynamic_config import BaseDynamicConfig
Expand Down Expand Up @@ -110,15 +112,16 @@ def convert_common_call_params(common_params: CommonCallParams) -> BaseCallParam
}


def test_setup_call_with_custom_messages() -> None:
@pytest.mark.parametrize("messages_type", [list, tuple])
def test_setup_call_with_custom_messages(messages_type) -> None:
"""Tests the `setup_call` function with custom messages."""

custom_messages = [
custom_messages = messages_type(
{
"role": "user",
"content": [{"type": "text", "text": "Recommend a fantasy book."}],
}
]
)
dynamic_config: BaseDynamicConfig = {"messages": custom_messages}

def fn() -> None:
Expand All @@ -138,7 +141,7 @@ def convert_common_call_params(common_params: CommonCallParams) -> BaseCallParam
convert_common_call_params, # pyright: ignore [reportArgumentType]
)
assert template is None
assert custom_messages == messages
assert list(custom_messages) == messages
assert tool_types is None
assert call_kwargs == {}

Expand Down

0 comments on commit d6c72c3

Please sign in to comment.