File tree Expand file tree Collapse file tree 5 files changed +21
-5
lines changed Expand file tree Collapse file tree 5 files changed +21
-5
lines changed Original file line number Diff line number Diff line change 1- __version__ = "0.48.2 "
1+ __version__ = "0.49.0 "
22
33
44def get_sdk_version ():
Original file line number Diff line number Diff line change 11import os
22from typing import Any
33
4+ import httpx
45from llama_index .core .embeddings import BaseEmbedding
56from llama_index .embeddings .azure_openai import AzureOpenAIEmbedding
67
@@ -18,7 +19,7 @@ class Constants:
1819 DEPLOYMENT_NAME = "deployment_name"
1920 API_TYPE = "azure"
2021 TIMEOUT = "timeout"
21- DEFAULT_TIMEOUT = 60
22+ DEFAULT_TIMEOUT = 240
2223
2324
2425class AzureOpenAI (EmbeddingAdapter ):
@@ -59,6 +60,8 @@ def get_embedding_instance(self) -> BaseEmbedding:
5960 config = self .config
6061 )
6162 timeout = int (self .config .get (Constants .TIMEOUT , Constants .DEFAULT_TIMEOUT ))
63+ httpx_timeout = httpx .Timeout (timeout , connect = 60.0 )
64+ httpx_client = httpx .Client (timeout = httpx_timeout )
6265 embedding : BaseEmbedding = AzureOpenAIEmbedding (
6366 model = str (self .config .get (Constants .MODEL )),
6467 deployment_name = str (self .config .get (Constants .DEPLOYMENT_NAME )),
@@ -68,6 +71,7 @@ def get_embedding_instance(self) -> BaseEmbedding:
6871 embed_batch_size = embedding_batch_size ,
6972 api_type = Constants .API_TYPE ,
7073 timeout = timeout ,
74+ http_client = httpx_client ,
7175 )
7276 return embedding
7377 except Exception as e :
Original file line number Diff line number Diff line change 5959 "minimum" : 0 ,
6060 "multipleOf" : 1 ,
6161 "title" : " Timeout" ,
62- "default" : 60 ,
62+ "default" : 240 ,
6363 "description" : " Timeout for each request in seconds"
6464 }
6565 }
Original file line number Diff line number Diff line change 11import os
22from typing import Any
33
4+ import httpx
45from llama_index .core .embeddings import BaseEmbedding
56from llama_index .embeddings .openai import OpenAIEmbedding
67
1112
1213class Constants :
1314 API_KEY = "api_key"
15+ MODEL = "model"
1416 API_BASE_VALUE = "https://api.openai.com/v1/"
1517 API_BASE_KEY = "api_base"
1618 ADAPTER_NAME = "adapter_name"
1719 API_TYPE = "openai"
1820 TIMEOUT = "timeout"
19- DEFAULT_TIMEOUT = 60
21+ DEFAULT_TIMEOUT = 240
2022
2123
2224class OpenAI (EmbeddingAdapter ):
@@ -54,13 +56,17 @@ def get_json_schema() -> str:
5456 def get_embedding_instance (self ) -> BaseEmbedding :
5557 try :
5658 timeout = int (self .config .get (Constants .TIMEOUT , Constants .DEFAULT_TIMEOUT ))
59+ httpx_timeout = httpx .Timeout (10.0 , connect = 60.0 )
60+ httpx_client = httpx .Client (timeout = httpx_timeout )
5761 embedding : BaseEmbedding = OpenAIEmbedding (
5862 api_key = str (self .config .get (Constants .API_KEY )),
5963 api_base = str (
6064 self .config .get (Constants .API_BASE_KEY , Constants .API_BASE_VALUE )
6165 ),
66+ model = str (self .config .get (Constants .MODEL )),
6267 api_type = Constants .API_TYPE ,
6368 timeout = timeout ,
69+ http_client = httpx_client ,
6470 )
6571 return embedding
6672 except Exception as e :
Original file line number Diff line number Diff line change 1212 "default" : " " ,
1313 "description" : " Provide a unique name for this adapter instance. Example: openai-emb-1"
1414 },
15+ "model" : {
16+ "type" : " string" ,
17+ "title" : " Model" ,
18+ "default" : " text-embedding-ada-002" ,
19+ "description" : " Provide the name of the model."
20+ },
1521 "api_key" : {
1622 "type" : " string" ,
1723 "title" : " API Key" ,
3642 "minimum" : 0 ,
3743 "multipleOf" : 1 ,
3844 "title" : " Timeout" ,
39- "default" : 60 ,
45+ "default" : 240 ,
4046 "description" : " Timeout in seconds"
4147 }
4248 }
You can’t perform that action at this time.
0 commit comments