-
Notifications
You must be signed in to change notification settings - Fork 45
Conversation
Have updated this pr from current diff |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for your work! 🎉
Some high-level note: we should I think remove jest
and replace it by vitest
, especially to get rid of babel
as a dependency.
src/utils/type.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you combine the JSDoc with the Typescript definitions please :)? You need to add the fields description as comments above fields in the TS def.
tests/client.test.ts
Outdated
const mockResponse = mockChatResponsePayload(); | ||
client._fetch = mockFetch(200, mockResponse); | ||
globalThis.fetch = mockFetch(200, mockResponse) as any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment above but let's use a private fetch
only for our package!
tests/test-utils.ts
Outdated
total_tokens: number; | ||
completion_tokens: number; | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need to put the interfaces again here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just clean it in further commit.
shims:true, | ||
skipNodeModulesBundle:true, | ||
clean:true | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it build with source maps as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes could build source map in tsup.
Currently I still use please kindly help check the updated PR :) |
src/mistral-client.ts
Outdated
this.endpoint = endpoint; | ||
this.apiKey = apiKey; | ||
export default class MistralClient { | ||
private apiKey: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for better or worse, these were public fields in the .d.ts file from 0.2
src/mistral-client.ts
Outdated
*/ | ||
async _fetch(...args) { | ||
public async _fetch(input: string | Request, init?: RequestInit){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be private. You can access it in the tests as client['_fetch']
src/mistral-client.ts
Outdated
return response.body; | ||
} else { | ||
const reader = response.body.getReader(); | ||
}else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like formatting needs running? }els {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one I think it might need something like .prettierrc
config to align formatting afterwards.
I have noticed that there was a pr related with single-quote.
src/mistral-client.ts
Outdated
await new Promise((resolve) => | ||
setTimeout(resolve, Math.pow(2, (attempts + 1)) * 500), | ||
); | ||
console.debug(`Retrying request on response status: ${response.status}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've dropped some of the text here:
"""
Response: ${await response.text()}
,
Attempt: ${attempts + 1}
,
"""
all issues raised by @sublimator in previous batch have been resolved, thanks :) |
On mobile now, but I think the throw branch also included resp.text()
…On Tue, 14 May 2024, 6:56 pm Jamie Lee, ***@***.***> wrote:
all issues raised by @sublimator <https://github.com/sublimator> in
previous batch have been resolved, thanks :)
—
Reply to this email directly, view it on GitHub
<#73 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEAHG5C7E22J5BUAJ2CAIDZCH3W7AVCNFSM6AAAAABHMGW7YCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJQGAYTINBRHA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
And yeah, prettier would rock!
Not sure if lint --fix still works now TS
…On Tue, 14 May 2024, 7:00 pm Nicholas Dudfield, ***@***.***> wrote:
On mobile now, but I think the throw branch also included resp.text()
On Tue, 14 May 2024, 6:56 pm Jamie Lee, ***@***.***> wrote:
> all issues raised by @sublimator <https://github.com/sublimator> in
> previous batch have been resolved, thanks :)
>
> —
> Reply to this email directly, view it on GitHub
> <#73 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAEAHG5C7E22J5BUAJ2CAIDZCH3W7AVCNFSM6AAAAABHMGW7YCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJQGAYTINBRHA>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
|
src/utils/helper.ts
Outdated
}); | ||
|
||
return controller.signal; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seem it wants you to add an extra line at the end
tests/test-utils.ts
Outdated
@@ -1,12 +1,20 @@ | |||
import jest from 'jest-mock'; | |||
import { jest } from '@jest/globals'; | |||
import { ChatCompletionResponse, Embedding, EmbeddingResponse, ListModelsResponse } from "@mistralai/mistralai/utils/type" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somehow surprised that import works
tests/test-utils.ts
Outdated
* @param {number} batchSize | ||
* @return {Object} | ||
* @param batchSize number of embeddings to generate | ||
* @returns EmbeddingResponsePayload |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The linter isn't crying about returns (vs return)? I guess not. I thought I recalled it doing so for me.
* @return {Object} | ||
*/ | ||
export function mockEmbeddingRequest() { | ||
// TODO: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Undone TODO
"outDir": "dist", | ||
"baseUrl": "./", | ||
"paths": { | ||
"@mistralai/mistralai/*": ["src/*"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's how that import worked!
src/mistral-client.ts
Outdated
@@ -1,132 +1,121 @@ | |||
const VERSION = '0.0.3'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally this PR would be based on top of the latest commit in main. It doesn't seem to be, given VERSION of 0.0.3 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but it is set 0.2.0
in latest commit in main branch:
Line 1 in 2fcc564
const VERSION = '0.2.0'; |
or anything I misunderstand?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, when looking at the diff for this PR we are seeing 0.0.3
That's because this branch is commits based on an old version of main
It complicates review a little bit
src/utils/helper.ts
Outdated
export function combineSignals(signals: AbortSignal[]):AbortSignal { | ||
const controller = new AbortController(); | ||
signals.forEach((signal) => { | ||
if (!signal) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, yeah, it was taking an array of AbortSignal | undefined
src/mistral-client.ts
Outdated
`HTTP error! status: ${response.status} ` + | ||
`Response: \n${await response.text()}`, | ||
); | ||
throw new MistralAPIError(`HTTP error! status: ${response.status}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're missing Response: \n${await response.text()}
from the og
src/mistral-client.ts
Outdated
|
||
/** | ||
* Returns a list of the available models | ||
* @return {Promise<Object>} | ||
* @returns |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consistent return vs returns?
Personally I would just lose the JSDoc now that it's typescript
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
due to this discussion:
#73 (comment)
I agree with jsdoc making code more readable, but okay with both.
Is it possible to deal with code formatting in other PR? |
Looking forward to this! Lack of Commonjs support has prevented me from using this. |
sure let me catch up the latest commit and merge into this pr |
@fuegoio |
Thanks for opening this PR. We have deprecated this package in favor of mistralai/client-ts, which is the new official Mistral client, compatible with both TypeScript and JavaScript. You can find all installation information here. This change is effective starting with version 1.0.0 of the npm package. |
this PR is for refactor original javascript version to
typescript
+tsup
;also contain test cases, but example cases not yet.