mirror of
https://github.com/RYDE-WORK/Langchain-Chatchat.git
synced 2026-01-19 21:37:20 +08:00
python3.8兼容
This commit is contained in:
parent
a6e78f219f
commit
d8352eb8e0
@ -1,5 +1,5 @@
|
||||
import logging
|
||||
from collections.abc import Generator
|
||||
from typing import Generator
|
||||
from typing import Dict, List, Optional, Type, Union, cast
|
||||
|
||||
import cohere
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import logging
|
||||
from collections.abc import Generator
|
||||
from typing import Generator
|
||||
from typing import List, Optional, Union, cast
|
||||
from decimal import Decimal
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
from collections.abc import Generator
|
||||
from typing import Generator
|
||||
|
||||
from model_providers.core.model_runtime.entities.llm_entities import (
|
||||
LLMResult,
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
from collections.abc import Generator
|
||||
from typing import Generator
|
||||
from typing import List, Optional, Union
|
||||
|
||||
from model_providers.core.model_runtime.entities.llm_entities import LLMResult
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import logging
|
||||
from collections.abc import Generator
|
||||
from typing import Generator
|
||||
from typing import List, Optional, Union, cast
|
||||
from decimal import Decimal
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import logging
|
||||
from collections.abc import Generator
|
||||
from typing import Generator
|
||||
from typing import List, Optional, Union, cast
|
||||
|
||||
import tiktoken
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import json
|
||||
import logging
|
||||
from collections.abc import Generator
|
||||
from typing import Generator
|
||||
from decimal import Decimal
|
||||
from typing import List, Optional, Union, cast
|
||||
from urllib.parse import urljoin
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
from collections.abc import Generator
|
||||
from typing import Generator
|
||||
from enum import Enum
|
||||
from json import dumps, loads
|
||||
from typing import Any, Union
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import threading
|
||||
from collections.abc import Generator
|
||||
from typing import Generator
|
||||
from typing import Dict, List, Optional, Type, Union
|
||||
|
||||
from model_providers.core.model_runtime.entities.llm_entities import (
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
from collections.abc import Generator
|
||||
from typing import Generator
|
||||
from typing import List, Optional, Union
|
||||
|
||||
from model_providers.core.model_runtime.entities.llm_entities import LLMResult
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
from collections.abc import Generator
|
||||
from typing import Generator
|
||||
from typing import Dict, List, Optional, Type, Union
|
||||
|
||||
from dashscope import get_tokenizer
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
from collections.abc import Generator, Iterator
|
||||
from typing import Generator, Iterator
|
||||
|
||||
from typing import Dict, List, Union, cast, Type
|
||||
|
||||
from openai import (
|
||||
@ -464,7 +465,7 @@ class XinferenceAILargeLanguageModel(LargeLanguageModel):
|
||||
]
|
||||
|
||||
if isinstance(
|
||||
xinference_model, RESTfulChatModelHandle | RESTfulChatglmCppChatModelHandle
|
||||
xinference_model, (RESTfulChatModelHandle, RESTfulChatglmCppChatModelHandle)
|
||||
):
|
||||
resp = client.chat.completions.create(
|
||||
model=credentials["model_uid"],
|
||||
|
||||
@ -15,7 +15,7 @@ from ipaddress import (
|
||||
from pathlib import Path, PurePath
|
||||
from re import Pattern
|
||||
from types import GeneratorType
|
||||
from typing import Any, Optional, Union
|
||||
from typing import Any, Optional, Union, Dict, Type, List, Tuple
|
||||
from uuid import UUID
|
||||
|
||||
from pydantic import BaseModel
|
||||
@ -54,7 +54,7 @@ def decimal_encoder(dec_value: Decimal) -> Union[int, float]:
|
||||
return float(dec_value)
|
||||
|
||||
|
||||
ENCODERS_BY_TYPE: Dict[type[Any], Callable[[Any], Any]] = {
|
||||
ENCODERS_BY_TYPE: Dict[Type[Any], Callable[[Any], Any]] = {
|
||||
bytes: lambda o: o.decode(),
|
||||
Color: str,
|
||||
datetime.date: isoformat,
|
||||
@ -86,8 +86,8 @@ ENCODERS_BY_TYPE: Dict[type[Any], Callable[[Any], Any]] = {
|
||||
|
||||
def generate_encoders_by_class_tuples(
|
||||
type_encoder_map: Dict[Any, Callable[[Any], Any]],
|
||||
) -> Dict[Callable[[Any], Any], tuple[Any, ...]]:
|
||||
encoders_by_class_tuples: Dict[Callable[[Any], Any], tuple[Any, ...]] = defaultdict(
|
||||
) -> Dict[Callable[[Any], Any], Tuple[Any, ...]]:
|
||||
encoders_by_class_tuples: Dict[Callable[[Any], Any], Tuple[Any, ...]] = defaultdict(
|
||||
tuple
|
||||
)
|
||||
for type_, encoder in type_encoder_map.items():
|
||||
@ -104,7 +104,7 @@ def jsonable_encoder(
|
||||
exclude_unset: bool = False,
|
||||
exclude_defaults: bool = False,
|
||||
exclude_none: bool = False,
|
||||
custom_encoder: Optional[dict[Any, Callable[[Any], Any]]] = None,
|
||||
custom_encoder: Optional[Dict[Any, Callable[[Any], Any]]] = None,
|
||||
sqlalchemy_safe: bool = True,
|
||||
) -> Any:
|
||||
custom_encoder = custom_encoder or {}
|
||||
@ -192,7 +192,7 @@ def jsonable_encoder(
|
||||
)
|
||||
encoded_dict[encoded_key] = encoded_value
|
||||
return encoded_dict
|
||||
if isinstance(obj, list | set | frozenset | GeneratorType | tuple | deque):
|
||||
if isinstance(obj, (list, set, frozenset, GeneratorType, tuple, deque)):
|
||||
encoded_list = []
|
||||
for item in obj:
|
||||
encoded_list.append(
|
||||
@ -217,8 +217,7 @@ def jsonable_encoder(
|
||||
try:
|
||||
data = dict(obj)
|
||||
except Exception as e:
|
||||
errors: List[Exception] = []
|
||||
errors.append(e)
|
||||
errors: List[Exception] = [e]
|
||||
try:
|
||||
data = vars(obj)
|
||||
except Exception as e:
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import os
|
||||
import shutil
|
||||
from collections.abc import Generator
|
||||
from typing import Generator
|
||||
from contextlib import closing
|
||||
from typing import Union
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user