langchain/libs/community/langchain_community/llms
Bagatur a0c2281540
infra: update mypy 1.10, ruff 0.5 (#23721)
```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
..
grammars
__init__.py community: minor changes sambanova integration (#21231) 2024-05-06 13:28:35 -07:00
ai21.py
aleph_alpha.py community[patch]: upgrade to recent version of mypy (#21616) 2024-05-13 14:55:07 -04:00
amazon_api_gateway.py
anthropic.py (all): update removal in deprecation warnings from 0.2 to 0.3 (#21265) 2024-05-03 14:29:36 -04:00
anyscale.py infra: update mypy 1.10, ruff 0.5 (#23721) 2024-07-03 10:33:27 -07:00
aphrodite.py
arcee.py
aviary.py
azureml_endpoint.py infra: rm unused # noqa violations (#22049) 2024-05-22 15:21:08 -07:00
baichuan.py docs: community docstring updates (#21040) 2024-04-29 17:40:23 -04:00
baidu_qianfan_endpoint.py patch: remove usage of llm, chat model __call__ (#20788) 2024-04-24 19:39:23 -04:00
bananadev.py
baseten.py
beam.py
bedrock.py community[minor]: import fix (#20995) 2024-04-29 10:32:50 -04:00
bigdl_llm.py community[minor]: import fix (#20995) 2024-04-29 10:32:50 -04:00
bittensor.py
cerebriumai.py
chatglm3.py patch: remove usage of llm, chat model __call__ (#20788) 2024-04-24 19:39:23 -04:00
chatglm.py patch: remove usage of llm, chat model __call__ (#20788) 2024-04-24 19:39:23 -04:00
clarifai.py patch: remove usage of llm, chat model __call__ (#20788) 2024-04-24 19:39:23 -04:00
cloudflare_workersai.py
cohere.py (all): update removal in deprecation warnings from 0.2 to 0.3 (#21265) 2024-05-03 14:29:36 -04:00
ctransformers.py patch: remove usage of llm, chat model __call__ (#20788) 2024-04-24 19:39:23 -04:00
ctranslate2.py
databricks.py infra: update mypy 1.10, ruff 0.5 (#23721) 2024-07-03 10:33:27 -07:00
deepinfra.py community[patch]: fix deepinfra inference (#22680) 2024-06-10 13:55:55 -07:00
deepsparse.py patch: remove usage of llm, chat model __call__ (#20788) 2024-04-24 19:39:23 -04:00
edenai.py infra: update mypy 1.10, ruff 0.5 (#23721) 2024-07-03 10:33:27 -07:00
exllamav2.py community[minor]: add exllamav2 library for GPTQ & EXL2 models (#17817) 2024-04-27 00:44:43 +00:00
fake.py
fireworks.py (all): update removal in deprecation warnings from 0.2 to 0.3 (#21265) 2024-05-03 14:29:36 -04:00
forefrontai.py
friendli.py
gigachat.py
google_palm.py
gooseai.py
gpt4all.py patch: remove usage of llm, chat model __call__ (#20788) 2024-04-24 19:39:23 -04:00
gradient_ai.py
huggingface_endpoint.py community: fix huggingface deprecations (#22522) 2024-06-05 04:13:13 +00:00
huggingface_hub.py community: fix huggingface deprecations (#22522) 2024-06-05 04:13:13 +00:00
huggingface_pipeline.py [Community]add option to delete the prompt from HF output (#22225) 2024-06-05 18:38:54 -04:00
huggingface_text_gen_inference.py community: fix huggingface deprecations (#22522) 2024-06-05 04:13:13 +00:00
human.py
ipex_llm.py community[minor]: import fix (#20995) 2024-04-29 10:32:50 -04:00
javelin_ai_gateway.py
koboldai.py patch: remove usage of llm, chat model __call__ (#20788) 2024-04-24 19:39:23 -04:00
konko.py infra: update mypy 1.10, ruff 0.5 (#23721) 2024-07-03 10:33:27 -07:00
layerup_security.py infra: update mypy 1.10, ruff 0.5 (#23721) 2024-07-03 10:33:27 -07:00
llamacpp.py patch: remove usage of llm, chat model __call__ (#20788) 2024-04-24 19:39:23 -04:00
llamafile.py core, openai: support custom token encoders (#20762) 2024-04-23 13:57:05 +00:00
loading.py infra: update mypy 1.10, ruff 0.5 (#23721) 2024-07-03 10:33:27 -07:00
manifest.py
minimax.py infra: update mypy 1.10, ruff 0.5 (#23721) 2024-07-03 10:33:27 -07:00
mlflow_ai_gateway.py
mlflow.py
mlx_pipeline.py community[patch]: Fix MLX LLM Stream (#20575) 2024-05-20 17:17:08 -07:00
modal.py
moonshot.py
mosaicml.py patch: remove usage of llm, chat model __call__ (#20788) 2024-04-24 19:39:23 -04:00
nlpcloud.py
oci_data_science_model_deployment_endpoint.py community[patch]: Add missing type annotations (#22758) 2024-06-10 16:59:28 -04:00
oci_generative_ai.py infra: update mypy 1.10, ruff 0.5 (#23721) 2024-07-03 10:33:27 -07:00
octoai_endpoint.py
ollama.py Update ollama.py with optional raw setting. (#21486) 2024-06-14 17:19:26 -07:00
opaqueprompts.py patch: remove usage of llm, chat model __call__ (#20788) 2024-04-24 19:39:23 -04:00
openai.py infra: rm unused # noqa violations (#22049) 2024-05-22 15:21:08 -07:00
openllm.py infra: update mypy 1.10, ruff 0.5 (#23721) 2024-07-03 10:33:27 -07:00
openlm.py
pai_eas_endpoint.py community[patch]: Invoke callback prior to yielding token (pai_eas_endpoint) (#18627) 2024-03-20 07:56:58 -07:00
petals.py
pipelineai.py
predibase.py community: Support both Predibase SDK-v1 and SDK-v2 in Predibase-LangChain integration (#20859) 2024-04-24 13:31:01 -07:00
predictionguard.py patch: remove usage of llm, chat model __call__ (#20788) 2024-04-24 19:39:23 -04:00
promptlayer_openai.py
replicate.py
rwkv.py infra: update mypy 1.10, ruff 0.5 (#23721) 2024-07-03 10:33:27 -07:00
sagemaker_endpoint.py infra: update mypy 1.10, ruff 0.5 (#23721) 2024-07-03 10:33:27 -07:00
sambanova.py community[patch]: sambanova llm integration improvement (#23137) 2024-06-19 10:30:14 -07:00
self_hosted_hugging_face.py community[minor]: import fix (#20995) 2024-04-29 10:32:50 -04:00
self_hosted.py ci: Add script to check for pickle usage in community (#22863) 2024-06-13 16:13:15 -04:00
solar.py
sparkllm.py community[patch]: upgrade to recent version of mypy (#21616) 2024-05-13 14:55:07 -04:00
stochasticai.py
symblai_nebula.py infra: rm unused # noqa violations (#22049) 2024-05-22 15:21:08 -07:00
textgen.py community[patch]: upgrade to recent version of mypy (#21616) 2024-05-13 14:55:07 -04:00
titan_takeoff.py community[patch]: upgrade to recent version of mypy (#21616) 2024-05-13 14:55:07 -04:00
together.py infra: update mypy 1.10, ruff 0.5 (#23721) 2024-07-03 10:33:27 -07:00
tongyi.py community: Implement bind_tools for ChatTongyi (#20725) 2024-05-16 10:39:35 -04:00
utils.py infra: update mypy 1.10, ruff 0.5 (#23721) 2024-07-03 10:33:27 -07:00
vertexai.py infra: update mypy 1.10, ruff 0.5 (#23721) 2024-07-03 10:33:27 -07:00
vllm.py
volcengine_maas.py
watsonxllm.py (all): update removal in deprecation warnings from 0.2 to 0.3 (#21265) 2024-05-03 14:29:36 -04:00
weight_only_quantization.py community[minor]: import fix (#20995) 2024-04-29 10:32:50 -04:00
writer.py
xinference.py community[patch]: upgrade to recent version of mypy (#21616) 2024-05-13 14:55:07 -04:00
yandex.py infra: update mypy 1.10, ruff 0.5 (#23721) 2024-07-03 10:33:27 -07:00
yuan2.py patch: remove usage of llm, chat model __call__ (#20788) 2024-04-24 19:39:23 -04:00