This commit is contained in:
jiangbo721 2025-03-21 12:48:36 +08:00 committed by GitHub
commit 139e4870b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
23 changed files with 50 additions and 3 deletions

View File

@ -191,8 +191,18 @@ class LLMNode(BaseNode[LLMNodeData]):
# deduct quota
self.deduct_llm_quota(tenant_id=self.tenant_id, model_instance=model_instance, usage=usage)
break
outputs = {"text": result_text, "usage": jsonable_encoder(usage), "finish_reason": finish_reason}
outputs = {
"text": result_text,
"usage": jsonable_encoder(usage),
"finish_reason": finish_reason,
"json": {},
}
if model_config.parameters.get("response_format") in ["json_object", "JSON"]:
try:
result_dict = json.loads(result_text)
except:
result_dict = {}
outputs.update({"json": result_dict})
yield RunCompletedEvent(
run_result=NodeRunResult(
status=WorkflowNodeExecutionStatus.SUCCEEDED,

View File

@ -139,7 +139,16 @@ const formatItem = (
}
case BlockEnum.LLM: {
res.vars = LLM_OUTPUT_STRUCT
res.vars = [
...LLM_OUTPUT_STRUCT,
...(['json_object', 'JSON'].includes(data.model?.completion_params?.response_format)
? [{
variable: 'json',
type: VarType.object,
}]
: []),
]
break
}

View File

@ -289,6 +289,14 @@ const Panel: FC<NodePanelProps<LLMNodeType>> = ({
type='string'
description={t(`${i18nPrefix}.outputVars.output`)}
/>
{['json_object', 'JSON'].includes(model?.completion_params?.response_format)
&& (
<VarItem
name="json"
type="object"
description={t(`${i18nPrefix}.outputVars.json`)}
/>
)}
</>
</OutputVars>
{isShowSingleRun && (

View File

@ -399,6 +399,7 @@ const translation = {
outputVars: {
output: 'Generierter Inhalt',
usage: 'Nutzungsinformationen des Modells',
json: 'Generierter Inhalt JSON',
},
singleRun: {
variable: 'Variable',

View File

@ -412,6 +412,7 @@ const translation = {
outputVars: {
output: 'Generate content',
usage: 'Model Usage Information',
json: 'Generate content JSON',
},
singleRun: {
variable: 'Variable',

View File

@ -399,6 +399,7 @@ const translation = {
outputVars: {
output: 'Generar contenido',
usage: 'Información de uso del modelo',
json: 'Generar contenido JSON',
},
singleRun: {
variable: 'Variable',

View File

@ -399,6 +399,7 @@ const translation = {
outputVars: {
output: 'تولید محتوا',
usage: 'اطلاعات استفاده از مدل',
json: 'تولید محتوا JSON',
},
singleRun: {
variable: 'متغیر',

View File

@ -399,6 +399,7 @@ const translation = {
outputVars: {
output: 'Contenu généré',
usage: 'Informations sur l\'utilisation du modèle',
json: 'Contenu généré JSON',
},
singleRun: {
variable: 'Variable',

View File

@ -412,6 +412,7 @@ const translation = {
outputVars: {
output: 'सामग्री उत्पन्न करें',
usage: 'मॉडल उपयोग जानकारी',
json: 'सामग्री उत्पन्न करें JSON',
},
singleRun: {
variable: 'वेरिएबल',

View File

@ -416,6 +416,7 @@ const translation = {
outputVars: {
output: 'Genera contenuto',
usage: 'Informazioni sull\'utilizzo del modello',
json: 'Genera contenuto JSON',
},
singleRun: {
variable: 'Variabile',

View File

@ -399,6 +399,7 @@ const translation = {
outputVars: {
output: 'コンテンツを生成',
usage: 'モデルの使用情報',
json: 'コンテンツを生成 JSON',
},
singleRun: {
variable: '変数',

View File

@ -399,6 +399,7 @@ const translation = {
outputVars: {
output: '생성된 내용',
usage: '모델 사용 정보',
json: '생성된 내용 JSON',
},
singleRun: {
variable: '변수',

View File

@ -399,6 +399,7 @@ const translation = {
outputVars: {
output: 'Generowana treść',
usage: 'Informacje o użyciu modelu',
json: 'Generowana treść JSON',
},
singleRun: {
variable: 'Zmienna',

View File

@ -399,6 +399,7 @@ const translation = {
outputVars: {
output: 'Conteúdo gerado',
usage: 'Informações de uso do modelo',
json: 'Conteúdo gerado JSON',
},
singleRun: {
variable: 'Variável',

View File

@ -399,6 +399,7 @@ const translation = {
outputVars: {
output: 'Conținut generat',
usage: 'Informații de utilizare a modelului',
json: 'Conținut generat JSON',
},
singleRun: {
variable: 'Variabilă',

View File

@ -399,6 +399,7 @@ const translation = {
outputVars: {
output: 'Создать контент',
usage: 'Информация об использовании модели',
json: 'Создать контент JSON',
},
singleRun: {
variable: 'Переменная',

View File

@ -348,6 +348,7 @@ const translation = {
outputVars: {
output: 'Generirana vsebina',
usage: 'Podatki o uporabi modela',
json: 'Generirana vsebina JSON',
},
singleRun: {
variable: 'Spremenljivka',

View File

@ -399,6 +399,7 @@ const translation = {
outputVars: {
output: 'สร้างเนื้อหา',
usage: 'ข้อมูลการใช้งานรุ่น',
json: 'สร้างเนื้อหา JSON',
},
singleRun: {
variable: 'ตัวแปร',

View File

@ -399,6 +399,7 @@ const translation = {
outputVars: {
output: 'İçerik Üret',
usage: 'Model Kullanım Bilgileri',
json: 'İçerik Üret JSON',
},
singleRun: {
variable: 'Değişken',

View File

@ -399,6 +399,7 @@ const translation = {
outputVars: {
output: 'Генерований вміст',
usage: 'Інформація про використання моделі',
json: 'Генерований вміст JSON',
},
singleRun: {
variable: 'Змінна',

View File

@ -399,6 +399,7 @@ const translation = {
outputVars: {
output: 'Nội dung được tạo',
usage: 'Thông tin sử dụng mô hình',
json: 'Nội dung được tạo JSON',
},
singleRun: {
variable: 'Biến',

View File

@ -413,6 +413,7 @@ const translation = {
outputVars: {
output: '生成内容',
usage: '模型用量信息',
json: '生成内容 JSON',
},
singleRun: {
variable: '变量',

View File

@ -401,6 +401,7 @@ const translation = {
outputVars: {
output: '生成內容',
usage: '模型用量信息',
json: '生成內容 JSON',
},
singleRun: {
variable: '變量',