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
13 changes: 8 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ repos:
files: ^ui/.*\.(ts|tsx|js|jsx)$
pass_filenames: false

# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v1.17.1
# hooks:
# - id: mypy
# additional_dependencies: [types-PyYAML, pydantic>=2.11.5]
- repo: local
hooks:
- id: ty
name: ty check
entry: ty check qtype --ignore unresolved-import
language: python
pass_filenames: false
files: ^qtype/.*\.py$
124 changes: 99 additions & 25 deletions common/aws.bedrock.models.qtype.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,108 @@
- id: nvidia.nemotron-nano-12b-v2
provider: aws-bedrock
- id: anthropic.claude-sonnet-4-20250514-v1:0
provider: aws-bedrock
- id: anthropic.claude-haiku-4-5-20251001-v1:0
provider: aws-bedrock
- id: openai.gpt-oss-120b-1:0
provider: aws-bedrock
- id: stability.stable-creative-upscale-v1:0
provider: aws-bedrock
- id: qwen.qwen3-next-80b-a3b
provider: aws-bedrock
- id: amazon.nova-2-multimodal-embeddings-v1:0
provider: aws-bedrock
- id: nvidia.nemotron-nano-3-30b
provider: aws-bedrock
- id: minimax.minimax-m2
provider: aws-bedrock
- id: mistral.voxtral-mini-3b-2507
provider: aws-bedrock
- id: amazon.nova-pro-v1:0
provider: aws-bedrock
- id: stability.stable-image-remove-background-v1:0
provider: aws-bedrock
- id: stability.stable-image-control-sketch-v1:0
provider: aws-bedrock
- id: amazon.nova-2-lite-v1:0
provider: aws-bedrock
- id: amazon.nova-2-lite-v1:0:256k
provider: aws-bedrock
- id: stability.stable-conservative-upscale-v1:0
provider: aws-bedrock
- id: google.gemma-3-12b-it
provider: aws-bedrock
- id: stability.stable-image-search-recolor-v1:0
provider: aws-bedrock
- id: moonshot.kimi-k2-thinking
provider: aws-bedrock
- id: mistral.mistral-large-3-675b-instruct
provider: aws-bedrock
- id: twelvelabs.pegasus-1-2-v1:0
provider: aws-bedrock
- id: amazon.nova-2-sonic-v1:0
provider: aws-bedrock
- id: qwen.qwen3-32b-v1:0
provider: aws-bedrock
- id: mistral.ministral-3-14b-instruct
provider: aws-bedrock
- id: writer.palmyra-x5-v1:0
provider: aws-bedrock
- id: nvidia.nemotron-nano-9b-v2
provider: aws-bedrock
- id: mistral.ministral-3-8b-instruct
provider: aws-bedrock
- id: mistral.voxtral-small-24b-2507
provider: aws-bedrock
- id: openai.gpt-oss-20b-1:0
provider: aws-bedrock
- id: google.gemma-3-4b-it
provider: aws-bedrock
- id: stability.stable-fast-upscale-v1:0
provider: aws-bedrock
- id: stability.stable-image-erase-object-v1:0
provider: aws-bedrock
- id: openai.gpt-oss-safeguard-120b
provider: aws-bedrock
- id: google.gemma-3-27b-it
provider: aws-bedrock
- id: stability.stable-image-control-structure-v1:0
provider: aws-bedrock
- id: twelvelabs.marengo-embed-3-0-v1:0
provider: aws-bedrock
- id: writer.palmyra-x4-v1:0
provider: aws-bedrock
- id: anthropic.claude-sonnet-4-5-20250929-v1:0
provider: aws-bedrock
- id: twelvelabs.marengo-embed-2-7-v1:0
provider: aws-bedrock
- id: qwen.qwen3-vl-235b-a22b
provider: aws-bedrock
- id: stability.stable-outpaint-v1:0
provider: aws-bedrock
- id: stability.stable-image-inpaint-v1:0
provider: aws-bedrock
- id: anthropic.claude-opus-4-1-20250805-v1:0
provider: aws-bedrock
- id: amazon.titan-tg1-large
- id: stability.stable-image-style-guide-v1:0
provider: aws-bedrock
- id: mistral.magistral-small-2509
provider: aws-bedrock
- id: stability.stable-style-transfer-v1:0
provider: aws-bedrock
- id: cohere.embed-v4:0
provider: aws-bedrock
- id: mistral.ministral-3-3b-instruct
provider: aws-bedrock
- id: anthropic.claude-opus-4-5-20251101-v1:0
provider: aws-bedrock
- id: stability.stable-image-search-replace-v1:0
provider: aws-bedrock
- id: amazon.titan-image-generator-v1:0
- id: qwen.qwen3-coder-30b-a3b-v1:0
provider: aws-bedrock
- id: amazon.titan-image-generator-v1
- id: openai.gpt-oss-safeguard-20b
provider: aws-bedrock
- id: amazon.titan-tg1-large
provider: aws-bedrock
- id: amazon.titan-image-generator-v2:0
provider: aws-bedrock
Expand All @@ -22,14 +116,10 @@
provider: aws-bedrock
- id: amazon.nova-premier-v1:0
provider: aws-bedrock
- id: amazon.titan-text-premier-v1:0
provider: aws-bedrock
- id: amazon.nova-pro-v1:0:24k
provider: aws-bedrock
- id: amazon.nova-pro-v1:0:300k
provider: aws-bedrock
- id: amazon.nova-pro-v1:0
provider: aws-bedrock
- id: amazon.nova-lite-v1:0:24k
provider: aws-bedrock
- id: amazon.nova-lite-v1:0:300k
Expand All @@ -52,10 +142,6 @@
provider: aws-bedrock
- id: amazon.titan-embed-g1-text-02
provider: aws-bedrock
- id: amazon.titan-text-lite-v1:0:4k
provider: aws-bedrock
- id: amazon.titan-text-lite-v1
provider: aws-bedrock
- id: amazon.titan-text-express-v1:0:8k
provider: aws-bedrock
- id: amazon.titan-text-express-v1
Expand All @@ -72,20 +158,12 @@
provider: aws-bedrock
- id: amazon.titan-embed-image-v1
provider: aws-bedrock
- id: stability.stable-diffusion-xl-v1:0
provider: aws-bedrock
- id: stability.stable-diffusion-xl-v1
provider: aws-bedrock
- id: ai21.jamba-instruct-v1:0
provider: aws-bedrock
- id: ai21.jamba-1-5-large-v1:0
provider: aws-bedrock
- id: ai21.jamba-1-5-mini-v1:0
provider: aws-bedrock
- id: anthropic.claude-instant-v1:2:100k
provider: aws-bedrock
- id: anthropic.claude-instant-v1
provider: aws-bedrock
- id: anthropic.claude-v2:0:18k
provider: aws-bedrock
- id: anthropic.claude-v2:0:100k
Expand All @@ -94,10 +172,6 @@
provider: aws-bedrock
- id: anthropic.claude-v2:1:200k
provider: aws-bedrock
- id: anthropic.claude-v2:1
provider: aws-bedrock
- id: anthropic.claude-v2
provider: aws-bedrock
- id: anthropic.claude-3-sonnet-20240229-v1:0:28k
provider: aws-bedrock
- id: anthropic.claude-3-sonnet-20240229-v1:0:200k
Expand Down Expand Up @@ -140,6 +214,8 @@
provider: aws-bedrock
- id: cohere.embed-multilingual-v3
provider: aws-bedrock
- id: cohere.rerank-v3-5:0
provider: aws-bedrock
- id: deepseek.r1-v1:0
provider: aws-bedrock
- id: meta.llama3-8b-instruct-v1:0
Expand Down Expand Up @@ -174,5 +250,3 @@
provider: aws-bedrock
- id: mistral.pixtral-large-2502-v1:0
provider: aws-bedrock
- id: twelvelabs.marengo-embed-2-7-v1:0
provider: aws-bedrock
29 changes: 8 additions & 21 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ dev = [
"mkdocs>=1.6.1",
"mkdocstrings-python>=1.16.12",
"mkdocstrings>=0.30.0",
"mypy>=1.8.0",
"networkx>=3.4.2",
"pandas-stubs>=2.3.2.250827",
"pkginfo>=1.12.1.2",
Expand All @@ -86,6 +85,7 @@ dev = [
"types-networkx>=3.5.0.20250901",
"types-PyYAML>=6.0.2",
"types-requests>=2.32.4.20250809",
"ty>=0.0.8",
]
docs = [
"mkdocs>=1.5.0",
Expand Down Expand Up @@ -134,26 +134,13 @@ force_grid_wrap = 0
use_parentheses = true
ensure_newline_before_comments = true

[tool.mypy]
python_version = "3.10"
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = true
explicit_package_bases = true
plugins = ["pydantic.mypy"]

[[tool.mypy.overrides]]
module = "tests.*"
disallow_untyped_defs = false

[[tool.mypy.overrides]]
module = "qtype.semantic.model"
ignore_errors = true

[tool.pydantic-mypy]
init_forbid_extra = true
init_typed = true
warn_required_dynamic_aliases = true
# Note: ty will show references to .venv in error contexts when reporting
# type issues with imported external libraries. This is expected behavior.
[tool.ty.environment]
root = ["."]

[tool.ty.src]
include = ["qtype/**"]

[tool.coverage.run]
source = ["qtype"]
Expand Down
6 changes: 5 additions & 1 deletion qtype/commands/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ def run_dump_commons_library(args: argparse.Namespace) -> None:
)

# Convert to YAML and save
content = facade.convert_document(model_list)
from pydantic_yaml import to_yaml_str

content = to_yaml_str(
model_list, exclude_none=True, exclude_unset=True
)
output_path = Path(f"{args.prefix}/aws.bedrock.models.qtype.yaml")
output_path.write_text(content, encoding="utf-8")
logger.info(f"AWS Bedrock models exported to {output_path}")
Expand Down
3 changes: 2 additions & 1 deletion qtype/dsl/custom_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ def _parse_type_string(type_str: str) -> tuple[Any, bool]:
resolved_type = ForwardRef(type_str)

if is_optional:
return Union[resolved_type, None], True
# Type checker: resolved_type is runtime-constructed type
return Union[resolved_type, None], True # type: ignore[valid-type]

return resolved_type, False

Expand Down
7 changes: 4 additions & 3 deletions qtype/dsl/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,10 @@ def _serialize_type(value):
@model_serializer
def _model_serializer(self):
# Use the default serialization, but ensure 'type' is a string
data = self.model_dump()
data["type"] = self._serialize_type(data.get("type"))
return data
return {
"type": self._serialize_type(self.type),
"optional": self.optional,
}


class ListType(BaseModel):
Expand Down
5 changes: 4 additions & 1 deletion qtype/interpreter/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import asyncio
from contextlib import asynccontextmanager
from pathlib import Path
from typing import Any

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
Expand Down Expand Up @@ -86,8 +87,10 @@ async def shutdown_telemetry():
if ui_enabled:
# Add CORS middleware only for localhost development
if self.host in ("localhost", "127.0.0.1", "0.0.0.0"):
from typing import cast

app.add_middleware(
CORSMiddleware,
cast(Any, CORSMiddleware),
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
Expand Down
4 changes: 3 additions & 1 deletion qtype/interpreter/base/base_step_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,9 @@ async def _process_message_with_cache(
):
serialized = [to_cache_value(m, self.step) for m in buf]
self.cache.set(
key, serialized, expire=self.step.cache_config.ttl
key,
serialized,
expire=self.step.cache_config.ttl, # type: ignore[union-attr]
) # type: ignore

async def _process_message_with_telemetry(
Expand Down
10 changes: 7 additions & 3 deletions qtype/interpreter/conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def to_embedding_model(
OpenAIEmbedding,
)

api_key = None
api_key: str | None = None
if model.auth:
with auth(model.auth, secret_manager) as provider:
if not isinstance(provider, APIKeyAuthProvider):
Expand All @@ -343,7 +343,7 @@ def to_embedding_model(
api_key = provider.api_key # type: ignore[assignment]

openai_embedding: BaseEmbedding = OpenAIEmbedding(
api_key=api_key,
api_key=api_key, # type: ignore[arg-type]
model_name=model.model_id if model.model_id else model.id,
)
return openai_embedding
Expand Down Expand Up @@ -523,7 +523,11 @@ def from_chat_message(message: LlamaChatMessage) -> ChatMessage:
f"Unsupported content block type: {type(block)}"
)

return ChatMessage(role=message.role, blocks=blocks)
# Convert llama_index MessageRole to our MessageRole
from qtype.dsl.domain_types import MessageRole as QTypeMessageRole

role = QTypeMessageRole(message.role.value)
return ChatMessage(role=role, blocks=blocks)


def to_text_splitter(splitter: DocumentSplitter) -> Any:
Expand Down
2 changes: 1 addition & 1 deletion qtype/interpreter/executors/construct_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async def process_message(
}
# use the mapping to convert variable names to
inputs = {
self.step.field_mapping.get(var_name, var_name): value
self.step.field_mapping.get(var_name, var_name): value # type: ignore[attr-defined]
for var_name, value in input_values.items()
}
else:
Expand Down
6 changes: 3 additions & 3 deletions qtype/interpreter/executors/file_source_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ async def process_message(
output_columns = {output.id for output in self.step.outputs}

# get the path
if isinstance(self.step.path, ConstantPath):
file_path = self.step.path
if isinstance(self.step.path, ConstantPath): # type: ignore[attr-defined]
file_path = self.step.path # type: ignore[attr-defined]
else:
file_path = message.variables.get(self.step.path.id)
file_path = message.variables.get(self.step.path.id) # type: ignore[attr-defined]
if not file_path:
raise ValueError(
(
Expand Down
Loading