chore(providers-local): add game key as header for player2 (#168)
* add game key as header for player2 * fixed request headers * use headers in createProvider
This commit is contained in:
1 parent
31ed461831
commit
c7ea02f6b3
1 file changed
+4
-2
@@ -6,7 +6,7 @@ import {
|
||||
} from '@xsai-ext/shared-providers'
|
||||
import { Buffer } from 'node:buffer'
|
||||
|
||||
export const createPlayer2 = (baseURL = 'http://localhost:4315/v1/') => merge(createMetadataProvider('player2'), createChatProvider({ baseURL }), createSpeechProvider({
|
||||
export const createPlayer2 = (baseURL = 'http://localhost:4315/v1/', gameKey = 'xsai') => merge(createMetadataProvider('player2'), createChatProvider({ baseURL, headers: { 'player2-game-key': gameKey } }), createSpeechProvider({
|
||||
baseURL,
|
||||
fetch: async (input: Parameters<typeof globalThis.fetch>[0], reqInit: Parameters<typeof globalThis.fetch>[1]) => {
|
||||
const newUrl = `${input.toString().slice(0, -'audio/speech'.length)}tts/speak`
|
||||
@@ -28,8 +28,9 @@ export const createPlayer2 = (baseURL = 'http://localhost:4315/v1/') => merge(cr
|
||||
: [],
|
||||
...rest,
|
||||
}
|
||||
if (reqInit)
|
||||
if (reqInit) {
|
||||
reqInit.body = JSON.stringify(modified)
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
console.warn('Could not parse body as JSON:', err)
|
||||
@@ -54,4 +55,5 @@ export const createPlayer2 = (baseURL = 'http://localhost:4315/v1/') => merge(cr
|
||||
})
|
||||
})
|
||||
},
|
||||
headers: { 'player2-game-key': gameKey },
|
||||
}))
|
||||
Reference in new issue
Block a user