chore: rename raw_json outputs to data
This commit is contained in:
@@ -1808,7 +1808,7 @@
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "raw_json",
|
||||
"name": "data",
|
||||
"type": "STRING",
|
||||
"links": null
|
||||
},
|
||||
@@ -2963,4 +2963,4 @@
|
||||
"VHS_KeepIntermediate": true
|
||||
},
|
||||
"version": 0.4
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -15,7 +15,6 @@ def _fetch_remaining_credits(api_key: str) -> Tuple[str, int]:
|
||||
except requests.RequestException as exc:
|
||||
raise RuntimeError(f"Failed to call remaining credits endpoint: {exc}") from exc
|
||||
|
||||
raw_text = response.text
|
||||
try:
|
||||
payload: Any = response.json()
|
||||
except json.JSONDecodeError as exc:
|
||||
@@ -33,7 +32,8 @@ def _fetch_remaining_credits(api_key: str) -> Tuple[str, int]:
|
||||
except (TypeError, ValueError) as exc:
|
||||
raise RuntimeError("Remaining credits value is not an integer.") from exc
|
||||
|
||||
return raw_text, credits_remaining
|
||||
formatted_json = json.dumps(payload, indent=2, ensure_ascii=False)
|
||||
return formatted_json, credits_remaining
|
||||
|
||||
|
||||
def _log_remaining_credits(log: bool, record_data: dict[str, Any], api_key: str, log_fn) -> None:
|
||||
|
||||
@@ -33,6 +33,15 @@ def _parse_json_optional(raw: str | None, label: str) -> Any | None:
|
||||
raise RuntimeError(f"{label} is not valid JSON.") from exc
|
||||
|
||||
|
||||
def _format_json_for_output(payload: Any) -> str:
|
||||
if payload is None:
|
||||
return ""
|
||||
try:
|
||||
return json.dumps(payload, indent=2, ensure_ascii=False)
|
||||
except TypeError:
|
||||
return json.dumps(payload, indent=2, ensure_ascii=False, default=str)
|
||||
|
||||
|
||||
def _normalize_messages(
|
||||
prompt: str,
|
||||
messages_json: str | None,
|
||||
@@ -88,7 +97,7 @@ def run_gemini3_pro_chat(
|
||||
"""Run a Gemini 3 Pro chat completion request.
|
||||
|
||||
Returns:
|
||||
(content_text, reasoning_text, raw_json)
|
||||
(content_text, reasoning_text, data_json)
|
||||
"""
|
||||
if model not in CHAT_COMPLETIONS_URLS:
|
||||
raise RuntimeError("Invalid model. Use the pinned enum options.")
|
||||
@@ -198,7 +207,7 @@ def run_gemini3_pro_chat(
|
||||
message = (choices[0].get("message") or {})
|
||||
content = message.get("content") or ""
|
||||
reasoning = message.get("reasoning_content") or ""
|
||||
return (str(content), str(reasoning), json.dumps(payload_json))
|
||||
return (str(content), str(reasoning), _format_json_for_output(payload_json))
|
||||
|
||||
content_parts: list[str] = []
|
||||
reasoning_parts: list[str] = []
|
||||
@@ -233,7 +242,7 @@ def run_gemini3_pro_chat(
|
||||
|
||||
content_text = "".join(content_parts)
|
||||
reasoning_text = "".join(reasoning_parts)
|
||||
raw_json = json.dumps(last_payload) if last_payload is not None else ""
|
||||
raw_json = _format_json_for_output(last_payload) if last_payload is not None else ""
|
||||
|
||||
if log:
|
||||
_log(log, f"{model} response length: {len(content_text)} chars")
|
||||
|
||||
+18
-2
@@ -23,6 +23,22 @@ FAIL_STATES = {
|
||||
}
|
||||
|
||||
|
||||
def _format_record_for_output(record: dict[str, Any]) -> str:
|
||||
try:
|
||||
record_copy = json.loads(json.dumps(record))
|
||||
except TypeError:
|
||||
record_copy = dict(record)
|
||||
|
||||
param_value = record_copy.get("param")
|
||||
if isinstance(param_value, str):
|
||||
try:
|
||||
record_copy["param"] = json.loads(param_value)
|
||||
except json.JSONDecodeError:
|
||||
record_copy["param"] = param_value
|
||||
|
||||
return json.dumps(record_copy, indent=2, ensure_ascii=False, default=str)
|
||||
|
||||
|
||||
def _validate_length(field_name: str, value: str | None, max_len: int) -> None:
|
||||
if value is None:
|
||||
return
|
||||
@@ -163,7 +179,7 @@ def run_suno_generate(
|
||||
timeout_s: int = 1800,
|
||||
log: bool = True,
|
||||
) -> tuple[dict, str]:
|
||||
"""Create a Suno music generation task and return audio output + raw record-info JSON."""
|
||||
"""Create a Suno music generation task and return audio output + formatted record-info JSON."""
|
||||
if model not in MODEL_OPTIONS:
|
||||
raise RuntimeError("Invalid model. Use the pinned enum options.")
|
||||
if vocal_gender and vocal_gender not in VOCAL_GENDER_OPTIONS:
|
||||
@@ -280,4 +296,4 @@ def run_suno_generate(
|
||||
waveform = audio_output.get("waveform")
|
||||
shape = getattr(waveform, "shape", None)
|
||||
_log(log, f"Suno audio waveform shape: {shape}")
|
||||
return audio_output, json.dumps(record)
|
||||
return audio_output, _format_record_for_output(record)
|
||||
|
||||
@@ -69,6 +69,7 @@ Inputs:
|
||||
- (none)
|
||||
|
||||
Outputs:
|
||||
- STRING: data
|
||||
- INT: Remaining credits
|
||||
Notes:
|
||||
- If your key is missing/invalid, this node errors.
|
||||
@@ -78,7 +79,7 @@ Notes:
|
||||
return {"required": {"log": ("BOOLEAN", {"default": True})}}
|
||||
|
||||
RETURN_TYPES = ("STRING", "INT")
|
||||
RETURN_NAMES = ("raw_json", "credits_remaining")
|
||||
RETURN_NAMES = ("data", "credits_remaining")
|
||||
FUNCTION = "get_remaining_credits"
|
||||
CATEGORY = "kie/api"
|
||||
|
||||
@@ -659,7 +660,7 @@ Inputs:
|
||||
Outputs:
|
||||
- STRING: Assistant response text
|
||||
- STRING: Reasoning text (empty if include_thoughts is false)
|
||||
- STRING: Raw JSON from last response chunk
|
||||
- STRING: data (formatted JSON from last response chunk)
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
@@ -685,7 +686,7 @@ Outputs:
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("STRING", "STRING", "STRING")
|
||||
RETURN_NAMES = ("text", "reasoning", "raw_json")
|
||||
RETURN_NAMES = ("text", "reasoning", "data")
|
||||
FUNCTION = "generate"
|
||||
CATEGORY = "kie/api"
|
||||
|
||||
@@ -744,7 +745,7 @@ Optional:
|
||||
|
||||
Outputs:
|
||||
- AUDIO: Generated audio
|
||||
- STRING: raw_json
|
||||
- STRING: data
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
@@ -766,7 +767,7 @@ Outputs:
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("AUDIO", "STRING")
|
||||
RETURN_NAMES = ("audio", "raw_json")
|
||||
RETURN_NAMES = ("audio", "data")
|
||||
FUNCTION = "generate"
|
||||
CATEGORY = "kie/api"
|
||||
|
||||
@@ -819,7 +820,7 @@ Optional:
|
||||
|
||||
Outputs:
|
||||
- AUDIO: Generated audio
|
||||
- STRING: raw_json
|
||||
- STRING: data
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
@@ -844,7 +845,7 @@ Outputs:
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("AUDIO", "STRING")
|
||||
RETURN_NAMES = ("audio", "raw_json")
|
||||
RETURN_NAMES = ("audio", "data")
|
||||
FUNCTION = "generate"
|
||||
CATEGORY = "kie/api"
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ Optional:
|
||||
|
||||
## Outputs
|
||||
- **audio** (AUDIO): Generated audio.
|
||||
- **raw_json** (STRING): Full API response JSON.
|
||||
- **data** (STRING): Full API response JSON (formatted).
|
||||
|
||||
## Notes
|
||||
- Non-custom mode expects **prompt only** (500 chars max); other fields should be empty.
|
||||
|
||||
@@ -17,7 +17,7 @@ Optional:
|
||||
|
||||
## Outputs
|
||||
- **audio** (AUDIO): Generated audio.
|
||||
- **raw_json** (STRING): Full API response JSON.
|
||||
- **data** (STRING): Full API response JSON (formatted).
|
||||
|
||||
## Notes
|
||||
- Non-custom mode expects **prompt only** (500 chars max); other fields should be empty.
|
||||
|
||||
Reference in New Issue
Block a user