agenta 0.17.5__py3-none-any.whl → 0.17.6a1__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 agenta might be problematic. Click here for more details.

@@ -83,9 +83,11 @@ class entrypoint(BaseDecorator):
83
83
  {"config": config_params, "environment": "playground"}
84
84
  )
85
85
 
86
+ # Exceptions are all handled inside self.execute_function()
86
87
  llm_result = await self.execute_function(
87
88
  func, *args, params=func_params, config_params=config_params
88
89
  )
90
+
89
91
  return llm_result
90
92
 
91
93
  @functools.wraps(func)
@@ -58,19 +58,24 @@ class instrument(BaseDecorator):
58
58
  try:
59
59
  result = await func(*args, **kwargs)
60
60
  self.tracing.update_span_status(span=span, value="OK")
61
- except Exception as e:
62
- result = str(e)
63
- self.tracing.set_span_attribute(
64
- {"traceback_exception": traceback.format_exc()}
65
- )
66
- self.tracing.update_span_status(span=span, value="ERROR")
67
- finally:
68
61
  self.tracing.end_span(
69
62
  outputs=(
70
63
  {"message": result} if not isinstance(result, dict) else result
71
64
  )
72
65
  )
73
- return result
66
+ return result
67
+
68
+ except Exception as e:
69
+ result = {
70
+ "message": str(e),
71
+ "stacktrace": traceback.format_exc(),
72
+ }
73
+ self.tracing.set_span_attribute(
74
+ {"traceback_exception": traceback.format_exc()}
75
+ )
76
+ self.tracing.update_span_status(span=span, value="ERROR")
77
+ self.tracing.end_span(outputs=result)
78
+ raise e
74
79
 
75
80
  @wraps(func)
76
81
  def sync_wrapper(*args, **kwargs):
@@ -89,17 +94,23 @@ class instrument(BaseDecorator):
89
94
  try:
90
95
  result = func(*args, **kwargs)
91
96
  self.tracing.update_span_status(span=span, value="OK")
92
- except Exception as e:
93
- result = str(e)
94
- self.tracing.set_span_attribute(
95
- {"traceback_exception": traceback.format_exc()}
96
- )
97
- self.tracing.update_span_status(span=span, value="ERROR")
98
- finally:
99
97
  self.tracing.end_span(
100
98
  outputs=(
101
99
  {"message": result} if not isinstance(result, dict) else result
102
100
  )
103
101
  )
102
+ return result
103
+
104
+ except Exception as e:
105
+ result = {
106
+ "message": str(e),
107
+ "stacktrace": traceback.format_exc(),
108
+ }
109
+ self.tracing.set_span_attribute(
110
+ {"traceback_exception": traceback.format_exc()}
111
+ )
112
+ self.tracing.update_span_status(span=span, value="ERROR")
113
+ self.tracing.end_span(outputs=result)
114
+ raise e
104
115
 
105
116
  return async_wrapper if is_coroutine_function else sync_wrapper
@@ -55,7 +55,9 @@ def litellm_handler():
55
55
  "message": kwargs.get(
56
56
  "complete_streaming_response"
57
57
  ), # the complete streamed response (only set if `completion(..stream=True)`)
58
- "usage": response_obj.usage.dict(), # litellm calculates usage
58
+ "usage": response_obj.usage.dict()
59
+ if hasattr(response_obj, "usage")
60
+ else None, # litellm calculates usage
59
61
  "cost": kwargs.get(
60
62
  "response_cost"
61
63
  ), # litellm calculates response cost
