arpakitlib 1.8.107__py3-none-any.whl → 1.8.108__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,45 @@
1
+ import asyncio
2
+ from functools import lru_cache
3
+
4
+ import httpx
5
+ from arpakitlib.ar_logging_util import setup_normal_logging
6
+ from arpakitlib.ar_openai_api_client_util import EasyOpenAIAPIClient
7
+ from openai import OpenAI, AsyncOpenAI
8
+
9
+ from project.core.settings import get_cached_settings
10
+
11
+
12
+ def create_easy_openai_api_client() -> EasyOpenAIAPIClient | None:
13
+ if get_cached_settings().openai_api_key is None:
14
+ return None
15
+
16
+ return EasyOpenAIAPIClient(
17
+ open_ai=OpenAI(
18
+ api_key=get_cached_settings().openai_api_key,
19
+ base_url=get_cached_settings().openai_api_base_url,
20
+ timeout=httpx.Timeout(
21
+ timeout=60,
22
+ connect=15,
23
+ read=60,
24
+ write=60,
25
+ pool=15
26
+ )
27
+ ),
28
+ async_open_ai=AsyncOpenAI(
29
+ api_key=get_cached_settings().openai_api_key,
30
+ base_url=get_cached_settings().openai_api_base_url
31
+ )
32
+ )
33
+
34
+
35
+ @lru_cache()
36
+ def get_cached_easy_openai_api_client() -> EasyOpenAIAPIClient | None:
37
+ return create_easy_openai_api_client()
38
+
39
+
40
+ async def __async_example():
41
+ setup_normal_logging()
42
+
43
+
44
+ if __name__ == '__main__':
45
+ asyncio.run(__async_example())
@@ -173,6 +173,10 @@ class Settings(SimpleSettings):
173
173
  raise_for_type(self.local_timezone, str)
174
174
  return pytz.timezone(self.local_timezone)
175
175
 
176
+ openai_api_key: str | None = None
177
+
178
+ openai_api_base_url: str | None = "https://api.proxyapi.ru/openai/v1"
179
+
176
180
 
177
181
  @lru_cache()
178
182
  def get_cached_settings() -> Settings:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: arpakitlib
3
- Version: 1.8.107
3
+ Version: 1.8.108
4
4
  Summary: arpakitlib
5
5
  License: Apache-2.0
6
6
  Keywords: arpakitlib,arpakit,arpakit-company,arpakitcompany,arpakit_company
@@ -168,9 +168,10 @@ arpakitlib/_arpakit_project_template_v_5/project/core/__init__.py,sha256=47DEQpj
168
168
  arpakitlib/_arpakit_project_template_v_5/project/core/cache_file_storage_in_dir.py,sha256=0lKPKvrs30DlAZwNS5ydPsQ9ETFLBjZqEcNv8LoQVCU,623
169
169
  arpakitlib/_arpakit_project_template_v_5/project/core/const.py,sha256=hgiiPIYL9543-eEnNAhZWYgX7ZzLKjOqRD0skkROSOw,951
170
170
  arpakitlib/_arpakit_project_template_v_5/project/core/dump_file_storage_in_dir.py,sha256=u3-vStMGaseMsRLuJmQK04UDhaez9vw6o5jyHb1fwNg,617
171
+ arpakitlib/_arpakit_project_template_v_5/project/core/easy_openai_api_client.py,sha256=NAwu0e7m4m2OVcZC0KBbgjiNxKmpIUofBzwTRbC1GBQ,1219
171
172
  arpakitlib/_arpakit_project_template_v_5/project/core/jinja2_templates.py,sha256=jCNLaBauGC7YNvZdTLNHuPp7hmRGt94O23Skg6ewo7o,352
172
173
  arpakitlib/_arpakit_project_template_v_5/project/core/media_file_storage_in_dir.py,sha256=fMofTsfJtA8pp5lEUhucEUu3PBsmj-elaRZzExDsdLI,623
173
- arpakitlib/_arpakit_project_template_v_5/project/core/settings.py,sha256=ZxBiE0cf7aywLhAz341MrRyjm4UeuE91Ja5JIjDZ9pU,5881
174
+ arpakitlib/_arpakit_project_template_v_5/project/core/settings.py,sha256=NlbGFZCR98hytoigP4E5TjazIUJt8NPSI0NZOmQ365A,5995
174
175
  arpakitlib/_arpakit_project_template_v_5/project/core/util.py,sha256=1ha9UrguVPsTSjoMHhVZVCD0_mNBfhIDGEvcG1nA4Zw,667
175
176
  arpakitlib/_arpakit_project_template_v_5/project/json_db/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
176
177
  arpakitlib/_arpakit_project_template_v_5/project/json_db/json_db.py,sha256=tBML-z4Y7uY8f_0ggcxvlDNt15Sf93Jr_OUeHwWxqOA,724
@@ -391,8 +392,8 @@ arpakitlib/ar_ssh_runner_util.py,sha256=yvAwza480MkHKvLkDEsR7JNh2bYNs6P9rCVo4NA8
391
392
  arpakitlib/ar_str_util.py,sha256=CAv0wH8nP5Ja59S-hEdmNhNrM_Fwy935d0zntLpJkx8,4309
392
393
  arpakitlib/ar_type_util.py,sha256=Cs_tef-Fc5xeyAF54KgISCsP11NHyzIsglm4S3Xx7iM,4049
393
394
  arpakitlib/ar_yookassa_api_client_util.py,sha256=VozuZeCJjmLd1zj2BdC9WfiAQ3XYOrIMsdpNK-AUlm0,5347
394
- arpakitlib-1.8.107.dist-info/LICENSE,sha256=GPEDQMam2r7FSTYqM1mm7aKnxLaWcBotH7UvQtea-ec,11355
395
- arpakitlib-1.8.107.dist-info/METADATA,sha256=FQKX2jz95Uw_IsgeFRvgE9peEFXnTVN-mIqirAJ37K0,3566
396
- arpakitlib-1.8.107.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
397
- arpakitlib-1.8.107.dist-info/entry_points.txt,sha256=36xqR3PJFT2kuwjkM_EqoIy0qFUDPKSm_mJaI7emewE,87
398
- arpakitlib-1.8.107.dist-info/RECORD,,
395
+ arpakitlib-1.8.108.dist-info/LICENSE,sha256=GPEDQMam2r7FSTYqM1mm7aKnxLaWcBotH7UvQtea-ec,11355
396
+ arpakitlib-1.8.108.dist-info/METADATA,sha256=jgzV39GScpi1sgRSiPkI7Bbt520miM5phD-0PlF6x2c,3566
397
+ arpakitlib-1.8.108.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
398
+ arpakitlib-1.8.108.dist-info/entry_points.txt,sha256=36xqR3PJFT2kuwjkM_EqoIy0qFUDPKSm_mJaI7emewE,87
399
+ arpakitlib-1.8.108.dist-info/RECORD,,