Skip to content

Commit

Permalink
[Feature][Transforms-V2] LLM transforms Support custom field name
Browse files Browse the repository at this point in the history
  • Loading branch information
hawk9821 committed Sep 13, 2024
1 parent 4dae15c commit 5793222
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 23 deletions.
4 changes: 2 additions & 2 deletions docs/en/transform-v2/llm.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ more.
## Options

| name | type | required | default value |
|------------------------| ------ | -------- | ------------- |
|------------------------| ------ | -------- |---------------|
| model_provider | enum | yes | |
| output_data_type | enum | no | String |
| output_column_name | string | no | String |
| output_column_name | string | no | llm_output |
| prompt | string | yes | |
| inference_columns | list | no | |
| model | string | yes | |
Expand Down
28 changes: 14 additions & 14 deletions docs/zh/transform-v2/llm.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@

## 属性

| 名称 | 类型 | 是否必须 | 默认值 |
|------------------------| ------ | -------- |--------|
| model_provider | enum | yes | |
| output_data_type | enum | no | String |
| output_column_name | string | no | |
| prompt | string | yes | |
| inference_columns | list | no | |
| model | string | yes | |
| api_key | string | yes | |
| api_path | string | no | |
| custom_config | map | no | |
| custom_response_parse | string | no | |
| custom_request_headers | map | no | |
| custom_request_body | map | no | |
| 名称 | 类型 | 是否必须 | 默认值 |
|------------------------| ------ | -------- |-------------|
| model_provider | enum | yes | |
| output_data_type | enum | no | String |
| output_column_name | string | no | llm_output |
| prompt | string | yes | |
| inference_columns | list | no | |
| model | string | yes | |
| api_key | string | yes | |
| api_path | string | no | |
| custom_config | map | no | |
| custom_response_parse | string | no | |
| custom_request_headers | map | no | |
| custom_request_body | map | no | |

### model_provider

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
import org.apache.seatunnel.transform.nlpmodel.llm.remote.custom.CustomModel;
import org.apache.seatunnel.transform.nlpmodel.llm.remote.openai.OpenAIModel;

import org.apache.commons.lang3.StringUtils;

import lombok.NonNull;
import lombok.SneakyThrows;

Expand Down Expand Up @@ -147,10 +145,7 @@ protected Column getOutputColumn() {
boolean isExist = Arrays.asList(fieldNames).contains(customFieldName);
if (isExist) {
throw new IllegalArgumentException(
String.format("Field name %s already exists", customFieldName));
}
if (StringUtils.isEmpty(customFieldName)) {
customFieldName = "llm_output";
String.format("llm inference field name %s already exists", customFieldName));
}
return PhysicalColumn.of(
customFieldName, outputDataType, (Long) null, true, null, "Output column of LLM");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class LLMTransformConfig extends ModelTransformConfig {
public static final Option<String> OUTPUT_COLUMN_NAME =
Options.key("output_column_name")
.stringType()
.noDefaultValue()
.defaultValue("llm_output")
.withDescription("custom field name for the llm output data");

public static final Option<Integer> INFERENCE_BATCH_SIZE =
Expand Down

0 comments on commit 5793222

Please sign in to comment.