e2b-code-interpreter 0.0.4__tar.gz → 0.0.5__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: e2b-code-interpreter
3
- Version: 0.0.4
3
+ Version: 0.0.5
4
4
  Summary: E2B Code Interpreter - Stateful code execution
5
5
  Home-page: https://e2b.dev/
6
6
  License: Apache-2.0
@@ -1,6 +1,6 @@
1
1
  import copy
2
2
  from typing import List, Optional, Iterable, Dict
3
- from pydantic import BaseModel
3
+ from pydantic import BaseModel, field_serializer
4
4
 
5
5
 
6
6
  class Error(BaseModel):
@@ -234,6 +234,25 @@ class Execution(BaseModel):
234
234
  if d.is_main_result:
235
235
  return d.text
236
236
 
237
+ def to_json(self) -> str:
238
+ """
239
+ Returns the JSON representation of the Execution object.
240
+ """
241
+ return self.model_dump_json(exclude_none=True)
242
+
243
+ @field_serializer("results", when_used="json")
244
+ def serialize_results(results: List[Result]) -> List[Dict[str, str]]:
245
+ """
246
+ Serializes the results to JSON.
247
+ This method is used by the Pydantic JSON encoder.
248
+ """
249
+ serialized = []
250
+ for result in results:
251
+ serialized_dict = {key: result[key] for key in result.formats()}
252
+ serialized_dict['text'] = result.text
253
+ serialized.append(serialized_dict)
254
+ return serialized
255
+
237
256
 
238
257
  class KernelException(Exception):
239
258
  """
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "e2b-code-interpreter"
3
- version = "0.0.4"
3
+ version = "0.0.5"
4
4
  description = "E2B Code Interpreter - Stateful code execution"
5
5
  authors = ["e2b <hello@e2b.dev>"]
6
6
  license = "Apache-2.0"