coze_lab 0.1.46 → 0.1.47
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.
package/package.json
CHANGED
|
@@ -107,6 +107,36 @@ _OTEL_SUFFIX = "/v1/loop/opentelemetry"
|
|
|
107
107
|
_DEFAULT_WORKSPACE_ID = "7649231955045072915" # hardcoded spaceID fallback
|
|
108
108
|
|
|
109
109
|
|
|
110
|
+
def _normalize_api_base_url(raw: str) -> str:
|
|
111
|
+
"""Normalize CozeLoop API/OTLP endpoint env vars to the SDK api_base_url."""
|
|
112
|
+
base = (raw or "").strip().rstrip("/")
|
|
113
|
+
if not base:
|
|
114
|
+
return ""
|
|
115
|
+
suffixes = [
|
|
116
|
+
"/api/v1/loop/traces/ingest",
|
|
117
|
+
"/v1/loop/traces/ingest",
|
|
118
|
+
"/api/v1/loop/opentelemetry/v1/traces",
|
|
119
|
+
"/v1/loop/opentelemetry/v1/traces",
|
|
120
|
+
"/api/v1/loop/opentelemetry",
|
|
121
|
+
"/v1/loop/opentelemetry",
|
|
122
|
+
"/api/v1",
|
|
123
|
+
"/v1",
|
|
124
|
+
]
|
|
125
|
+
for suffix in suffixes:
|
|
126
|
+
if base.endswith(suffix):
|
|
127
|
+
return base[:-len(suffix)].rstrip("/")
|
|
128
|
+
return base
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def get_api_base_url() -> str:
|
|
132
|
+
"""Return optional CozeLoop SDK api_base_url from onboard-injected env."""
|
|
133
|
+
return _normalize_api_base_url(
|
|
134
|
+
os.environ.get("COZELOOP_API_BASE_URL")
|
|
135
|
+
or os.environ.get("OTEL_ENDPOINT")
|
|
136
|
+
or ""
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
|
|
110
140
|
# --- coze-context parsing -------------------------------------------------
|
|
111
141
|
# User messages may embed a block like:
|
|
112
142
|
# <coze-context>
|
|
@@ -133,6 +133,36 @@ else:
|
|
|
133
133
|
DEBUG = os.environ.get("CC_COZELOOP_DEBUG", "").lower() == "true"
|
|
134
134
|
|
|
135
135
|
|
|
136
|
+
def _normalize_api_base_url(raw: str) -> str:
|
|
137
|
+
"""Normalize CozeLoop API/OTLP endpoint env vars to the SDK api_base_url."""
|
|
138
|
+
base = (raw or "").strip().rstrip("/")
|
|
139
|
+
if not base:
|
|
140
|
+
return ""
|
|
141
|
+
suffixes = [
|
|
142
|
+
"/api/v1/loop/traces/ingest",
|
|
143
|
+
"/v1/loop/traces/ingest",
|
|
144
|
+
"/api/v1/loop/opentelemetry/v1/traces",
|
|
145
|
+
"/v1/loop/opentelemetry/v1/traces",
|
|
146
|
+
"/api/v1/loop/opentelemetry",
|
|
147
|
+
"/v1/loop/opentelemetry",
|
|
148
|
+
"/api/v1",
|
|
149
|
+
"/v1",
|
|
150
|
+
]
|
|
151
|
+
for suffix in suffixes:
|
|
152
|
+
if base.endswith(suffix):
|
|
153
|
+
return base[:-len(suffix)].rstrip("/")
|
|
154
|
+
return base
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def get_api_base_url() -> str:
|
|
158
|
+
"""Return optional CozeLoop SDK api_base_url from onboard-injected env."""
|
|
159
|
+
return _normalize_api_base_url(
|
|
160
|
+
os.environ.get("COZELOOP_API_BASE_URL")
|
|
161
|
+
or os.environ.get("OTEL_ENDPOINT")
|
|
162
|
+
or ""
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
|
|
136
166
|
def _log_file_path() -> str:
|
|
137
167
|
return os.environ.get("COZELOOP_HOOK_LOG", "").strip()
|
|
138
168
|
|