|
| 1 | +meta { |
| 2 | + name: Create Embedding |
| 3 | + type: http |
| 4 | + seq: 4 |
| 5 | +} |
| 6 | + |
| 7 | +post { |
| 8 | + url: {{baseUrl}}/v1/embeddings |
| 9 | + body: json |
| 10 | + auth: inherit |
| 11 | +} |
| 12 | + |
| 13 | +body:json { |
| 14 | + { |
| 15 | + "model": "{{embedding_model}}", |
| 16 | + "input": "OGX functional test embedding", |
| 17 | + "encoding_format": "float" |
| 18 | + } |
| 19 | +} |
| 20 | + |
| 21 | +tests { |
| 22 | + test("Status is 200", function() { |
| 23 | + expect(res.getStatus()).to.eql(200); |
| 24 | + }); |
| 25 | + test("Response has data array", function() { |
| 26 | + const body = res.getBody(); |
| 27 | + expect(body).to.have.property("data"); |
| 28 | + expect(body.data).to.be.an("array"); |
| 29 | + expect(body.data.length).to.be.greaterThan(0); |
| 30 | + }); |
| 31 | + test("First embedding has correct structure", function() { |
| 32 | + const item = res.getBody().data[0]; |
| 33 | + expect(item).to.have.property("embedding"); |
| 34 | + expect(item.embedding).to.be.an("array"); |
| 35 | + expect(item.embedding.length).to.be.greaterThan(0); |
| 36 | + }); |
| 37 | + test("Embedding dimension matches configured value", function() { |
| 38 | + const item = res.getBody().data[0]; |
| 39 | + const expectedDim = Number(bru.getEnvVar("embedding_dimension")); |
| 40 | + expect(Number.isSafeInteger(expectedDim)).to.eql(true); |
| 41 | + expect(expectedDim).to.be.greaterThan(0); |
| 42 | + expect(item.embedding.length).to.eql(expectedDim); |
| 43 | + }); |
| 44 | + test("Response model matches configured embedding model", function() { |
| 45 | + const body = res.getBody(); |
| 46 | + expect(body).to.have.property("model"); |
| 47 | + expect(body.model).to.eql(bru.getEnvVar("embedding_model")); |
| 48 | + }); |
| 49 | +} |
0 commit comments