promptlayer 1.0.5__tar.gz → 1.0.7__tar.gz

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.

Potentially problematic release.


This version of promptlayer might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: promptlayer
3
- Version: 1.0.5
3
+ Version: 1.0.7
4
4
  Summary: PromptLayer is a platform for prompt engineering and tracks your LLM requests.
5
5
  License: Apache-2.0
6
6
  Author: Magniv
@@ -41,7 +41,12 @@ def promptlayer_api_handler(
41
41
  isinstance(response, types.GeneratorType)
42
42
  or isinstance(response, types.AsyncGeneratorType)
43
43
  or type(response).__name__
44
- in ["Stream", "AsyncStream", "AsyncMessageStreamManager"]
44
+ in [
45
+ "Stream",
46
+ "AsyncStream",
47
+ "AsyncMessageStreamManager",
48
+ "MessageStreamManager",
49
+ ]
45
50
  ):
46
51
  return GeneratorProxy(
47
52
  response,
@@ -356,6 +361,19 @@ class GeneratorProxy:
356
361
  self.api_key,
357
362
  )
358
363
 
364
+ def __enter__(self):
365
+ api_request_arguments = self.api_request_arugments
366
+ if hasattr(self.generator, "_MessageStreamManager__api_request"):
367
+ stream = self.generator.__enter__()
368
+ return GeneratorProxy(
369
+ stream,
370
+ api_request_arguments,
371
+ self.api_key,
372
+ )
373
+
374
+ def __exit__(self, exc_type, exc_val, exc_tb):
375
+ pass
376
+
359
377
  async def __aexit__(self, exc_type, exc_val, exc_tb):
360
378
  pass
361
379
 
@@ -418,8 +436,11 @@ class GeneratorProxy:
418
436
  response = f"{response}{result.completion}"
419
437
  elif hasattr(result, "message") and isinstance(result.message, str):
420
438
  response = f"{response}{result.message}"
421
- elif hasattr(result, "content_block") and hasattr(
422
- result.content_block, "text"
439
+ elif (
440
+ hasattr(result, "content_block")
441
+ and hasattr(result.content_block, "text")
442
+ and "type" in result
443
+ and result.type != "message_stop"
423
444
  ):
424
445
  response = f"{response}{result.content_block.text}"
425
446
  elif hasattr(result, "delta") and hasattr(result.delta, "text"):
@@ -458,7 +479,7 @@ class GeneratorProxy:
458
479
  hasattr(result.choices[0].delta, "content")
459
480
  and result.choices[0].delta.content is not None
460
481
  ):
461
- response[
482
+ response["content"] = response[
462
483
  "content"
463
484
  ] = f"{response['content']}{result.choices[0].delta.content}"
464
485
  final_result = deepcopy(self.results[-1])
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "promptlayer"
3
- version = "1.0.5"
3
+ version = "1.0.7"
4
4
  description = "PromptLayer is a platform for prompt engineering and tracks your LLM requests."
5
5
  authors = ["Magniv <hello@magniv.io>"]
6
6
  license = "Apache-2.0"
File without changes
File without changes