Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -15,7 +15,7 @@ from openai import (
|
|||||||
AsyncOpenAI,
|
AsyncOpenAI,
|
||||||
APIConnectionError,
|
APIConnectionError,
|
||||||
RateLimitError,
|
RateLimitError,
|
||||||
Timeout,
|
APITimeoutError,
|
||||||
AsyncAzureOpenAI,
|
AsyncAzureOpenAI,
|
||||||
)
|
)
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
@@ -47,7 +47,9 @@ os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
|||||||
@retry(
|
@retry(
|
||||||
stop=stop_after_attempt(3),
|
stop=stop_after_attempt(3),
|
||||||
wait=wait_exponential(multiplier=1, min=4, max=10),
|
wait=wait_exponential(multiplier=1, min=4, max=10),
|
||||||
retry=retry_if_exception_type((RateLimitError, APIConnectionError, Timeout)),
|
retry=retry_if_exception_type(
|
||||||
|
(RateLimitError, APIConnectionError, APITimeoutError)
|
||||||
|
),
|
||||||
)
|
)
|
||||||
async def openai_complete_if_cache(
|
async def openai_complete_if_cache(
|
||||||
model,
|
model,
|
||||||
@@ -108,7 +110,9 @@ async def openai_complete_if_cache(
|
|||||||
@retry(
|
@retry(
|
||||||
stop=stop_after_attempt(3),
|
stop=stop_after_attempt(3),
|
||||||
wait=wait_exponential(multiplier=1, min=4, max=10),
|
wait=wait_exponential(multiplier=1, min=4, max=10),
|
||||||
retry=retry_if_exception_type((RateLimitError, APIConnectionError, Timeout)),
|
retry=retry_if_exception_type(
|
||||||
|
(RateLimitError, APIConnectionError, APIConnectionError)
|
||||||
|
),
|
||||||
)
|
)
|
||||||
async def azure_openai_complete_if_cache(
|
async def azure_openai_complete_if_cache(
|
||||||
model,
|
model,
|
||||||
@@ -259,7 +263,9 @@ def initialize_hf_model(model_name):
|
|||||||
@retry(
|
@retry(
|
||||||
stop=stop_after_attempt(3),
|
stop=stop_after_attempt(3),
|
||||||
wait=wait_exponential(multiplier=1, min=4, max=10),
|
wait=wait_exponential(multiplier=1, min=4, max=10),
|
||||||
retry=retry_if_exception_type((RateLimitError, APIConnectionError, Timeout)),
|
retry=retry_if_exception_type(
|
||||||
|
(RateLimitError, APIConnectionError, APITimeoutError)
|
||||||
|
),
|
||||||
)
|
)
|
||||||
async def hf_model_if_cache(
|
async def hf_model_if_cache(
|
||||||
model,
|
model,
|
||||||
@@ -326,7 +332,9 @@ async def hf_model_if_cache(
|
|||||||
@retry(
|
@retry(
|
||||||
stop=stop_after_attempt(3),
|
stop=stop_after_attempt(3),
|
||||||
wait=wait_exponential(multiplier=1, min=4, max=10),
|
wait=wait_exponential(multiplier=1, min=4, max=10),
|
||||||
retry=retry_if_exception_type((RateLimitError, APIConnectionError, Timeout)),
|
retry=retry_if_exception_type(
|
||||||
|
(RateLimitError, APIConnectionError, APITimeoutError)
|
||||||
|
),
|
||||||
)
|
)
|
||||||
async def ollama_model_if_cache(
|
async def ollama_model_if_cache(
|
||||||
model,
|
model,
|
||||||
@@ -444,7 +452,9 @@ def initialize_lmdeploy_pipeline(
|
|||||||
@retry(
|
@retry(
|
||||||
stop=stop_after_attempt(3),
|
stop=stop_after_attempt(3),
|
||||||
wait=wait_exponential(multiplier=1, min=4, max=10),
|
wait=wait_exponential(multiplier=1, min=4, max=10),
|
||||||
retry=retry_if_exception_type((RateLimitError, APIConnectionError, Timeout)),
|
retry=retry_if_exception_type(
|
||||||
|
(RateLimitError, APIConnectionError, APITimeoutError)
|
||||||
|
),
|
||||||
)
|
)
|
||||||
async def lmdeploy_model_if_cache(
|
async def lmdeploy_model_if_cache(
|
||||||
model,
|
model,
|
||||||
@@ -704,7 +714,9 @@ async def lollms_model_complete(
|
|||||||
@retry(
|
@retry(
|
||||||
stop=stop_after_attempt(3),
|
stop=stop_after_attempt(3),
|
||||||
wait=wait_exponential(multiplier=1, min=4, max=10),
|
wait=wait_exponential(multiplier=1, min=4, max=10),
|
||||||
retry=retry_if_exception_type((RateLimitError, APIConnectionError, Timeout)),
|
retry=retry_if_exception_type(
|
||||||
|
(RateLimitError, APIConnectionError, APITimeoutError)
|
||||||
|
),
|
||||||
)
|
)
|
||||||
async def zhipu_complete_if_cache(
|
async def zhipu_complete_if_cache(
|
||||||
prompt: Union[str, List[Dict[str, str]]],
|
prompt: Union[str, List[Dict[str, str]]],
|
||||||
@@ -834,7 +846,9 @@ async def zhipu_complete(
|
|||||||
@retry(
|
@retry(
|
||||||
stop=stop_after_attempt(3),
|
stop=stop_after_attempt(3),
|
||||||
wait=wait_exponential(multiplier=1, min=4, max=60),
|
wait=wait_exponential(multiplier=1, min=4, max=60),
|
||||||
retry=retry_if_exception_type((RateLimitError, APIConnectionError, Timeout)),
|
retry=retry_if_exception_type(
|
||||||
|
(RateLimitError, APIConnectionError, APITimeoutError)
|
||||||
|
),
|
||||||
)
|
)
|
||||||
async def zhipu_embedding(
|
async def zhipu_embedding(
|
||||||
texts: list[str], model: str = "embedding-3", api_key: str = None, **kwargs
|
texts: list[str], model: str = "embedding-3", api_key: str = None, **kwargs
|
||||||
@@ -870,7 +884,9 @@ async def zhipu_embedding(
|
|||||||
@retry(
|
@retry(
|
||||||
stop=stop_after_attempt(3),
|
stop=stop_after_attempt(3),
|
||||||
wait=wait_exponential(multiplier=1, min=4, max=60),
|
wait=wait_exponential(multiplier=1, min=4, max=60),
|
||||||
retry=retry_if_exception_type((RateLimitError, APIConnectionError, Timeout)),
|
retry=retry_if_exception_type(
|
||||||
|
(RateLimitError, APIConnectionError, APITimeoutError)
|
||||||
|
),
|
||||||
)
|
)
|
||||||
async def openai_embedding(
|
async def openai_embedding(
|
||||||
texts: list[str],
|
texts: list[str],
|
||||||
@@ -928,7 +944,9 @@ async def jina_embedding(
|
|||||||
@retry(
|
@retry(
|
||||||
stop=stop_after_attempt(3),
|
stop=stop_after_attempt(3),
|
||||||
wait=wait_exponential(multiplier=1, min=4, max=60),
|
wait=wait_exponential(multiplier=1, min=4, max=60),
|
||||||
retry=retry_if_exception_type((RateLimitError, APIConnectionError, Timeout)),
|
retry=retry_if_exception_type(
|
||||||
|
(RateLimitError, APIConnectionError, APITimeoutError)
|
||||||
|
),
|
||||||
)
|
)
|
||||||
async def nvidia_openai_embedding(
|
async def nvidia_openai_embedding(
|
||||||
texts: list[str],
|
texts: list[str],
|
||||||
@@ -959,7 +977,9 @@ async def nvidia_openai_embedding(
|
|||||||
@retry(
|
@retry(
|
||||||
stop=stop_after_attempt(3),
|
stop=stop_after_attempt(3),
|
||||||
wait=wait_exponential(multiplier=1, min=4, max=10),
|
wait=wait_exponential(multiplier=1, min=4, max=10),
|
||||||
retry=retry_if_exception_type((RateLimitError, APIConnectionError, Timeout)),
|
retry=retry_if_exception_type(
|
||||||
|
(RateLimitError, APIConnectionError, APITimeoutError)
|
||||||
|
),
|
||||||
)
|
)
|
||||||
async def azure_openai_embedding(
|
async def azure_openai_embedding(
|
||||||
texts: list[str],
|
texts: list[str],
|
||||||
@@ -990,7 +1010,9 @@ async def azure_openai_embedding(
|
|||||||
@retry(
|
@retry(
|
||||||
stop=stop_after_attempt(3),
|
stop=stop_after_attempt(3),
|
||||||
wait=wait_exponential(multiplier=1, min=4, max=60),
|
wait=wait_exponential(multiplier=1, min=4, max=60),
|
||||||
retry=retry_if_exception_type((RateLimitError, APIConnectionError, Timeout)),
|
retry=retry_if_exception_type(
|
||||||
|
(RateLimitError, APIConnectionError, APITimeoutError)
|
||||||
|
),
|
||||||
)
|
)
|
||||||
async def siliconcloud_embedding(
|
async def siliconcloud_embedding(
|
||||||
texts: list[str],
|
texts: list[str],
|
||||||
|
@@ -341,8 +341,14 @@ class JsonDocStatusStorage(DocStatusStorage):
|
|||||||
logger.info(f"Loaded document status storage with {len(self._data)} records")
|
logger.info(f"Loaded document status storage with {len(self._data)} records")
|
||||||
|
|
||||||
async def filter_keys(self, data: list[str]) -> set[str]:
|
async def filter_keys(self, data: list[str]) -> set[str]:
|
||||||
"""Return keys that don't exist in storage"""
|
"""Return keys that should be processed (not in storage or not successfully processed)"""
|
||||||
return set([k for k in data if k not in self._data])
|
return set(
|
||||||
|
[
|
||||||
|
k
|
||||||
|
for k in data
|
||||||
|
if k not in self._data or self._data[k]["status"] != DocStatus.PROCESSED
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
async def get_status_counts(self) -> Dict[str, int]:
|
async def get_status_counts(self) -> Dict[str, int]:
|
||||||
"""Get counts of documents in each status"""
|
"""Get counts of documents in each status"""
|
||||||
|
Reference in New Issue
Block a user