@@ -69,7 +71,9 @@ def litellm_handler():
69
71
  self._trace.end_span(
70
72
  outputs={
71
73
  "message": response_obj.choices[0].message.content,
72
- "usage": response_obj.usage.dict(), # litellm calculates usage
74
+ "usage": response_obj.usage.dict()
75
+ if hasattr(response_obj, "usage")
76
+ else None, # litellm calculates usage
73
77
  "cost": kwargs.get(
74
78
  "response_cost"
75
79
  ), # litellm calculates response cost
@@ -93,7 +97,9 @@ def litellm_handler():
93
97
  self._trace.end_span(
94
98
  outputs={
95
99
  "message": kwargs["exception"], # the Exception raised
96
- "usage": response_obj.usage.dict(), # litellm calculates usage
100
+ "usage": response_obj.usage.dict()
101
+ if hasattr(response_obj, "usage")
102
+ else None, # litellm calculates usage
97
103
  "cost": kwargs.get(
98
104
  "response_cost"
99
105
  ), # litellm calculates response cost
@@ -109,7 +115,9 @@ def litellm_handler():
109
115
  "message": kwargs.get(
110
116
  "complete_streaming_response"
111
117
  ), # the complete streamed response (only set if `completion(..stream=True)`)
112
- "usage": response_obj.usage.dict(), # litellm calculates usage
118
+ "usage": response_obj.usage.dict()
119
+ if hasattr(response_obj, "usage")
120
+ else None, # litellm calculates usage
113
121
  "cost": kwargs.get(
114
122
  "response_cost"
115
123
  ), # litellm calculates response cost
@@ -123,7 +131,9 @@ def litellm_handler():
123
131
  self._trace.end_span(
124
132
  outputs={
125
133
  "message": response_obj.choices[0].message.content,
126
- "usage": response_obj.usage.dict(), # litellm calculates usage
134
+ "usage": response_obj.usage.dict()
135
+ if hasattr(response_obj, "usage")
136
+ else None, # litellm calculates usage
127
137
  "cost": kwargs.get(
128
138
  "response_cost"
129
139
  ), # litellm calculates response cost
@@ -147,7 +157,9 @@ def litellm_handler():
147
157
  self._trace.end_span(
148
158
  outputs={
149
159
  "message": kwargs["exception"], # the Exception raised
150
- "usage": response_obj.usage.dict(), # litellm calculates usage
160
+ "usage": response_obj.usage.dict()
161
+ if hasattr(response_obj, "usage")
162
+ else None, # litellm calculates usage
151
163
  "cost": kwargs.get(
152
164
  "response_cost"
153
165
  ), # litellm calculates response cost
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: agenta
3
- Version: 0.17.5
3
+ Version: 0.17.6a1
4
4
  Summary: The SDK for agenta is an open-source LLMOps platform.
5
5
  Home-page: https://agenta.ai
6
6
  Keywords: LLMOps,LLM,evaluation,prompt engineering
@@ -131,11 +131,11 @@ agenta/sdk/agenta_init.py,sha256=aKCJRoZ6nsY3dHWwvgxdxyJhYL3n5xEcD6ZJiqshchQ,995
131
131
  agenta/sdk/client.py,sha256=trKyBOYFZRk0v5Eptxvh87yPf50Y9CqY6Qgv4Fy-VH4,2142
132
132
  agenta/sdk/context.py,sha256=q-PxL05-I84puunUAs9LGsffEXcYhDxhQxjuOz2vK90,901
133
133
  agenta/sdk/decorators/base.py,sha256=9aNdX5h8a2mFweuhdO-BQPwXGKY9ONPIdLRhSGAGMfY,217
134
- agenta/sdk/decorators/llm_entrypoint.py,sha256=o1kD14dfXLV3p1OyzgCUA6mIoyDV_YuW__kfXaAKW_I,22754
135
- agenta/sdk/decorators/tracing.py,sha256=_6lbnhoJgz6q6OkMDNWoLstuv-ZvTz9ExcetW2sTiEY,3447
134
+ agenta/sdk/decorators/llm_entrypoint.py,sha256=awdd2fSjVKIz3MVmElHw8_nJxFvePI_zMdPd_QWxIM0,22827
135
+ agenta/sdk/decorators/tracing.py,sha256=4Ta9UN3pjQhxST6lnPaNz1GwnoXz2EHjq5JGqd4g8qw,3817
136
136
  agenta/sdk/router.py,sha256=0sbajvn5C7t18anH6yNo7-oYxldHnYfwcbmQnIXBePw,269
137
137
  agenta/sdk/tracing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
138
- agenta/sdk/tracing/callbacks.py,sha256=E5cA6dzut90WSQ38Zy2y1XkiP6wRQ1j1CGcEo5oCsWc,6312
138
+ agenta/sdk/tracing/callbacks.py,sha256=8XYcGC4EZQ0lBn2IWmtPH_yC5Hu6Yu-NkdZRuY7CoTw,6816
139
139
  agenta/sdk/tracing/context_manager.py,sha256=HskDaiORoOhjeN375gm05wYnieQzh5UnoIsnSAHkAyc,252
140
140
  agenta/sdk/tracing/llm_tracing.py,sha256=fHtc1tKgdR2CDnFMrfDIxSvyjwFW3Qk2RE8P-y_tCM0,11361
141
141
  agenta/sdk/tracing/logger.py,sha256=GfH7V-jBHcn7h5dbdrnkDMe_ml3wkXFBeoQiqR4KVRc,474
@@ -159,7 +159,7 @@ agenta/templates/simple_prompt/app.py,sha256=kODgF6lhzsaJPdgL5b21bUki6jkvqjWZzWR
159
159
  agenta/templates/simple_prompt/env.example,sha256=g9AE5bYcGPpxawXMJ96gh8oenEPCHTabsiOnfQo3c5k,70
160
160
  agenta/templates/simple_prompt/requirements.txt,sha256=ywRglRy7pPkw8bljmMEJJ4aOOQKrt9FGKULZ-DGkoBU,23
161
161
  agenta/templates/simple_prompt/template.toml,sha256=DQBtRrF4GU8LBEXOZ-GGuINXMQDKGTEG5y37tnvIUIE,60
162
- agenta-0.17.5.dist-info/METADATA,sha256=t2FWDTfX0KJuqDUrim87E_dysSTg1fr5L7-BC2BiPw4,26458
163
- agenta-0.17.5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
164
- agenta-0.17.5.dist-info/entry_points.txt,sha256=PDiu8_8AsL7ibU9v4iNoOKR1S7F2rdxjlEprjM9QOgo,46
165
- agenta-0.17.5.dist-info/RECORD,,
162
+ agenta-0.17.6a1.dist-info/METADATA,sha256=C8nSi2ONQxN_eJvqInko-n097OcsZ6atl5OBVq5pWtM,26460
163
+ agenta-0.17.6a1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
164
+ agenta-0.17.6a1.dist-info/entry_points.txt,sha256=PDiu8_8AsL7ibU9v4iNoOKR1S7F2rdxjlEprjM9QOgo,46
165
+ agenta-0.17.6a1.dist-info/RECORD,,