lionagi 0.0.115__py3-none-any.whl → 0.0.116__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -115,6 +115,8 @@ class Session:
115
115
  # kwargs = {**tool_kwarg, **kwargs}
116
116
  if self.tool_manager.registry != {}:
117
117
  kwargs = self._tool_parser(**kwargs)
118
+ if self.service is not None:
119
+ await self.service._init()
118
120
  config = {**self.llmconfig, **kwargs}
119
121
  system = system or self.system
120
122
  self.conversation.initiate_conversation(system=system, instruction=instruction, context=context, name=name)
@@ -182,4 +184,4 @@ class Session:
182
184
  self.service.status_tracker.num_tasks_succeeded += 1
183
185
  else:
184
186
  self.service.status_tracker.num_tasks_failed += 1
185
-
187
+
@@ -22,7 +22,7 @@ class BaseAPIRateLimiter(RateLimiter):
22
22
  ) -> None:
23
23
  self = cls(max_requests_per_minute, max_tokens_per_minute)
24
24
  if not os.getenv("env_readthedocs"):
25
- self.rate_limit_replenisher_task = await asyncio.create_task(
25
+ self.rate_limit_replenisher_task = asyncio.create_task(
26
26
  self.rate_limit_replenisher()
27
27
  )
28
28
  return self
@@ -133,13 +133,16 @@ class BaseAPIService(BaseService):
133
133
  def __init__(self, api_key: str = None,
134
134
  status_tracker = None,
135
135
  queue = None, endpoint=None, schema=None,
136
- ratelimiter=None, max_requests_per_minute=None, max_tokens_per_minute=None) -> None:
136
+ ratelimiter=BaseAPIRateLimiter, max_requests_per_minute=None, max_tokens_per_minute=None) -> None:
137
137
  self.api_key = api_key
138
138
  self.status_tracker = status_tracker or StatusTracker()
139
139
  self.queue = queue or AsyncQueue()
140
140
  self.endpoint=endpoint
141
141
  self.schema = schema
142
- self.rate_limiter = ratelimiter(max_requests_per_minute, max_tokens_per_minute)
142
+ self.max_requests_per_minute = max_requests_per_minute
143
+ self.max_tokens_per_minute = max_tokens_per_minute
144
+ self.rate_limiter_class = ratelimiter
145
+ self.rate_limiter = None
143
146
 
144
147
  @staticmethod
145
148
  def api_methods(http_session, method="post"):
@@ -171,6 +174,10 @@ class BaseAPIService(BaseService):
171
174
  yield task_id
172
175
  task_id += 1
173
176
 
177
+ async def _init(self):
178
+ if self.rate_limiter is None:
179
+ self.rate_limiter = await self.rate_limiter_class.create(self.max_requests_per_minute, self.max_tokens_per_minute)
180
+
174
181
  async def _call_api(self, http_session, endpoint_, method="post", payload: Dict[str, any] =None) -> Optional[Dict[str, any]]:
175
182
  endpoint_ = self.api_endpoint_from_url("https://api.openai.com/v1/"+endpoint_)
176
183
 
@@ -227,4 +234,4 @@ class BaseAPIService(BaseService):
227
234
  except Exception as e:
228
235
  self.status_tracker.num_tasks_failed += 1
229
236
  raise e
230
-
237
+
lionagi/services/oai.py CHANGED
@@ -15,7 +15,7 @@ class OpenAIService(BaseAPIService):
15
15
  max_attempts: int = 3,
16
16
  max_requests_per_minute: int = 500,
17
17
  max_tokens_per_minute: int = 150_000,
18
- ratelimiter = BaseAPIRateLimiter ,
18
+ ratelimiter = BaseAPIRateLimiter,
19
19
  status_tracker = None,
20
20
  queue = None,
21
21
  ):
@@ -31,4 +31,4 @@ class OpenAIService(BaseAPIService):
31
31
 
32
32
  async def serve(self, payload, endpoint_="chat/completions", method="post"):
33
33
  return await self._serve(payload=payload, endpoint_=endpoint_, method=method)
34
-
34
+
lionagi/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.0.115"
1
+ __version__ = "0.0.116"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lionagi
3
- Version: 0.0.115
3
+ Version: 0.0.116
4
4
  Summary: Towards automated general intelligence.
5
5
  Author: HaiyangLi
6
6
  Author-email: Haiyang Li <ocean@lionagi.ai>
@@ -1,5 +1,5 @@
1
1
  lionagi/__init__.py,sha256=19MF4mClDcA1MnveM-mMVzHozpm0SPB_Q9xr_iARUnM,905
2
- lionagi/version.py,sha256=kJWTvBdGHSY-dEE48wQ1yJp4kCxegBM6lwZcvHLo7H8,24
2
+ lionagi/version.py,sha256=eLNosBjJzYQH-LOycm3M-_lc70PB3et54VYnvKM502o,24
3
3
  lionagi/bridge/__init__.py,sha256=YDKi-pniFEknEXTSEvX6yEe4Y69f0kLvbjvEQ0TdrTU,575
4
4
  lionagi/bridge/langchain.py,sha256=-3rlRnI5Df5vyfjZ2AoWD-4Rl623MD1lRqvMV7ZKjbs,5304
