Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

V001 rewrite ts microbundle #41

Closed
wants to merge 50 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
170739d
installed typescript
pBread Jan 15, 2024
c470d86
reorganized package.json. no changes
pBread Jan 15, 2024
0816224
installed microbundle
pBread Jan 15, 2024
04f7af3
replaced node-fetch with isomorphic-fetch, which handles context swit…
pBread Jan 15, 2024
56092b4
ported MistralClientError
pBread Jan 15, 2024
d597f31
added MistralClient and updated JSDocs. The previous JSdoc syntax mea…
pBread Jan 15, 2024
79bf823
ported constructor
pBread Jan 15, 2024
0ab83d1
ported fetch request builder logic
pBread Jan 15, 2024
caeee00
ported result handling
pBread Jan 15, 2024
635a5c5
ported remaining executeRequest logic
pBread Jan 15, 2024
05f347b
minor cleanup
pBread Jan 15, 2024
7b40483
changed name back to _request.
pBread Jan 15, 2024
29c050e
added api version facade
pBread Jan 15, 2024
58ca9b0
ported root level methods
pBread Jan 15, 2024
1cae149
ported response types
pBread Jan 15, 2024
4e0129c
sorted entities
pBread Jan 15, 2024
f34a737
added reponse typings
pBread Jan 15, 2024
53ce15d
added streamChat. Forgot to port it before
pBread Jan 15, 2024
2568b08
ported comments
pBread Jan 15, 2024
118919a
deprecated client.js
pBread Jan 15, 2024
17085db
added default export of client
pBread Jan 15, 2024
0e95219
deprecated manually written type file
pBread Jan 15, 2024
51cf4d0
added dotenv
pBread Jan 15, 2024
f9ba375
updated examples name to eliminate lint warnings
pBread Jan 15, 2024
b2ea84b
changed examples from snake to kebab case
pBread Jan 15, 2024
59b8a51
added StreamableParameters type for better type safety
pBread Jan 15, 2024
b5dec2a
removed named export for now
pBread Jan 15, 2024
68bfa93
removed MistralClientError export for now
pBread Jan 15, 2024
b5f486c
fixed typo
pBread Jan 15, 2024
354df02
fixed typo. api was being built like //v1/...
pBread Jan 15, 2024
de3777f
updated stream handler to resolve discrepencies of fetch
pBread Jan 15, 2024
62b3710
changing tsconfig for now to avoid unintended transpilation. will cha…
pBread Jan 15, 2024
1c9f259
reusing single instance of TextDecoder instead of redeclaring every c…
pBread Jan 15, 2024
773e086
updated chat-with-streaming to parse text to json
pBread Jan 15, 2024
b215f74
added scripts to examples
pBread Jan 15, 2024
63ac199
forgot to push this. Just renaming the examples package.json
pBread Jan 15, 2024
66758d9
about to begin porting tests
pBread Jan 15, 2024
9e67981
had to change dep.test.js to dep.js to avoid test classes from running
pBread Jan 15, 2024
62f58f6
added build to test to ensure latest version is tested
pBread Jan 15, 2024
c580a77
added constructor tests
pBread Jan 15, 2024
69bcc3b
troubleshooting test environment
pBread Jan 16, 2024
978ce46
moved utils.js to __tests__ directory
pBread Jan 16, 2024
78b60c5
added basic tests for listModels() & chat()
pBread Jan 16, 2024
d72305f
removing the two tests that I ported in the last commit
pBread Jan 16, 2024
06dfb53
minor
pBread Jan 16, 2024
7d856f7
ported the remaining chat
pBread Jan 16, 2024
af53169
ported embeddings tests
pBread Jan 16, 2024
58df9e4
finished porting chatStream tests
pBread Jan 16, 2024
d5a9d92
added comment clarifying why it needs to be a util function
pBread Jan 16, 2024
43a6e5a
tests fully ported. deleting previous file
pBread Jan 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
sorted entities
pBread committed Jan 15, 2024
commit 4e0129c73cd819308dd0af561c0a23c28638ac7f
110 changes: 55 additions & 55 deletions src/client.ts
Original file line number Diff line number Diff line change
@@ -165,59 +165,20 @@ export interface CreateEmbedding {
input: string[];
}

interface MistralClientConfig {
endpoint: string;
maxRetries: number;
timeout: number;
}

export interface MistralMessage {
role: "user" | "system";
content: string;
}

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 TokenUsage {
prompt_tokens: number;
completion_tokens: number;
total_tokens: number;
}

export interface ChatCompletionResponseChoice {
index: number;
message: { role: string; content: string };
finish_reason: string;
}

export interface ChatCompletionResponseChunk {
id: string;
object: "chat.completion.chunk";
created: number;
model: string;
choices: ChatCompletionResponseChunkChoice[];
}

export interface ChatCompletionResponseChunkChoice {
index: number;
delta: { content?: string; role?: string };
@@ -233,14 +194,6 @@ export interface ChatCompletionResponse {
usage: TokenUsage;
}

export interface ChatCompletionResponseChunk {
id: string;
object: "chat.completion.chunk";
created: number;
model: string;
choices: ChatCompletionResponseChunkChoice[];
}

export interface Embedding {
id: string;
object: "embedding";
@@ -255,6 +208,53 @@ export interface EmbeddingResponse {
usage: TokenUsage;
}

export interface ListModelsResponse {
object: "list";
data: Model[];
}

export interface MistralClientConfig {
endpoint: string;
maxRetries: number;
timeout: number;
}

export interface MistralMessage {
role: "user" | "system";
content: string;
}

export interface Model {
id: string;
object: "model";
created: number;
owned_by: string;
root: string | null;
parent: string | null;
permission: ModelPermission[];
}

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 TokenUsage {
prompt_tokens: number;
completion_tokens: number;
total_tokens: number;
}

/****************************************************
Utilities
****************************************************/