Skip to content

Commit 0ec49e3

Browse files
committed
mypy fixes
1 parent 25a26c2 commit 0ec49e3

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

.github/workflows/app-tests.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ jobs:
8080
cd ./src/frontend
8181
npm install
8282
npm run build
83+
- name: cache mypy
84+
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
85+
with:
86+
path: ./.mypy_cache
87+
key: mypy${{ matrix.os }}-${{ matrix.python_version }}-${{ hashFiles('requirements-dev.txt', 'src/backend/requirements.txt', 'src/backend/pyproject.toml') }}
8388
- name: Run MyPy
8489
run: python3 -m mypy .
8590
- name: Run Pytest

evals/evaluate.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import logging
22
import os
33
from pathlib import Path
4+
from typing import Any
45

56
import azure.identity
6-
from azure.ai.evaluation import AzureOpenAIModelConfiguration, OpenAIModelConfiguration
77
from dotenv import load_dotenv
88
from evaltools.eval.evaluate import run_evaluate_from_config
99
from rich.logging import RichHandler
@@ -12,12 +12,13 @@
1212

1313

1414
def get_openai_config() -> dict:
15+
openai_config: dict[str, Any]
1516
if os.environ.get("OPENAI_CHAT_HOST") == "azure":
1617
azure_endpoint = os.environ["AZURE_OPENAI_ENDPOINT"]
17-
azure_deployment = os.environ.get("AZURE_OPENAI_EVAL_DEPLOYMENT")
18+
azure_deployment = os.environ["AZURE_OPENAI_EVAL_DEPLOYMENT"]
1819
if os.environ.get("AZURE_OPENAI_KEY"):
1920
logger.info("Using Azure OpenAI Service with API Key from AZURE_OPENAI_KEY")
20-
openai_config: AzureOpenAIModelConfiguration = {
21+
openai_config = {
2122
"azure_endpoint": azure_endpoint,
2223
"azure_deployment": azure_deployment,
2324
"api_key": os.environ["AZURE_OPENAI_KEY"],
@@ -29,7 +30,7 @@ def get_openai_config() -> dict:
2930
else:
3031
logger.info("Authenticating to Azure using Azure Developer CLI Credential")
3132
azure_credential = azure.identity.AzureDeveloperCliCredential(process_timeout=60)
32-
openai_config: AzureOpenAIModelConfiguration = {
33+
openai_config = {
3334
"azure_endpoint": azure_endpoint,
3435
"azure_deployment": azure_deployment,
3536
"credential": azure_credential,
@@ -39,7 +40,7 @@ def get_openai_config() -> dict:
3940
openai_config["model"] = os.environ["AZURE_OPENAI_EVAL_MODEL"]
4041
else:
4142
logger.info("Using OpenAI Service with API Key from OPENAICOM_KEY")
42-
openai_config: OpenAIModelConfiguration = {"api_key": os.environ["OPENAICOM_KEY"], "model": "gpt-4"}
43+
openai_config = {"api_key": os.environ["OPENAICOM_KEY"], "model": "gpt-4"}
4344
return openai_config
4445

4546

evals/generate_ground_truth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def source_retriever() -> Generator[dict, None, None]:
3333
# "content": "\n\n".join([record.to_str_for_rag() for record in records]),
3434
# }
3535
# Fetch each item individually
36-
records = session.scalars(select(Item).order_by(Item.id))
36+
records = list(session.scalars(select(Item).order_by(Item.id)))
3737
for record in records:
3838
logger.info(f"Processing database record: {record.name}")
3939
yield {"id": record.id, "content": record.to_str_for_rag()}

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ filterwarnings = ["ignore::DeprecationWarning"]
1919
[[tool.mypy.overrides]]
2020
module = [
2121
"pgvector.*",
22+
"evaltools.*"
2223
]
2324
ignore_missing_imports = true
2425

0 commit comments

Comments
 (0)