Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature][seatunnel-transforms-v2] LLM transform Support Ollama return format #8550 #8551

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import com.jayway.jsonpath.JsonPath;

import java.io.IOException;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -94,8 +95,15 @@ protected List<String> chatWithModel(String promptWithLimit, String rowsJson)
if (response.getStatusLine().getStatusCode() != 200) {
throw new IOException("Failed to get vector from custom, response: " + responseStr);
}
return OBJECT_MAPPER.convertValue(
parseResponse(responseStr), new TypeReference<List<String>>() {});
try {
return OBJECT_MAPPER.convertValue(
parseResponse(responseStr), new TypeReference<List<String>>() {});
} catch (Exception e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to specify the error here?
eg:
try { return OBJECT_MAPPER.convertValue( parseResponse(responseStr), new TypeReference<List<String>>() {}); } catch (IllegalArgumentException or xxxx e) { try { String result = OBJECT_MAPPER.convertValue( parseResponse(responseStr), new TypeReference<String>() {}); return Collections.singletonList(result); } catch (Exception ex) { xxxxx } }

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that better,but origin code were not handling exception here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get

String result =
OBJECT_MAPPER.convertValue(
parseResponse(responseStr), new TypeReference<String>() {});
return Collections.singletonList(result);
}
}

@VisibleForTesting
Expand Down
Loading