5
5
  lionagi/bridge/llama_index.py,sha256=GwHksLzQZHxiSgXsWhviPccgSj3ZQWo9ujdPklQtU9k,5600
@@ -15,7 +15,7 @@ lionagi/core/flows/flow_util.py,sha256=6O1Y6zHKvKRA1xshBzseNyDjGJyUkIL0DSbbkon-h
15
15
  lionagi/core/instruction_set/__init__.py,sha256=BUQ35fKuVAq55CWj8FMFYabULNdxYVhcOSwwOEA_BFE,83
16
16
  lionagi/core/instruction_set/instruction_sets.py,sha256=3kKpXMjtLXHAcS51cElpgT8b6j31EzX7RBatnAl-hnQ,193
17
17
  lionagi/core/sessions/__init__.py,sha256=orAbb5Ehq8arlPOoV_UkJBFtEXfeF_aROb_scNjppWo,58
18
- lionagi/core/sessions/sessions.py,sha256=3qY4oEdpPCZePleO9gB0-3hpMiwNq85NDGd6PZBZTqk,7692
18
+ lionagi/core/sessions/sessions.py,sha256=rK1pInjfFbyeY66en8C8sDSlnmT5PPjz9j0WOYBCbmc,7769
19
19
  lionagi/datastores/__init__.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
20
20
  lionagi/datastores/chroma.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
21
21
  lionagi/datastores/deeplake.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
@@ -58,7 +58,7 @@ lionagi/services/__init__.py,sha256=bcRRZBM6L2jgGzOW9o8hxnZb3d_b6fgc3rZUhWThbnk,
58
58
  lionagi/services/anthropic.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
59
59
  lionagi/services/anyscale.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
60
60
  lionagi/services/azure.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
61
- lionagi/services/base_api_service.py,sha256=EOVxyF8iRmy1FBCZh8757WZojBaRLXPFR26STb9bOlo,9868
61
+ lionagi/services/base_api_service.py,sha256=x9bvHwEn-uKQlWvHcR3Gw07n9ym_E857RAIhE6NkGZc,10183
62
62
  lionagi/services/bedrock.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
63
63
  lionagi/services/everlyai.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
64
64
  lionagi/services/gemini.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -67,7 +67,7 @@ lionagi/services/huggingface.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSu
67
67
  lionagi/services/litellm.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
68
68
  lionagi/services/localai.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
69
69
  lionagi/services/mistralai.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
70
- lionagi/services/oai.py,sha256=NcKiqmQ8YpKEkoVv-6a-mvIZVBumWOVpstpVD0oTiUs,1122
70
+ lionagi/services/oai.py,sha256=ocuaX4jcqEwZUi9ffbk7qCnLK7NL-b1mAaJ-r-ZBMtY,1122
71
71
  lionagi/services/ollama.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
72
72
  lionagi/services/openllm.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
73
73
  lionagi/services/openrouter.py,sha256=muyQxS7vzyq_Z02IoRE7q4TQHZVZ8rYKpnC5SUdXDis,1107
@@ -103,8 +103,8 @@ lionagi/utils/encrypt_util.py,sha256=JBUrLRkgmPgbvLvf20Ufw1SjxI6qx2FlzVZZCKzx3XQ
103
103
  lionagi/utils/flat_util.py,sha256=RR2c0AwCWG9dI8vLsCE8PIJLQkGlR6kPYL65UnVEaSg,24210
104
104
  lionagi/utils/io_util.py,sha256=2nOfHcWR05HhezYFcsDrYGQEGVvX6XE8Q4fUaar8Y6I,3531
105
105
  lionagi/utils/sys_util.py,sha256=NNeBEo3QNj0BRlFLtZvWMtwT25u7IOgbcp9Y49-vQ4o,7362
106
- lionagi-0.0.115.dist-info/LICENSE,sha256=TBnSyG8fs_tMRtK805GzA1cIyExleKyzoN_kuVxT9IY,11358
107
- lionagi-0.0.115.dist-info/METADATA,sha256=2uexKOXnKEUyMghr6tIU54XqihsBBbLknXsAXZ7xA4c,18025
108
- lionagi-0.0.115.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
109
- lionagi-0.0.115.dist-info/top_level.txt,sha256=szvch_d2jE1Lu9ZIKsl26Ll6BGfYfbOgt5lm-UpFSo4,8
110
- lionagi-0.0.115.dist-info/RECORD,,
106
+ lionagi-0.0.116.dist-info/LICENSE,sha256=TBnSyG8fs_tMRtK805GzA1cIyExleKyzoN_kuVxT9IY,11358
107
+ lionagi-0.0.116.dist-info/METADATA,sha256=36Zw3nGYhrDfemxXFBXf3674j6exozg10HUD2BpBgb0,18025
108
+ lionagi-0.0.116.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
109
+ lionagi-0.0.116.dist-info/top_level.txt,sha256=szvch_d2jE1Lu9ZIKsl26Ll6BGfYfbOgt5lm-UpFSo4,8
110
+ lionagi-0.0.116.dist-info/RECORD,,