aruggero commented on code in PR #4259:
URL: https://github.com/apache/solr/pull/4259#discussion_r3033183645


##########
solr/modules/language-models/src/test-files/solr/collection1/conf/solrconfig-document-enrichment.xml:
##########
@@ -0,0 +1,235 @@
+<?xml version="1.0" ?>
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more 
contributor
+ license agreements. See the NOTICE file distributed with this work for 
additional
+ information regarding copyright ownership. The ASF licenses this file to
+ You under the Apache License, Version 2.0 (the "License"); you may not use
+ this file except in compliance with the License. You may obtain a copy of
+ the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
+ by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ OF ANY KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License. -->
+
+<config>
+    <luceneMatchVersion>${tests.luceneMatchVersion:LATEST}</luceneMatchVersion>
+ <dataDir>${solr.data.dir:}</dataDir>
+ <directoryFactory name="DirectoryFactory"
+                   class="${solr.directoryFactory:solr.MockDirectoryFactory}" 
/>
+ <schemaFactory class="ClassicIndexSchemaFactory" />
+
+ <requestDispatcher>
+   <requestParsers />
+ </requestDispatcher>
+
+ <query>
+  <filterCache class="solr.CaffeineCache" size="4096"
+   initialSize="2048" autowarmCount="0" />
+ </query>
+ <requestHandler name="/select" class="solr.SearchHandler" />
+
+ <updateHandler class="solr.DirectUpdateHandler2">
+  <autoCommit>
+   <maxTime>15000</maxTime>
+   <openSearcher>false</openSearcher>
+  </autoCommit>
+  <autoSoftCommit>
+   <maxTime>1000</maxTime>
+  </autoSoftCommit>
+  <updateLog>
+   <str name="dir">${solr.data.dir:}</str>
+  </updateLog>
+ </updateHandler>
+
+ <requestHandler name="/query" class="solr.SearchHandler">
+  <lst name="defaults">
+   <str name="echoParams">explicit</str>
+   <str name="wt">json</str>
+   <str name="indent">true</str>
+   <str name="df">id</str>
+  </lst>
+ </requestHandler>
+
+ <updateRequestProcessorChain name="documentEnrichment">
+  <processor 
class="solr.languagemodels.documentenrichment.update.processor.DocumentEnrichmentUpdateProcessorFactory">
+   <str name="inputField">string_field</str>
+   <str name="outputField">enriched_field</str>
+   <str name="prompt">Summarize this content: {string_field}</str>
+   <str name="model">dummy-chat-1</str>
+  </processor>
+  <processor class="solr.RunUpdateProcessorFactory"/>
+ </updateRequestProcessorChain>
+
+ <updateRequestProcessorChain name="failingDocumentEnrichment">
+  <processor 
class="solr.languagemodels.documentenrichment.update.processor.DocumentEnrichmentUpdateProcessorFactory">
+   <str name="inputField">string_field</str>
+   <str name="outputField">enriched_field</str>
+   <str name="prompt">Summarize this content: {string_field}</str>
+   <str name="model">exception-throwing-chat-model</str>
+  </processor>
+  <processor class="solr.RunUpdateProcessorFactory"/>
+ </updateRequestProcessorChain>
+
+ <updateRequestProcessorChain name="documentEnrichmentForPartialUpdates">
+  <processor class="solr.DistributedUpdateProcessorFactory"/>
+  <processor 
class="solr.languagemodels.documentenrichment.update.processor.DocumentEnrichmentUpdateProcessorFactory">
+   <str name="inputField">string_field</str>
+   <str name="outputField">enriched_field</str>
+   <str name="prompt">Summarize this content: {string_field}</str>
+   <str name="model">dummy-chat-1</str>
+  </processor>
+  <processor class="solr.RunUpdateProcessorFactory"/>
+ </updateRequestProcessorChain>
+
+ <updateRequestProcessorChain name="documentEnrichmentMultiField">
+  <processor 
class="solr.languagemodels.documentenrichment.update.processor.DocumentEnrichmentUpdateProcessorFactory">
+   <str name="inputField">string_field</str>
+   <str name="inputField">body_field</str>
+   <str name="outputField">enriched_field</str>
+   <str name="prompt">Title: {string_field}. Body: {body_field}.</str>
+   <str name="model">dummy-chat-1</str>
+  </processor>
+  <processor class="solr.RunUpdateProcessorFactory"/>
+ </updateRequestProcessorChain>
+
+ <updateRequestProcessorChain name="documentEnrichmentMultivaluedString">
+  <processor 
class="solr.languagemodels.documentenrichment.update.processor.DocumentEnrichmentUpdateProcessorFactory">
+   <str name="inputField">string_field</str>
+   <str name="outputField">enriched_field_multi</str>
+   <str name="prompt">Extract tags from: {string_field}</str>
+   <str name="model">dummy-chat-multivalued-1</str>
+  </processor>
+  <processor class="solr.RunUpdateProcessorFactory"/>
+ </updateRequestProcessorChain>
+
+ <updateRequestProcessorChain name="failingDocumentEnrichmentMultiField">

