|
14 | 14 | import org.opensearch.common.settings.Settings; |
15 | 15 | import org.opensearch.core.action.ActionListener; |
16 | 16 | import org.opensearch.core.xcontent.NamedXContentRegistry; |
17 | | -import org.opensearch.ingest.ConfigurationUtils; |
18 | 17 | import org.opensearch.ml.common.FunctionName; |
19 | 18 | import org.opensearch.ml.common.dataset.remote.RemoteInferenceInputDataSet; |
20 | 19 | import org.opensearch.ml.common.input.Input; |
@@ -131,50 +130,4 @@ private void processOutput(Object output, List<ModelTensor> modelTensors) { |
131 | 130 | modelTensors.add(ModelTensor.builder().name("response").result(result).build()); |
132 | 131 | } |
133 | 132 | } |
134 | | - |
135 | | - private void validateParameterTypes(String toolName, Map<String, String> parameters, Tool.Factory toolFactory) { |
136 | | - try { |
137 | | - for (Map.Entry<String, String> entry : parameters.entrySet()) { |
138 | | - String paramName = entry.getKey(); |
139 | | - String paramValue = entry.getValue(); |
140 | | - |
141 | | - if (!isValidParameterValue(paramName, paramValue)) { |
142 | | - throw new IllegalArgumentException( |
143 | | - "Invalid parameter value for '" + paramName + "' in tool '" + toolName + "': " + paramValue |
144 | | - ); |
145 | | - } |
146 | | - } |
147 | | - } catch (Exception e) { |
148 | | - log.error("Could not validate parameter types for tool: " + toolName, e); |
149 | | - if (e instanceof IllegalArgumentException) { |
150 | | - throw e; |
151 | | - } |
152 | | - } |
153 | | - } |
154 | | - |
155 | | - private boolean isValidParameterValue(String paramName, String paramValue) { |
156 | | - if (paramValue == null || paramValue.trim().isEmpty()) { |
157 | | - return false; |
158 | | - } |
159 | | - |
160 | | - try { |
161 | | - Map<String, Object> testConfig = new HashMap<>(); |
162 | | - testConfig.put(paramName, paramValue); |
163 | | - |
164 | | - if (paramValue.matches("^-?\\d+$")) { |
165 | | - ConfigurationUtils.readIntProperty("tool", "test", testConfig, paramName, 0); |
166 | | - } else if ("true".equalsIgnoreCase(paramValue) || "false".equalsIgnoreCase(paramValue)) { |
167 | | - ConfigurationUtils.readBooleanProperty("tool", "test", testConfig, paramName, false); |
168 | | - } else if (paramValue.matches("^-?\\d*\\.\\d+$")) { |
169 | | - ConfigurationUtils.readDoubleProperty("tool", "test", testConfig, paramName); |
170 | | - } else if (paramValue.startsWith("[") && paramValue.endsWith("]")) { |
171 | | - ConfigurationUtils.readOptionalList("tool", "test", testConfig, paramName); |
172 | | - } else if (paramValue.startsWith("{") && paramValue.endsWith("}")) { |
173 | | - ConfigurationUtils.readOptionalMap("tool", "test", testConfig, paramName); |
174 | | - } |
175 | | - return true; |
176 | | - } catch (Exception e) { |
177 | | - return false; |
178 | | - } |
179 | | - } |
180 | 133 | } |
0 commit comments