promptlayer 1.0.13__tar.gz → 1.0.15__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.13
3
+ Version: 1.0.15
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,4 +1,4 @@
1
1
  from .promptlayer import PromptLayer
2
2
 
3
- __version__ = "1.0.13"
3
+ __version__ = "1.0.15"
4
4
  __all__ = ["PromptLayer", "__version__"]
@@ -61,7 +61,6 @@ class PromptLayer:
61
61
  self,
62
62
  api_key: str = None,
63
63
  enable_tracing: bool = False,
64
- workspace_id: int = None,
65
64
  ):
66
65
  if api_key is None:
67
66
  api_key = os.environ.get("PROMPTLAYER_API_KEY")
@@ -72,15 +71,11 @@ class PromptLayer:
72
71
  "Please set the PROMPTLAYER_API_KEY environment variable or pass the api_key parameter."
73
72
  )
74
73
 
75
- if enable_tracing and not workspace_id:
76
- raise ValueError("Please set a workspace_id to enable tracing.")
77
-
78
74
  self.api_key = api_key
79
75
  self.templates = TemplateManager(api_key)
80
76
  self.group = GroupManager(api_key)
81
- self.tracer = self._initialize_tracer(api_key, enable_tracing, workspace_id)
77
+ self.tracer = self._initialize_tracer(api_key, enable_tracing)
82
78
  self.track = TrackManager(api_key)
83
- self.workspace_id = workspace_id
84
79
 
85
80
  def __getattr__(
86
81
  self,
@@ -140,17 +135,13 @@ class PromptLayer:
140
135
  return self.templates.get(prompt_name, template_params)
141
136
 
142
137
  @staticmethod
143
- def _initialize_tracer(
144
- api_key: str = None, enable_tracing: bool = False, workspace_id: int = None
145
- ):
138
+ def _initialize_tracer(api_key: str = None, enable_tracing: bool = False):
146
139
  if enable_tracing:
147
140
  resource = Resource(
148
141
  attributes={ResourceAttributes.SERVICE_NAME: "prompt-layer-library"}
149
142
  )
150
143
  tracer_provider = TracerProvider(resource=resource)
151
- promptlayer_exporter = PromptLayerSpanExporter(
152
- api_key=api_key, workspace_id=workspace_id
153
- )
144
+ promptlayer_exporter = PromptLayerSpanExporter(api_key=api_key)
154
145
  span_processor = BatchSpanProcessor(promptlayer_exporter)
155
146
  tracer_provider.add_span_processor(span_processor)
156
147
  trace.set_tracer_provider(tracer_provider)
@@ -374,14 +365,14 @@ class PromptLayer:
374
365
  else:
375
366
  return self._run_internal(**_run_internal_kwargs)
376
367
 
377
- def traceable(self, metadata=None):
368
+ def traceable(self, attributes=None):
378
369
  def decorator(func):
379
370
  @wraps(func)
380
371
  def sync_wrapper(*args, **kwargs):
381
372
  if self.tracer:
382
373
  with self.tracer.start_as_current_span(func.__name__) as span:
383
- if metadata:
384
- for key, value in metadata.items():
374
+ if attributes:
375
+ for key, value in attributes.items():
385
376
  span.set_attribute(key, value)
386
377
 
387
378
  span.set_attribute(
@@ -398,8 +389,8 @@ class PromptLayer:
398
389
  async def async_wrapper(*args, **kwargs):
399
390
  if self.tracer:
400
391
  with self.tracer.start_as_current_span(func.__name__) as span:
401
- if metadata:
402
- for key, value in metadata.items():
392
+ if attributes:
393
+ for key, value in attributes.items():
403
394
  span.set_attribute(key, value)
404
395
 
405
396
  span.set_attribute(
@@ -8,10 +8,9 @@ from promptlayer.utils import URL_API_PROMPTLAYER
8
8
 
9
9
 
10
10
  class PromptLayerSpanExporter(SpanExporter):
11
- def __init__(self, api_key: str = None, workspace_id: int = None):
11
+ def __init__(self, api_key: str = None):
12
12
  self.api_key = api_key
13
13
  self.url = f"{URL_API_PROMPTLAYER}/spans-bulk"
14
- self.workspace_id = workspace_id
15
14
 
16
15
  def export(self, spans: Sequence[ReadableSpan]) -> SpanExportResult:
17
16
  request_data = []
@@ -65,7 +64,6 @@ class PromptLayerSpanExporter(SpanExporter):
65
64
  },
66
65
  json={
67
66
  "spans": request_data,
68
- "workspace_id": self.workspace_id,
69
67
  },
70
68
  )
71
69
  response.raise_for_status()
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "promptlayer"
3
- version = "1.0.13"
3
+ version = "1.0.15"
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