Repository: Mirascope/mirascope

Issue:
response_model causes error in llm.call
### Description

When I add a `response_model` with or without `json_mode` I get this error:

`Unsupported result type: <class 'BookRecommendation'>`

Using this code:

```
from mirascope import llm
from pydantic import BaseModel

class BookRecommendation(BaseModel):
    title: str
    author: str
    genre: str

@llm.call(provider="anthropic", model="claude-3-5-sonnet-20240620", json_mode=True, response_model=BookRecommendation)
async def recommend_book(genre: str) -> str:
    return f"Recommend a {genre} book."
```

### Python, Mirascope & OS Versions, related packages (not required)

```TOML

```

Hints from issue comments:
@willbakst: fix released in `v1.16.3`!

Solution patch:
diff --git a/mirascope/llm/llm_call.py b/mirascope/llm/llm_call.py
index 65afe738..ddcfa247 100644
--- a/mirascope/llm/llm_call.py
+++ b/mirascope/llm/llm_call.py
@@ -49,7 +49,7 @@ _BaseCallResponseChunkT = TypeVar(
     "_BaseCallResponseChunkT", covariant=True, bound=BaseCallResponseChunk
 )
 _BaseStreamT = TypeVar("_BaseStreamT", covariant=True)
-_BaseToolT = TypeVar("_BaseToolT", bound=BaseTool)
+_ResultT = TypeVar("_ResultT")
 
 
 def _get_provider_call(provider: str) -> Callable:
@@ -97,7 +97,9 @@ def _get_provider_call(provider: str) -> Callable:
     raise ValueError(f"Unsupported provider: {provider}")
 
 
-def _wrap_result(result: BaseCallResponse | BaseStream) -> CallResponse | Stream:
+def _wrap_result(
+    result: BaseCallResponse | BaseStream | _ResultT,
+) -> CallResponse | Stream | _ResultT:
     """Wraps the result into a CallResponse or Stream instance.
 
     Args:
@@ -115,7 +117,7 @@ def _wrap_result(result: BaseCallResponse | BaseStream) -> CallResponse | Stream
     elif isinstance(result, BaseStream):
         return Stream(stream=result)  # type: ignore
     else:
-        raise ValueError(f"Unsupported result type: {type(result)}")
+        return result
 
 
 def _call(
diff --git a/pyproject.toml b/pyproject.toml
index 5c13e25f..51e0e124 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
 [project]
 name = "mirascope"
-version = "1.16.2"
+version = "1.16.3"
 description = "LLM abstractions that aren't obstructions"
 readme = "README.md"
 license = { file = "LICENSE" }


Test patch:
diff --git a/tests/llm/test_call.py b/tests/llm/test_call.py
index 59e442b9..57c03553 100644
--- a/tests/llm/test_call.py
+++ b/tests/llm/test_call.py
@@ -92,7 +92,7 @@ class ConcreteStream(BaseStream):
     def cost(self): ...
 
 
-def test_wrap_result_with_concrete_response_and_stream():
+def test_wrap_result():
     resp = ConcreteResponse(
         metadata=Metadata(),
         response={},
@@ -127,10 +127,9 @@ def test_wrap_result_with_concrete_response_and_stream():
     result_stream = _wrap_result(strm)
     assert isinstance(result_stream, Stream)
 
-
-def test_wrap_result_unsupported_type():
-    with pytest.raises(ValueError, match="Unsupported result type: <class 'int'>"):
-        _wrap_result(42)  # pyright: ignore [reportGeneralTypeIssues, reportArgumentType]
+    output = _wrap_result("parsed output")
+    assert isinstance(output, str)
+    assert output == "parsed output"
 
 
 def test_get_provider_call_unsupported():
@@ -288,33 +287,3 @@ async def test_call_decorator_async():
         res = await dummy_async_function()
         assert isinstance(res, CallResponse)
         assert res.finish_reasons == ["stop"]
-
-
-def test_call_unsupported_result_type():
-    def dummy_str_call(
-        model,
-        stream,
-        tools,
-        response_model,
-        output_parser,
-        json_mode,
-        call_params,
-        client,
-    ):
-        def wrapper(fn):
-            def inner(*args, **kwargs):
-                return "not a supported result"
-
-            return inner
-
-        return wrapper
-
-    with patch(
-        "mirascope.llm.llm_call._get_provider_call", return_value=dummy_str_call
-    ):
-
-        @call(provider="openai", model="gpt-4o-mini")
-        def dummy_function_str(): ...
-
-        with pytest.raises(ValueError, match="Unsupported result type: <class 'str'>"):
-            dummy_function_str()