From a02280fd292365b2ffc383d3040c5cd68f72151b Mon Sep 17 00:00:00 2001 From: Evans Date: Tue, 5 Mar 2024 18:06:06 +0800 Subject: [PATCH] :green_heart: Fix CI --- .npmignore | 3 ++- examples/examples.md | 49 ++++++++++++++++++++++++++++++++++++++++++++ examples/index.ts | 46 ----------------------------------------- jest.config.js | 1 - tsconfig.json | 2 +- 5 files changed, 52 insertions(+), 49 deletions(-) create mode 100644 examples/examples.md delete mode 100644 examples/index.ts diff --git a/.npmignore b/.npmignore index 4f3b242..a2f18eb 100644 --- a/.npmignore +++ b/.npmignore @@ -1,5 +1,5 @@ examples -node_modules +node_modules/* .github/ .vscode/ .env @@ -8,3 +8,4 @@ tsconfig.json .npmignore .gitignore jest.config.js +lib \ No newline at end of file diff --git a/examples/examples.md b/examples/examples.md new file mode 100644 index 0000000..dd4b83b --- /dev/null +++ b/examples/examples.md @@ -0,0 +1,49 @@ +```typescript +import { KimiChat } from "../lib"; + +const kimi = new KimiChat("Your API Key"); + +// Chat Completion +const { data: messages } = await kimi.chatCompletions({ + messages: [ + { + role: "user", + content: "Hello, how are you?", + }, + ], +}); + +// Estimate Token +const { data: tokenCounts } = await kimi.estimateTokens({ + messages: [ + { + role: "user", + content: "Hello, how are you?", + }, + ], +}); + +// List Models +const { data: models } = await kimi.getModels(); + +// Upload file +const { data: file } = await kimi.uploadFile( + "pathToYourFile", + (args: { loaded: number; total: number }) => { + // Optional callback + console.log(args.loaded, args.total); + } +); + +// Get uploaded files +const { data: files } = await kimi.getFiles(); + +// Get file content +const { data: fileContent } = await kimi.getFileContent(file.id); + +// Get File +const { data: fileDetail } = await kimi.getFile(file.id); + +// Delete file +const { data: deletedFile } = await kimi.deleteFile(file.id); +``` diff --git a/examples/index.ts b/examples/index.ts deleted file mode 100644 index 6e5b3c7..0000000 --- a/examples/index.ts +++ /dev/null @@ -1,46 +0,0 @@ -// @ts-nocheck - -import { KimiChat } from '../lib'; - -const kimi = new KimiChat("Your API Key") - -// Chat Completion -const {data: messages} = await kimi.chatCompletions({ - messages:[ - { - role: "user", - content: "Hello, how are you?", - }, - ], -}) - -// Estimate Token -const {data: tokenCounts} = await kimi.estimateTokens({ - messages: [ - { - role: "user", - content: "Hello, how are you?", - }, - ] -}) - -// List Models -const {data: models} = await kimi.getModels() - -// Upload file -const {data: file} = await kimi.uploadFile("pathToYourFile", (args: {loaded: number, total: number}) => { - // Optional callback - console.log(args.loaded, args.total) -}) - -// Get uploaded files -const {data: files} = await kimi.getFiles() - -// Get file content -const {data: fileContent} = await kimi.getFileContent(file.id) - -// Get File -const {data: fileDetail} = await kimi.getFile(file.id) - -// Delete file -const {data: deletedFile} = await kimi.deleteFile(file.id) diff --git a/jest.config.js b/jest.config.js index f6f99d8..8a9222c 100644 --- a/jest.config.js +++ b/jest.config.js @@ -6,6 +6,5 @@ module.exports = { '.d.ts', 'dist/', 'lib/__tests__/clearFiles.ts', - 'examples' ], }; diff --git a/tsconfig.json b/tsconfig.json index 6948f53..b4adf1d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ "module": "commonjs", /* Specify what module code is generated. */ - "outDir": "./dist", /* Specify an output folder for all emitted files. */ + "outDir": "dist", /* Specify an output folder for all emitted files. */ "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ "strict": true, /* Enable all strict type-checking options. */