Skip to content

Commit

Permalink
fix import.meta.resolve() issue
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonTian committed Apr 1, 2024
1 parent 82b657a commit a607735
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# The Node.js library and CLI for Moonshot AI

- [![Node.js CI](https://github.com/JacksonTian/kimi/actions/workflows/test.yaml/badge.svg)](https://github.com/JacksonTian/kimi/actions/workflows/test.yaml)

## Installation/安装

```sh
Expand Down
11 changes: 8 additions & 3 deletions test/kimi.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import Kimi from '../lib/kimi.js';
import assert from 'assert';
import path from 'path';
import { readAsSSE } from 'httpx';
import { fileURLToPath } from 'url';

import Kimi from '../lib/kimi.js';

const KIMI_API_KEY = process.env.KIMI_API_KEY;

const __dirname = path.dirname(fileURLToPath(import.meta.url));

describe('kimi', () => {
it('chat should ok', async function () {
this.timeout(60000);
Expand Down Expand Up @@ -37,7 +41,8 @@ describe('kimi', () => {
result.data.forEach((d) => {
assert.strictEqual(d.status, 'ok');
});
const fileResult = await client.putFile(fileURLToPath(import.meta.resolve('./figures/1906.08237.pdf')), 'file-extract');

const fileResult = await client.putFile(path.join(__dirname, './figures/1906.08237.pdf'), 'file-extract');
assert.deepStrictEqual(fileResult.bytes, 761790);
assert.strictEqual(fileResult.status, 'ok');
const id = fileResult.id;
Expand All @@ -56,7 +61,7 @@ describe('kimi', () => {
});

try {
await client.putFile(fileURLToPath(import.meta.resolve('./figures/invalid_format.txt')), 'file-extract');
await client.putFile(path.join(__dirname, './figures/invalid_format.txt'), 'file-extract');
} catch (ex) {
assert.strictEqual(ex.message, 'server_error: failed to extract file: unexpected status code: 400, body: {"error_type":"file.no_content","message":"没有解析出内容"}');
return;
Expand Down

0 comments on commit a607735

Please sign in to comment.