Skip to content

Commit

Permalink
👷 Update CI
Browse files Browse the repository at this point in the history
  • Loading branch information
noraincode committed Mar 6, 2024
1 parent 55ec71e commit 5da507e
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 17 deletions.
11 changes: 0 additions & 11 deletions .npmignore

This file was deleted.

2 changes: 0 additions & 2 deletions lib/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
export const VERSION = "v1"
export const BASE_URL = `https://api.moonshot.cn/${VERSION}`

export type Model = "moonshot-v1-8k" | "moonshot-v1-32k" | "moonshot-v1-128k"
6 changes: 3 additions & 3 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { Dispatcher, request } from 'undici';
import FormData from 'form-data';
import fs from 'fs';

import { BASE_URL, Model } from "./constants";
import { ChatCompletion, ErrorResponse, FileContent, Message, ModelResource, KimiFile, DeletedFile, Tokens, KimiResponse } from "./types";
import { BASE_URL } from "./constants";
import { ChatCompletion, Model, FileContent, Message, ModelResource, KimiFile, DeletedFile, Tokens, KimiResponse, IKimiChat } from "./types";

export * from './constants'
export * from './types'

export class KimiChat {
export class KimiChat implements IKimiChat {
private apiKey: string;
private baseUrl = BASE_URL;

Expand Down
23 changes: 23 additions & 0 deletions lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export type Permission = {
is_blocking: boolean
}

export type Model = "moonshot-v1-8k" | "moonshot-v1-32k" | "moonshot-v1-128k"

export type ModelResource = {
created: number
id: string
Expand Down Expand Up @@ -97,3 +99,24 @@ export interface ErrorResponse {
type: string
}
}

export interface IKimiChat {
chatCompletions: (data: {
messages: Message[];
model?: Model;
maxTokens?: number;
temperature?: number;
topN?: number;
n?: number;
stream?: boolean;
}) => Promise<KimiResponse<ChatCompletion>>;
getModels: () => Promise<KimiResponse<ModelResource[]>>;
getFileContent: (id: string) => Promise<KimiResponse<FileContent>>;
deleteFile: (id: string) => Promise<KimiResponse<DeletedFile>>;
getFile: (id: string) => Promise<KimiResponse<KimiFile>>
uploadFile: (file: string) => Promise<KimiResponse<KimiFile>>
estimateTokens: (data: {
messages: Message[];
model?: Model;
}) => Promise<KimiResponse<Tokens[]>>
}
21 changes: 20 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,25 @@
"moonshot",
"sdk"
],
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js",
"require": "./dist/index.js",
"import": "./dist/index.js"
},
"./package.json": "./package.json"
},
"files": [
"dist",
"package.json",
"README.md",
"README_EN.md",
"LICENSE"
],
"author": "norain4u@yeah.net",
"license": "MIT",
"types": "dist/types.d.ts",
"types": "dist/index.d.ts",
"main": "dist/index.js",
"dependencies": {
"form-data": "^4.0.0",
Expand All @@ -32,5 +48,8 @@
"dotenv": "^16.4.5",
"jest": "^29.7.0",
"ts-jest": "^29.1.2"
},
"engines": {
"node": ">=16"
}
}

0 comments on commit 5da507e

Please sign in to comment.