1
0
mirror of https://github.com/hwchase17/langchain.git synced 2025-05-02 13:55:42 +00:00
langchain/libs/community/langchain_community/chat_models
Bagatur a0c2281540
infra: update mypy 1.10, ruff 0.5 ()
```python
"""python scripts/update_mypy_ruff.py"""
import glob
import tomllib
from pathlib import Path

import toml
import subprocess
import re

ROOT_DIR = Path(__file__).parents[1]


def main():
    for path in glob.glob(str(ROOT_DIR / "libs/**/pyproject.toml"), recursive=True):
        print(path)
        with open(path, "rb") as f:
            pyproject = tomllib.load(f)
        try:
            pyproject["tool"]["poetry"]["group"]["typing"]["dependencies"]["mypy"] = (
                "^1.10"
            )
            pyproject["tool"]["poetry"]["group"]["lint"]["dependencies"]["ruff"] = (
                "^0.5"
            )
        except KeyError:
            continue
        with open(path, "w") as f:
            toml.dump(pyproject, f)
        cwd = "/".join(path.split("/")[:-1])
        completed = subprocess.run(
            "poetry lock --no-update; poetry install --with typing; poetry run mypy . --no-color",
            cwd=cwd,
            shell=True,
            capture_output=True,
            text=True,
        )
        logs = completed.stdout.split("\n")

        to_ignore = {}
        for l in logs:
            if re.match("^(.*)\:(\d+)\: error:.*\[(.*)\]", l):
                path, line_no, error_type = re.match(
                    "^(.*)\:(\d+)\: error:.*\[(.*)\]", l
                ).groups()
                if (path, line_no) in to_ignore:
                    to_ignore[(path, line_no)].append(error_type)
                else:
                    to_ignore[(path, line_no)] = [error_type]
        print(len(to_ignore))
        for (error_path, line_no), error_types in to_ignore.items():
            all_errors = ", ".join(error_types)
            full_path = f"{cwd}/{error_path}"
            try:
                with open(full_path, "r") as f:
                    file_lines = f.readlines()
            except FileNotFoundError:
                continue
            file_lines[int(line_no) - 1] = (
                file_lines[int(line_no) - 1][:-1] + f"  # type: ignore[{all_errors}]\n"
            )
            with open(full_path, "w") as f:
                f.write("".join(file_lines))

        subprocess.run(
            "poetry run ruff format .; poetry run ruff --select I --fix .",
            cwd=cwd,
            shell=True,
            capture_output=True,
            text=True,
        )


if __name__ == "__main__":
    main()

```
2024-07-03 10:33:27 -07:00
..
__init__.py Add OCI Generative AI new model support () 2024-06-24 14:48:23 -04:00
anthropic.py
anyscale.py infra: update mypy 1.10, ruff 0.5 () 2024-07-03 10:33:27 -07:00
azure_openai.py infra: update mypy 1.10, ruff 0.5 () 2024-07-03 10:33:27 -07:00
azureml_endpoint.py infra: rm unused # noqa violations () 2024-05-22 15:21:08 -07:00
baichuan.py feat: Implement ChatBaichuan asynchronous interface () 2024-07-03 12:10:04 -04:00
baidu_qianfan_endpoint.py community[patch]: set tool name for tongyi&qianfan llm () 2024-06-28 09:17:05 -04:00
bedrock.py
cohere.py
coze.py community[patch]: Update root_validators to use pre=True or pre=False () 2024-07-01 20:10:15 +00:00
dappier.py community[patch]: Update root_validators to use pre=True or pre=False () 2024-07-01 20:10:15 +00:00
databricks.py community[patch]: Update documentation string in databricks chat model () 2024-05-20 14:33:57 +00:00
deepinfra.py community[deepinfra]: fix tool call parsing. () 2024-07-03 12:11:37 -04:00
edenai.py community[minor]: Add tools calls to ChatEdenAI () 2024-06-04 10:29:28 -07:00
ernie.py community[patch]: Update root_validators to use pre=True or pre=False () 2024-07-01 20:10:15 +00:00
everlyai.py infra: update mypy 1.10, ruff 0.5 () 2024-07-03 10:33:27 -07:00
fake.py infra: update mypy 1.10, ruff 0.5 () 2024-07-03 10:33:27 -07:00
fireworks.py community[patch]: Update root_validators to use pre=True or pre=False () 2024-07-01 20:10:15 +00:00
friendli.py
gigachat.py community[patch]: upgrade to recent version of mypy () 2024-05-13 14:55:07 -04:00
google_palm.py infra: update mypy 1.10, ruff 0.5 () 2024-07-03 10:33:27 -07:00
gpt_router.py
huggingface.py community[patch]: Update root_validators to use pre=True or pre=False () 2024-07-01 20:10:15 +00:00
human.py
hunyuan.py community[patch]: fix hunyuan message include chinese signature error () () 2024-06-12 12:30:22 -04:00
javelin_ai_gateway.py community[patch]: standardize init args, update for javelin sdk release. () 2024-05-22 21:47:28 +00:00
jinachat.py infra: update mypy 1.10, ruff 0.5 () 2024-07-03 10:33:27 -07:00
kinetica.py
konko.py infra: update mypy 1.10, ruff 0.5 () 2024-07-03 10:33:27 -07:00
litellm_router.py infra: update mypy 1.10, ruff 0.5 () 2024-07-03 10:33:27 -07:00
litellm.py infra: update mypy 1.10, ruff 0.5 () 2024-07-03 10:33:27 -07:00
llama_edge.py community[patch]: upgrade to recent version of mypy () 2024-05-13 14:55:07 -04:00
llamacpp.py openai, anthropic, ...: with_structured_output to pass in explicit tool choice () 2024-06-28 16:39:53 -07:00
maritalk.py community: fix lint () 2024-06-27 22:12:16 +00:00
meta.py
minimax.py community[patch]: Fix MiniMaxChat validate_environment error () 2024-07-02 13:23:32 -04:00
mlflow_ai_gateway.py
mlflow.py community[patch]: Fix ChatDatabricsk in case that streaming response doesn't have role field in delta chunk () 2024-05-22 08:12:53 -07:00
mlx.py
moonshot.py infra: update mypy 1.10, ruff 0.5 () 2024-07-03 10:33:27 -07:00
oci_generative_ai.py infra: update mypy 1.10, ruff 0.5 () 2024-07-03 10:33:27 -07:00
octoai.py infra: update mypy 1.10, ruff 0.5 () 2024-07-03 10:33:27 -07:00
ollama.py Ollama vision support () 2024-06-11 16:10:19 +00:00
openai.py Standardized openai init params () 2024-05-16 16:30:52 +00:00
pai_eas_endpoint.py community[patch]: Update root_validators embeddings: llamacpp, jina, dashscope, mosaicml, huggingface_hub, Toolkits: Connery, ChatModels: PAI_EAS, () 2024-06-12 13:59:05 -04:00
perplexity.py docs: updated PPLX model () 2024-07-02 08:48:49 -04:00
premai.py community[minor]: Prem Templates () 2024-06-13 19:59:28 -07:00
promptlayer_openai.py infra: update mypy 1.10, ruff 0.5 () 2024-07-03 10:33:27 -07:00
snowflake.py community[minor]: add ChatSnowflakeCortex chat model () 2024-06-17 09:47:05 -07:00
solar.py community[patch]: upgrade to recent version of mypy () 2024-05-13 14:55:07 -04:00
sparkllm.py community[patch]: Update root_validators ChatModels: ChatBaichuan, QianfanChatEndpoint, MiniMaxChat, ChatSparkLLM, ChatZhipuAI () 2024-06-20 16:36:41 +00:00
tongyi.py community[patch]: set tool name for tongyi&qianfan llm () 2024-06-28 09:17:05 -04:00
vertexai.py infra: update mypy 1.10, ruff 0.5 () 2024-07-03 10:33:27 -07:00
volcengine_maas.py
yandex.py infra: update mypy 1.10, ruff 0.5 () 2024-07-03 10:33:27 -07:00
yuan2.py infra: update mypy 1.10, ruff 0.5 () 2024-07-03 10:33:27 -07:00
zhipuai.py community[patch]: Invoke callback prior to yielding token () 2024-07-01 18:12:24 +00:00