oagi 0.2.0__py3-none-any.whl → 0.2.1__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 oagi might be problematic. Click here for more details.

oagi/sync_client.py CHANGED
@@ -8,8 +8,10 @@
8
8
 
9
9
  import base64
10
10
  import os
11
+ from functools import wraps
11
12
 
12
13
  import httpx
14
+ from httpx import Response
13
15
  from pydantic import BaseModel
14
16
 
15
17
  from .exceptions import (
@@ -63,6 +65,27 @@ class LLMResponse(BaseModel):
63
65
  error: ErrorDetail | None = None
64
66
 
65
67
 
68
+ def _log_trace_id(response: Response):
69
+ logger.error(f"Request Id: {response.headers.get('x-request-id', '')}")
70
+ logger.error(f"Trace Id: {response.headers.get('x-trace-id', '')}")
71
+
72
+
73
+ def log_trace_on_failure(func):
74
+ """Decorator that logs trace ID when a method fails."""
75
+
76
+ @wraps(func)
77
+ def wrapper(*args, **kwargs):
78
+ try:
79
+ return func(*args, **kwargs)
80
+ except Exception as e:
81
+ # Try to get response from the exception if it has one
82
+ if (response := getattr(e, "response", None)) is not None:
83
+ _log_trace_id(response)
84
+ raise
85
+
86
+ return wrapper
87
+
88
+
66
89
  class SyncClient:
67
90
  def __init__(self, base_url: str | None = None, api_key: str | None = None):
68
91
  # Get from environment if not provided
@@ -98,6 +121,7 @@ class SyncClient:
98
121
  """Close the underlying httpx client"""
99
122
  self.client.close()
100
123
 
124
+ @log_trace_on_failure
101
125
  def create_message(
102
126
  self,
103
127
  model: str,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: oagi
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: Official API of OpenAGI Foundation
5
5
  Project-URL: Homepage, https://github.com/agiopen-org/oagi
6
6
  Author-email: OpenAGI Foundation <contact@agiopen.org>
@@ -5,7 +5,7 @@ oagi/pyautogui_action_handler.py,sha256=LBWmtqkXzZSJo07s3uOw-NWUE9rZZtbNAx0YI83p
5
5
  oagi/screenshot_maker.py,sha256=lyJSMFagHeaqg59CQGMTqLvSzQN_pBbhbV2oIFG46vA,2077
6
6
  oagi/short_task.py,sha256=ofcMi7vbu9W1MCSGOk_FNEHJcB02pfgNcx1-Y8UkpJY,1552
7
7
  oagi/single_step.py,sha256=JEsF7ABa4wwW5Pi5AfjeKzyuKhC4kC4fcotnmnNye5o,2874
8
- oagi/sync_client.py,sha256=XIuqAHD56BkBz5v4HshgWpjmfzs_z7TQbjDEzIcnKJA,8678
8
+ oagi/sync_client.py,sha256=E6EgFIe-H91rdsPhF1puwrBTpOnKaL6JA1WHR4R-CLY,9395
9
9
  oagi/task.py,sha256=NmpNMu8CJll50zGsGtVie1kdpKeWnAAWudEa-aasBbU,3959
10
10
  oagi/types/__init__.py,sha256=eh-1IEqMTY2hUrvQJeTg6vsvlE6F4Iz5C0_K86AnWn8,549
11
11
  oagi/types/action_handler.py,sha256=NH8E-m5qpGqWcXzTSWfF7W0Xdp8SkzJsbhCmQ0B96cg,1075
@@ -14,7 +14,7 @@ oagi/types/image_provider.py,sha256=oYFdOYznrK_VOR9egzOjw5wFM5w8EY2sY01pH0ANAgU,
14
14
  oagi/types/models/__init__.py,sha256=4qhKxWXsXEVzD6U_RM6PXR45os765qigtZs1BsS4WHg,414
15
15
  oagi/types/models/action.py,sha256=8Xd3IcH32ENq7uXczo-mbQ736yUOGxO_TaZTfHVRY7w,935
16
16
  oagi/types/models/step.py,sha256=RSI4H_2rrUBq_xyCoWKaq7JHdJWNobtQppaKC1l0aWU,471
17
- oagi-0.2.0.dist-info/METADATA,sha256=nk3a9mv2DvZ1LKEpV-1nHH1TEbrqKv8OALN_8LJ47tQ,2066
18
- oagi-0.2.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
19
- oagi-0.2.0.dist-info/licenses/LICENSE,sha256=sy5DLA2M29jFT4UfWsuBF9BAr3FnRkYtnAu6oDZiIf8,1075
20
- oagi-0.2.0.dist-info/RECORD,,
17
+ oagi-0.2.1.dist-info/METADATA,sha256=5W_aB_J2LUEyKAvE6G_iOcySv7tf0PWiGikOQe_K7l4,2066
18
+ oagi-0.2.1.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
19
+ oagi-0.2.1.dist-info/licenses/LICENSE,sha256=sy5DLA2M29jFT4UfWsuBF9BAr3FnRkYtnAu6oDZiIf8,1075
20
+ oagi-0.2.1.dist-info/RECORD,,
File without changes