From 840717c5e996048a633efdc38bbda871a631abfe Mon Sep 17 00:00:00 2001 From: Bam4d Date: Mon, 15 Jan 2024 14:29:56 +0100 Subject: [PATCH 1/2] add user agent header --- src/client.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/client.js b/src/client.js index fa2a990..0339e93 100644 --- a/src/client.js +++ b/src/client.js @@ -1,3 +1,5 @@ +import {version} from '../package.json'; + let isNode = false; /** @@ -74,6 +76,7 @@ class MistralClient { const options = { method: method, headers: { + 'User-Agent': `mistral-client-js/${version}`, 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': `Bearer ${this.apiKey}`, From 30e9ed6c92d2e8ec7b7f4e0475b1dd6d0b7bceae Mon Sep 17 00:00:00 2001 From: Bam4d Date: Mon, 15 Jan 2024 14:54:54 +0100 Subject: [PATCH 2/2] versioned client user-agent --- .github/workflows/build_publish.yaml | 1 + src/client.js | 11 +++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_publish.yaml b/.github/workflows/build_publish.yaml index 0d00f6a..05e579f 100644 --- a/.github/workflows/build_publish.yaml +++ b/.github/workflows/build_publish.yaml @@ -69,6 +69,7 @@ jobs: run: | echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> .npmrc npm version ${{ github.ref_name }} + sed -i '' -e 's/VERSION = '\''0.0.1'\''/VERSION = '\''${{ github.ref_name }}'\''/g' src/client.js npm publish \ No newline at end of file diff --git a/src/client.js b/src/client.js index 0339e93..9b0b429 100644 --- a/src/client.js +++ b/src/client.js @@ -1,7 +1,9 @@ -import {version} from '../package.json'; - let isNode = false; +const VERSION = '0.0.3'; +const RETRY_STATUS_CODES = [429, 500, 502, 503, 504]; +const ENDPOINT = 'https://api.mistral.ai'; + /** * Initialize fetch * @return {Promise} @@ -19,9 +21,6 @@ async function initializeFetch() { initializeFetch(); -const RETRY_STATUS_CODES = [429, 500, 502, 503, 504]; -const ENDPOINT = 'https://api.mistral.ai'; - /** * MistralAPIError * @return {MistralAPIError} @@ -76,7 +75,7 @@ class MistralClient { const options = { method: method, headers: { - 'User-Agent': `mistral-client-js/${version}`, + 'User-Agent': `mistral-client-js/${VERSION}`, 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': `Bearer ${this.apiKey}`,