File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/llama/request/embeddings Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+ * or more contributor license agreements. Licensed under the Elastic License
4+ * 2.0; you may not use this file except in compliance with the Elastic License
5+ * 2.0.
6+ */
7+
8+ package org .elasticsearch .xpack .inference .services .llama .request .embeddings ;
9+
10+ import org .elasticsearch .common .Strings ;
11+ import org .elasticsearch .common .xcontent .XContentHelper ;
12+ import org .elasticsearch .test .ESTestCase ;
13+ import org .elasticsearch .xcontent .XContentBuilder ;
14+ import org .elasticsearch .xcontent .XContentFactory ;
15+ import org .elasticsearch .xcontent .XContentType ;
16+
17+ import java .io .IOException ;
18+ import java .util .List ;
19+
20+ import static org .hamcrest .CoreMatchers .is ;
21+
22+ public class LlamaEmbeddingsRequestEntityTests extends ESTestCase {
23+
24+ public void testXContent_Success () throws IOException {
25+ var entity = new LlamaEmbeddingsRequestEntity ("llama-embed" , List .of ("ABDC" ));
26+
27+ XContentBuilder builder = XContentFactory .contentBuilder (XContentType .JSON );
28+ entity .toXContent (builder , null );
29+ String xContentResult = Strings .toString (builder );
30+
31+ assertThat (xContentResult , is (XContentHelper .stripWhitespace ("""
32+ {
33+ "model_id": "llama-embed",
34+ "contents": ["ABDC"]
35+ }
36+ """ )));
37+ }
38+ }
You can’t perform that action at this time.
0 commit comments