Review Comment:
   Difference with failingDocumentEnrichment?



##########
solr/modules/language-models/src/test/org/apache/solr/languagemodels/documentenrichment/update/processor/DocumentEnrichmentUpdateProcessorFactoryTest.java:
##########
@@ -0,0 +1,422 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.languagemodels.documentenrichment.update.processor;
+
+import java.util.List;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.languagemodels.TestLanguageModelBase;
+import org.apache.solr.languagemodels.documentenrichment.model.SolrChatModel;
+import 
org.apache.solr.languagemodels.documentenrichment.store.rest.ManagedChatModelStore;
+import org.apache.solr.request.SolrQueryRequestBase;
+import org.apache.solr.update.processor.UpdateRequestProcessor;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class DocumentEnrichmentUpdateProcessorFactoryTest extends 
TestLanguageModelBase {

Review Comment:
   Add a test for a not-supported output field type (dense vector is present, 
but the other fields of the other exception are not)



##########
solr/modules/language-models/src/test/org/apache/solr/languagemodels/documentenrichment/store/rest/TestChatModelManagerPersistence.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.languagemodels.documentenrichment.store.rest;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import org.apache.solr.common.util.Utils;
+import org.apache.solr.languagemodels.TestLanguageModelBase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestChatModelManagerPersistence extends TestLanguageModelBase {
+
+  @Before
+  public void init() throws Exception {
+    setupTest("solrconfig-document-enrichment.xml", 
"schema-language-models.xml", false, true);
+  }
+
+  @After
+  public void cleanup() throws Exception {
+    afterTest();
+  }
+
+  @Test
+  public void testModelAreStoredCompact() throws Exception {
+    loadChatModel("openai-model.json");
+
+    final String JSONOnDisk = Files.readString(chatModelStoreFile, 
StandardCharsets.UTF_8);
+    Object objectFromDisk = Utils.fromJSONString(JSONOnDisk);
+    assertEquals(new String(Utils.toJSON(objectFromDisk, -1), UTF_8), 
JSONOnDisk);
+  }
+
+  @Test
+  public void testModelStorePersistence() throws Exception {
+    // check store is empty at start
+    assertJQ(ManagedChatModelStore.REST_END_POINT, "/models/==[]");
+
+    // load a model
+    loadChatModel("openai-model.json");
+
+    final String modelName = "openai-1";
+    assertJQ(ManagedChatModelStore.REST_END_POINT, "/models/[0]/name=='" + 
modelName + "'");
+    assertJQ(
+        ManagedChatModelStore.REST_END_POINT,
+        "/models/[0]/params/baseUrl=='https://api.openai.com/v1'");
+    assertJQ(
+        ManagedChatModelStore.REST_END_POINT, 
"/models/[0]/params/apiKey=='apiKey-openAI'");
+    assertJQ(
+        ManagedChatModelStore.REST_END_POINT, 
"/models/[0]/params/modelName=='gpt-5.4-nano'");
+    assertJQ(ManagedChatModelStore.REST_END_POINT, 
"/models/[0]/params/timeout==60");
+    assertJQ(ManagedChatModelStore.REST_END_POINT, 
"/models/[0]/params/logRequests==true");
+    assertJQ(ManagedChatModelStore.REST_END_POINT, 
"/models/[0]/params/logResponses==true");
+    assertJQ(ManagedChatModelStore.REST_END_POINT, 
"/models/[0]/params/maxRetries==5");
+
+    // check persistence after reload
+    restTestHarness.reload();
+    assertJQ(ManagedChatModelStore.REST_END_POINT, "/models/[0]/name=='" + 
modelName + "'");

Review Comment:
   What about the other params?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to