This repository has been archived by the owner on Oct 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
230 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@mistralai/mistralai", | ||
"version": "0.0.1", | ||
"version": "0.2.0", | ||
"description": "", | ||
"author": "[email protected]", | ||
"license": "ISC", | ||
|
@@ -12,7 +12,9 @@ | |
"test": "node --experimental-vm-modules node_modules/.bin/jest" | ||
}, | ||
"jest": { | ||
"testPathIgnorePatterns": ["examples"] | ||
"testPathIgnorePatterns": [ | ||
"examples" | ||
] | ||
}, | ||
"repository": { | ||
"type": "git", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,162 +1,173 @@ | ||
declare module '@mistralai/mistralai' { | ||
export interface ModelPermission { | ||
id: string; | ||
object: 'model_permission'; | ||
created: number; | ||
allow_create_engine: boolean; | ||
allow_sampling: boolean; | ||
allow_logprobs: boolean; | ||
allow_search_indices: boolean; | ||
allow_view: boolean; | ||
allow_fine_tuning: boolean; | ||
organization: string; | ||
group: string | null; | ||
is_blocking: boolean; | ||
} | ||
|
||
export interface Model { | ||
id: string; | ||
object: 'model'; | ||
created: number; | ||
owned_by: string; | ||
root: string | null; | ||
parent: string | null; | ||
permission: ModelPermission[]; | ||
} | ||
|
||
export interface ListModelsResponse { | ||
object: 'list'; | ||
data: Model[]; | ||
} | ||
|
||
export interface Function { | ||
name: string; | ||
description: string; | ||
parameters: object; | ||
} | ||
|
||
export interface FunctionCall { | ||
name: string; | ||
arguments: string; | ||
} | ||
|
||
export interface ToolCalls { | ||
id: string; | ||
function: FunctionCall; | ||
} | ||
|
||
export interface ResponseFormat { | ||
type: 'json_object'; | ||
} | ||
|
||
export interface TokenUsage { | ||
prompt_tokens: number; | ||
completion_tokens: number; | ||
total_tokens: number; | ||
} | ||
|
||
export interface ChatCompletionResponseChoice { | ||
index: number; | ||
message: { | ||
role: string; | ||
content: string; | ||
tool_calls: null | ToolCalls[]; | ||
}; | ||
finish_reason: string; | ||
} | ||
|
||
export interface ChatCompletionResponseChunkChoice { | ||
index: number; | ||
delta: { | ||
role?: string; | ||
content?: string; | ||
tool_calls?: ToolCalls[]; | ||
}; | ||
finish_reason: string; | ||
} | ||
|
||
export interface ChatCompletionResponse { | ||
id: string; | ||
object: 'chat.completion'; | ||
created: number; | ||
model: string; | ||
choices: ChatCompletionResponseChoice[]; | ||
usage: TokenUsage; | ||
} | ||
|
||
export interface ChatCompletionResponseChunk { | ||
id: string; | ||
object: 'chat.completion.chunk'; | ||
created: number; | ||
model: string; | ||
choices: ChatCompletionResponseChunkChoice[]; | ||
usage: TokenUsage | null; | ||
} | ||
|
||
export interface Embedding { | ||
id: string; | ||
object: 'embedding'; | ||
embedding: number[]; | ||
} | ||
|
||
export interface EmbeddingResponse { | ||
id: string; | ||
object: 'list'; | ||
data: Embedding[]; | ||
model: string; | ||
usage: TokenUsage; | ||
} | ||
|
||
export interface Message { | ||
role: string; | ||
content: string | string[] | ||
} | ||
|
||
export interface Tool { | ||
type: 'function'; | ||
function: Function; | ||
} | ||
|
||
export interface ChatRequest { | ||
model: string; | ||
messages: Array<Message>; | ||
tools?: Array<Tool>; | ||
temperature?: number; | ||
maxTokens?: number; | ||
topP?: number; | ||
randomSeed?: number; | ||
/** | ||
* @deprecated use safePrompt instead | ||
*/ | ||
safeMode?: boolean; | ||
safePrompt?: boolean; | ||
toolChoice?: 'auto' | 'any' | 'none'; | ||
responseFormat?: ResponseFormat; | ||
} | ||
|
||
export interface ChatRequestOptions { | ||
signal?: AbortSignal | ||
} | ||
|
||
class MistralClient { | ||
apiKey: string | ||
endpoint: string | ||
maxRetries: number | ||
timeout: number | ||
|
||
constructor(apiKey?: string, endpoint?: string, maxRetries?: number, timeout?: number); | ||
|
||
listModels(): Promise<ListModelsResponse>; | ||
|
||
chat(request: ChatRequest, options?: ChatRequestOptions): Promise<ChatCompletionResponse>; | ||
|
||
chatStream(request: ChatRequest, options?: ChatRequestOptions): AsyncGenerator<ChatCompletionResponseChunk, void>; | ||
|
||
embeddings(options: { | ||
model: string; | ||
input: string | string[]; | ||
}): Promise<EmbeddingResponse>; | ||
} | ||
|
||
export default MistralClient; | ||
declare module "@mistralai/mistralai" { | ||
export interface ModelPermission { | ||
id: string; | ||
object: "model_permission"; | ||
created: number; | ||
allow_create_engine: boolean; | ||
allow_sampling: boolean; | ||
allow_logprobs: boolean; | ||
allow_search_indices: boolean; | ||
allow_view: boolean; | ||
allow_fine_tuning: boolean; | ||
organization: string; | ||
group: string | null; | ||
is_blocking: boolean; | ||
} | ||
|
||
export interface Model { | ||
id: string; | ||
object: "model"; | ||
created: number; | ||
owned_by: string; | ||
root: string | null; | ||
parent: string | null; | ||
permission: ModelPermission[]; | ||
} | ||
|
||
export interface ListModelsResponse { | ||
object: "list"; | ||
data: Model[]; | ||
} | ||
|
||
export interface Function { | ||
name: string; | ||
description: string; | ||
parameters: object; | ||
} | ||
|
||
export interface FunctionCall { | ||
name: string; | ||
arguments: string; | ||
} | ||
|
||
export interface ToolCalls { | ||
id: string; | ||
function: FunctionCall; | ||
} | ||
|
||
export interface ResponseFormat { | ||
type: "json_object"; | ||
} | ||
|
||
export interface TokenUsage { | ||
prompt_tokens: number; | ||
completion_tokens: number; | ||
total_tokens: number; | ||
} | ||
|
||
export interface ChatCompletionResponseChoice { | ||
index: number; | ||
message: { | ||
role: string; | ||
content: string; | ||
tool_calls: null | ToolCalls[]; | ||
}; | ||
finish_reason: string; | ||
} | ||
|
||
export interface ChatCompletionResponseChunkChoice { | ||
index: number; | ||
delta: { | ||
role?: string; | ||
content?: string; | ||
tool_calls?: ToolCalls[]; | ||
}; | ||
finish_reason: string; | ||
} | ||
|
||
export interface ChatCompletionResponse { | ||
id: string; | ||
object: "chat.completion"; | ||
created: number; | ||
model: string; | ||
choices: ChatCompletionResponseChoice[]; | ||
usage: TokenUsage; | ||
} | ||
|
||
export interface ChatCompletionResponseChunk { | ||
id: string; | ||
object: "chat.completion.chunk"; | ||
created: number; | ||
model: string; | ||
choices: ChatCompletionResponseChunkChoice[]; | ||
usage: TokenUsage | null; | ||
} | ||
|
||
export interface Embedding { | ||
id: string; | ||
object: "embedding"; | ||
embedding: number[]; | ||
} | ||
|
||
export interface EmbeddingResponse { | ||
id: string; | ||
object: "list"; | ||
data: Embedding[]; | ||
model: string; | ||
usage: TokenUsage; | ||
} | ||
|
||
export interface Message { | ||
role: string; | ||
content: string | string[]; | ||
} | ||
|
||
export interface Tool { | ||
type: "function"; | ||
function: Function; | ||
} | ||
|
||
export interface ChatRequest { | ||
model: string; | ||
messages: Array<Message>; | ||
tools?: Array<Tool>; | ||
temperature?: number; | ||
maxTokens?: number; | ||
topP?: number; | ||
randomSeed?: number; | ||
/** | ||
* @deprecated use safePrompt instead | ||
*/ | ||
safeMode?: boolean; | ||
safePrompt?: boolean; | ||
toolChoice?: "auto" | "any" | "none"; | ||
responseFormat?: ResponseFormat; | ||
} | ||
|
||
export interface ChatRequestOptions { | ||
signal?: AbortSignal; | ||
} | ||
|
||
class MistralClient { | ||
apiKey: string; | ||
endpoint: string; | ||
maxRetries: number; | ||
timeout: number; | ||
|
||
constructor( | ||
apiKey?: string, | ||
endpoint?: string, | ||
maxRetries?: number, | ||
timeout?: number | ||
); | ||
|
||
listModels(): Promise<ListModelsResponse>; | ||
|
||
chat( | ||
request: ChatRequest, | ||
options?: ChatRequestOptions | ||
): Promise<ChatCompletionResponse>; | ||
|
||
chatStream( | ||
request: ChatRequest, | ||
options?: ChatRequestOptions | ||
): AsyncGenerator<ChatCompletionResponseChunk, void>; | ||
|
||
embeddings(options: { | ||
model: string; | ||
input: string | string[]; | ||
}): Promise<EmbeddingResponse>; | ||
} | ||
|
||
export default MistralClient; | ||
} |
Oops, something went wrong.