Skip to content
File

Blob: src/cloudflare/internal/test/autorag/autorag-api-test.js

javascript31 lines
1// Copyright (c) 2025 Cloudflare, Inc.
2// Licensed under the Apache 2.0 license found in the LICENSE file or at:
3// https://opensource.org/licenses/Apache-2.0
4 
5import * as assert from 'node:assert';
6 
7export const tests = {
8 async test(_, env) {
9 {
10 // Test search method
11 const resp = await env.ai
12 .autorag('my-rag')
13 .search({ query: 'example query' });
14 
15 assert.deepEqual(
16 resp.data[0].content[0].text,
17 'According to the latest regulations, each passenger is allowed to carry up to two woodchucks.'
18 );
19 }
20 
21 {
22 // Test ai search method
23 const resp = await env.ai
24 .autorag('my-rag')
25 .aiSearch({ query: 'example query' });
26 
27 assert.deepEqual(resp.response, 'this is an example result');
28 }
29 },
30};