Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions asknews_sdk/api/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
]
DeepNewsModel = Literal[
"gpt-5",
"gpt-6-astra",
"claude-3-7-sonnet-latest",
"deepseek",
"deepseek-basic",
Expand Down
40 changes: 40 additions & 0 deletions tests/api/test_chat_model_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import json
from inspect import getmembers, isclass
from typing import get_args, get_type_hints

import pytest
from pydantic import BaseModel

from asknews_sdk.api.chat import AsyncChatAPI, ChatAPI, ChatModel, DeepNewsModel
from asknews_sdk.dto import alert as alert_dto


GPT_6_ASTRA = "gpt-6-astra"


def test_gpt_6_astra_is_a_direct_deepnews_model_only():
assert GPT_6_ASTRA in get_args(DeepNewsModel)
assert GPT_6_ASTRA not in get_args(ChatModel)


@pytest.mark.parametrize("api_type", [ChatAPI, AsyncChatAPI])
def test_gpt_6_astra_is_scoped_to_get_deep_news(api_type):
deepnews_model = get_type_hints(api_type.get_deep_news)["model"]
forecast_model = get_type_hints(api_type.get_forecast)["model"]

assert GPT_6_ASTRA in get_args(deepnews_model)
assert GPT_6_ASTRA not in get_args(forecast_model)


def test_gpt_6_astra_is_absent_from_alert_model_contracts():
alert_model_types = (
alert_dto.DeepNewsModel,
alert_dto.CheckAlertModel,
alert_dto.AlertReportModel,
)
for model_type in alert_model_types:
assert GPT_6_ASTRA not in get_args(model_type)

for name, model in getmembers(alert_dto, isclass):
if model.__module__ == alert_dto.__name__ and issubclass(model, BaseModel):
assert GPT_6_ASTRA not in json.dumps(model.model_json_schema()), name
Loading