promptlayer 1.0.62__py3-none-any.whl → 1.0.63__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.

Potentially problematic release.


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

promptlayer/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
1
  from .promptlayer import AsyncPromptLayer, PromptLayer
2
2
 
3
- __version__ = "1.0.62"
3
+ __version__ = "1.0.63"
4
4
  __all__ = ["PromptLayer", "AsyncPromptLayer", "__version__"]
@@ -27,10 +27,12 @@ from promptlayer.streaming import (
27
27
  openai_stream_completion,
28
28
  )
29
29
  from promptlayer.utils import (
30
+ aanthropic_bedrock_request,
30
31
  aanthropic_request,
31
32
  aazure_openai_request,
32
33
  agoogle_request,
33
34
  amistral_request,
35
+ anthropic_bedrock_request,
34
36
  anthropic_request,
35
37
  aopenai_request,
36
38
  avertexai_request,
@@ -92,6 +94,16 @@ MAP_PROVIDER_TO_FUNCTION_NAME = {
92
94
  "stream_function": google_stream_completion,
93
95
  },
94
96
  },
97
+ "anthropic.bedrock": {
98
+ "chat": {
99
+ "function_name": "anthropic.messages.create",
100
+ "stream_function": anthropic_stream_message,
101
+ },
102
+ "completion": {
103
+ "function_name": "anthropic.completions.create",
104
+ "stream_function": anthropic_stream_completion,
105
+ },
106
+ },
95
107
  }
96
108
 
97
109
 
@@ -102,6 +114,7 @@ MAP_PROVIDER_TO_FUNCTION = {
102
114
  "openai": openai_request,
103
115
  "openai.azure": azure_openai_request,
104
116
  "vertexai": vertexai_request,
117
+ "anthropic.bedrock": anthropic_bedrock_request,
105
118
  }
106
119
 
107
120
  AMAP_PROVIDER_TO_FUNCTION_NAME = {
@@ -155,6 +168,16 @@ AMAP_PROVIDER_TO_FUNCTION_NAME = {
155
168
  "stream_function": agoogle_stream_completion,
156
169
  },
157
170
  },
171
+ "anthropic.bedrock": {
172
+ "chat": {
173
+ "function_name": "anthropic.messages.create",
174
+ "stream_function": aanthropic_stream_message,
175
+ },
176
+ "completion": {
177
+ "function_name": "anthropic.completions.create",
178
+ "stream_function": aanthropic_stream_completion,
179
+ },
180
+ },
158
181
  }
159
182
 
160
183
 
@@ -165,6 +188,7 @@ AMAP_PROVIDER_TO_FUNCTION = {
165
188
  "openai": aopenai_request,
166
189
  "openai.azure": aazure_openai_request,
167
190
  "vertexai": avertexai_request,
191
+ "anthropic.bedrock": aanthropic_bedrock_request,
168
192
  }
169
193
 
170
194
 
@@ -18,7 +18,7 @@ def _build_stream_blueprint(result: Any, metadata: Dict) -> Any:
18
18
  elif provider == "google" or (provider == "vertexai" and model_name.startswith("gemini")):
19
19
  return build_prompt_blueprint_from_google_event(result, metadata)
20
20
 
21
- elif provider == "anthropic" or (provider == "vertexai" and model_name.startswith("claude")):
21
+ elif provider in ["anthropic", "anthropic.bedrock"] or (provider == "vertexai" and model_name.startswith("claude")):
22
22
  return build_prompt_blueprint_from_anthropic_event(result, metadata)
23
23
 
24
24
  elif provider == "mistral":
promptlayer/utils.py CHANGED
@@ -1542,3 +1542,45 @@ async def avertexai_request(prompt_blueprint: GetPromptTemplateResponse, client_
1542
1542
  raise NotImplementedError(
1543
1543
  f"Vertex AI request for model {prompt_blueprint['metadata']['model']['name']} is not implemented yet."
1544
1544
  )
1545
+
1546
+
1547
+ def anthropic_bedrock_request(prompt_blueprint: GetPromptTemplateResponse, client_kwargs: dict, function_kwargs: dict):
1548
+ from anthropic import AnthropicBedrock
1549
+
1550
+ client = AnthropicBedrock(
1551
+ aws_access_key=function_kwargs.pop("aws_access_key", None),
1552
+ aws_secret_key=function_kwargs.pop("aws_secret_key", None),
1553
+ aws_region=function_kwargs.pop("aws_region", None),
1554
+ aws_session_token=function_kwargs.pop("aws_session_token", None),
1555
+ base_url=function_kwargs.pop("base_url", None),
1556
+ **client_kwargs,
1557
+ )
1558
+ if prompt_blueprint["prompt_template"]["type"] == "chat":
1559
+ return anthropic_chat_request(client=client, **function_kwargs)
1560
+ elif prompt_blueprint["prompt_template"]["type"] == "completion":
1561
+ return anthropic_completions_request(client=client, **function_kwargs)
1562
+ raise NotImplementedError(
1563
+ f"Unsupported prompt template type {prompt_blueprint['prompt_template']['type']}' for Anthropic Bedrock"
1564
+ )
1565
+
1566
+
1567
+ async def aanthropic_bedrock_request(
1568
+ prompt_blueprint: GetPromptTemplateResponse, client_kwargs: dict, function_kwargs: dict
1569
+ ):
1570
+ from anthropic import AsyncAnthropicBedrock
1571
+
1572
+ client = AsyncAnthropicBedrock(
1573
+ aws_access_key=function_kwargs.pop("aws_access_key", None),
1574
+ aws_secret_key=function_kwargs.pop("aws_secret_key", None),
1575
+ aws_region=function_kwargs.pop("aws_region", None),
1576
+ aws_session_token=function_kwargs.pop("aws_session_token", None),
1577
+ base_url=function_kwargs.pop("base_url", None),
1578
+ **client_kwargs,
1579
+ )
1580
+ if prompt_blueprint["prompt_template"]["type"] == "chat":
1581
+ return await aanthropic_chat_request(client=client, **function_kwargs)
1582
+ elif prompt_blueprint["prompt_template"]["type"] == "completion":
1583
+ return await aanthropic_completions_request(client=client, **function_kwargs)
1584
+ raise NotImplementedError(
1585
+ f"Unsupported prompt template type {prompt_blueprint['prompt_template']['type']}' for Anthropic Bedrock"
1586
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: promptlayer
3
- Version: 1.0.62
3
+ Version: 1.0.63
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
@@ -1,22 +1,22 @@
1
- promptlayer/__init__.py,sha256=GjRpGyl6bTJY05ZQlkVZOr8_ahNCmuYI3BPS3vyKvsk,140
1
+ promptlayer/__init__.py,sha256=i_U-wg6qSSPBh8OcEf8G3SnNhnlNFx42LJZLadGC1gg,140
2
2
  promptlayer/groups/__init__.py,sha256=xhOAolLUBkr76ZHvJr29OwjCIk1V9qKQXjZCuyTJUIY,429
3
3
  promptlayer/groups/groups.py,sha256=YPROicy-TzpkrpA8vOpZS2lwvJ6VRtlbQ1S2oT1N0vM,338
4
4
  promptlayer/promptlayer.py,sha256=qaxxSvimmXgN45q-IvWsAtyzIJ-w397F97ofsH_7w00,22516
5
5
  promptlayer/promptlayer_base.py,sha256=jOgXzNZlV1LKOOsXSSAOgn8o4hXn_EV0oY9Nf3Bsu_s,6872
6
- promptlayer/promptlayer_mixins.py,sha256=x-HOqd7SaKnVHoGeySYKzwlPVnqpFH5oCohJQIEjLQY,12172
6
+ promptlayer/promptlayer_mixins.py,sha256=TYxcAAosWG7wmST-TmE4ScAM9KhJy7_K8VfW4Z2Fjlk,13010
7
7
  promptlayer/span_exporter.py,sha256=Pc1-zWAcjVCSykh-4rYPqiEZvzkG9xaYLVoHFY_TWaQ,2410
8
8
  promptlayer/streaming/__init__.py,sha256=yNO77fyOi_scNPbE-eIEDGwSOyp8WYyPZ7ZrHaoipmM,1523
9
9
  promptlayer/streaming/blueprint_builder.py,sha256=NLmqwspHoAsecrY7varbF4EQaUg5yBKfBxS4y7UycuU,5925
10
10
  promptlayer/streaming/response_handlers.py,sha256=vNvpP-RLVl2uHkKLc8Ci9bmNldCezRey40tgtBEd4bo,19005
11
- promptlayer/streaming/stream_processor.py,sha256=NQIumPzDwceFyqxLOHDe3tpAr2v39luICJlByVgB9mA,2813
11
+ promptlayer/streaming/stream_processor.py,sha256=vB9pB25bd0vG-Pl2UYqB8Ae6b9iKSH-WCB9S-SNOSAU,2836
12
12
  promptlayer/templates.py,sha256=7ObDPMzHXjttDdJdCXA_pDL9XAnmcujIWucmgZJcOC8,1179
13
13
  promptlayer/track/__init__.py,sha256=tyweLTAY7UpYpBHWwY-T3pOPDIlGjcgccYXqU_r0694,1710
14
14
  promptlayer/track/track.py,sha256=A-awcYwsSwxktrlCMchy8NITIquwxU1UXbgLZMwqrA0,3164
15
15
  promptlayer/types/__init__.py,sha256=xJcvQuOk91ZBBePb40-1FDNDKYrZoH5lPE2q6_UhprM,111
16
16
  promptlayer/types/prompt_template.py,sha256=blkVBhh4u5pMhgX_Dsn78sN7Rv2Vy_zhd1-NERLXTpM,5075
17
17
  promptlayer/types/request_log.py,sha256=xU6bcxQar6GaBOJlgZTavXUV3FjE8sF_nSjPu4Ya_00,174
18
- promptlayer/utils.py,sha256=ds8F-pF-1xcrJrurg4Uamg7GcMx8VHc-0vaD0zEtZnw,56018
19
- promptlayer-1.0.62.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
20
- promptlayer-1.0.62.dist-info/METADATA,sha256=xNrV0NJFpwRnLmWm7yStyQqdh1YCq3vCoU7LbMhHj3o,4819
21
- promptlayer-1.0.62.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
22
- promptlayer-1.0.62.dist-info/RECORD,,
18
+ promptlayer/utils.py,sha256=DNhX6ydXXIBDKI9c0d_Jke2l-ZjpdvIpWqXM7ebjt20,58029
19
+ promptlayer-1.0.63.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
20
+ promptlayer-1.0.63.dist-info/METADATA,sha256=m9PDd_ZohbPjrl2jB4yfAbg96q9IpfeVUFxaFzm8wrQ,4819
21
+ promptlayer-1.0.63.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
22
+ promptlayer-1.0.63.dist-info/RECORD,,