@mistralai/mistralai 1.13.0 → 1.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -3
- package/examples/src/async_audio_transcription_diarize.ts +17 -0
- package/examples/src/realtime_microphone.ts +163 -0
- package/examples/src/realtime_transcription.ts +225 -0
- package/extra/realtime/connection.d.ts +44 -0
- package/extra/realtime/connection.d.ts.map +1 -0
- package/extra/realtime/connection.js +299 -0
- package/extra/realtime/connection.js.map +1 -0
- package/extra/realtime/errors.d.ts +18 -0
- package/extra/realtime/errors.d.ts.map +1 -0
- package/extra/realtime/errors.js +21 -0
- package/extra/realtime/errors.js.map +1 -0
- package/extra/realtime/index.d.ts +15 -0
- package/extra/realtime/index.d.ts.map +1 -0
- package/extra/realtime/index.js +10 -0
- package/extra/realtime/index.js.map +1 -0
- package/extra/realtime/transcription.d.ts +17 -0
- package/extra/realtime/transcription.d.ts.map +1 -0
- package/extra/realtime/transcription.js +200 -0
- package/extra/realtime/transcription.js.map +1 -0
- package/extra/structChat.js.map +1 -1
- package/funcs/audioTranscriptionsComplete.js +6 -0
- package/funcs/audioTranscriptionsComplete.js.map +1 -1
- package/funcs/audioTranscriptionsStream.js +6 -0
- package/funcs/audioTranscriptionsStream.js.map +1 -1
- package/funcs/batchJobsList.js +1 -0
- package/funcs/batchJobsList.js.map +1 -1
- package/funcs/betaAgentsCreateVersionAlias.d.ts +19 -0
- package/funcs/betaAgentsCreateVersionAlias.d.ts.map +1 -0
- package/funcs/betaAgentsCreateVersionAlias.js +130 -0
- package/funcs/betaAgentsCreateVersionAlias.js.map +1 -0
- package/funcs/betaAgentsDeleteVersionAlias.d.ts +18 -0
- package/funcs/betaAgentsDeleteVersionAlias.d.ts.map +1 -0
- package/funcs/betaAgentsDeleteVersionAlias.js +128 -0
- package/funcs/betaAgentsDeleteVersionAlias.js.map +1 -0
- package/funcs/betaAgentsGet.d.ts +1 -1
- package/funcs/betaAgentsGet.js +1 -1
- package/funcs/betaAgentsGetVersion.js +1 -1
- package/funcs/betaAgentsGetVersion.js.map +1 -1
- package/funcs/betaAgentsList.js +1 -0
- package/funcs/betaAgentsList.js.map +1 -1
- package/funcs/betaAgentsListVersionAliases.d.ts +19 -0
- package/funcs/betaAgentsListVersionAliases.d.ts.map +1 -0
- package/funcs/betaAgentsListVersionAliases.js +126 -0
- package/funcs/betaAgentsListVersionAliases.js.map +1 -0
- package/funcs/filesList.js +1 -0
- package/funcs/filesList.js.map +1 -1
- package/jsr.json +1 -1
- package/lib/config.d.ts +2 -2
- package/lib/config.js +2 -2
- package/models/components/agent.d.ts +2 -8
- package/models/components/agent.d.ts.map +1 -1
- package/models/components/agent.js +4 -8
- package/models/components/agent.js.map +1 -1
- package/models/components/agentaliasresponse.d.ts +13 -0
- package/models/components/agentaliasresponse.d.ts.map +1 -0
- package/models/components/agentaliasresponse.js +59 -0
- package/models/components/agentaliasresponse.js.map +1 -0
- package/models/components/agentconversation.d.ts +5 -8
- package/models/components/agentconversation.d.ts.map +1 -1
- package/models/components/agentconversation.js +8 -7
- package/models/components/agentconversation.js.map +1 -1
- package/models/components/agentcreationrequest.d.ts +2 -0
- package/models/components/agentcreationrequest.d.ts.map +1 -1
- package/models/components/agentcreationrequest.js +2 -0
- package/models/components/agentcreationrequest.js.map +1 -1
- package/models/components/agenthandoffdoneevent.d.ts +1 -8
- package/models/components/agenthandoffdoneevent.d.ts.map +1 -1
- package/models/components/agenthandoffdoneevent.js +2 -7
- package/models/components/agenthandoffdoneevent.js.map +1 -1
- package/models/components/agenthandoffentry.d.ts +4 -21
- package/models/components/agenthandoffentry.d.ts.map +1 -1
- package/models/components/agenthandoffentry.js +5 -19
- package/models/components/agenthandoffentry.js.map +1 -1
- package/models/components/agenthandoffstartedevent.d.ts +1 -8
- package/models/components/agenthandoffstartedevent.d.ts.map +1 -1
- package/models/components/agenthandoffstartedevent.js +2 -7
- package/models/components/agenthandoffstartedevent.js.map +1 -1
- package/models/components/agentupdaterequest.d.ts +2 -0
- package/models/components/agentupdaterequest.d.ts.map +1 -1
- package/models/components/agentupdaterequest.js +2 -0
- package/models/components/agentupdaterequest.js.map +1 -1
- package/models/components/archiveftmodelout.d.ts +1 -8
- package/models/components/archiveftmodelout.d.ts.map +1 -1
- package/models/components/archiveftmodelout.js +2 -7
- package/models/components/archiveftmodelout.js.map +1 -1
- package/models/components/assistantmessage.d.ts +2 -11
- package/models/components/assistantmessage.d.ts.map +1 -1
- package/models/components/assistantmessage.js +3 -10
- package/models/components/assistantmessage.js.map +1 -1
- package/models/components/audiochunk.d.ts +2 -11
- package/models/components/audiochunk.d.ts.map +1 -1
- package/models/components/audiochunk.js +3 -10
- package/models/components/audiochunk.js.map +1 -1
- package/models/components/audiotranscriptionrequest.d.ts +4 -0
- package/models/components/audiotranscriptionrequest.d.ts.map +1 -1
- package/models/components/audiotranscriptionrequest.js +3 -0
- package/models/components/audiotranscriptionrequest.js.map +1 -1
- package/models/components/audiotranscriptionrequeststream.d.ts +4 -0
- package/models/components/audiotranscriptionrequeststream.d.ts.map +1 -1
- package/models/components/audiotranscriptionrequeststream.js +3 -0
- package/models/components/audiotranscriptionrequeststream.js.map +1 -1
- package/models/components/basemodelcard.d.ts +0 -7
- package/models/components/basemodelcard.d.ts.map +1 -1
- package/models/components/basemodelcard.js +1 -6
- package/models/components/basemodelcard.js.map +1 -1
- package/models/components/batchjobout.d.ts +1 -8
- package/models/components/batchjobout.d.ts.map +1 -1
- package/models/components/batchjobout.js +2 -7
- package/models/components/batchjobout.js.map +1 -1
- package/models/components/batchjobsout.d.ts +1 -8
- package/models/components/batchjobsout.d.ts.map +1 -1
- package/models/components/batchjobsout.js +2 -7
- package/models/components/batchjobsout.js.map +1 -1
- package/models/components/classifierdetailedjobout.d.ts +2 -17
- package/models/components/classifierdetailedjobout.d.ts.map +1 -1
- package/models/components/classifierdetailedjobout.js +3 -13
- package/models/components/classifierdetailedjobout.js.map +1 -1
- package/models/components/classifierftmodelout.d.ts +2 -15
- package/models/components/classifierftmodelout.d.ts.map +1 -1
- package/models/components/classifierftmodelout.js +3 -13
- package/models/components/classifierftmodelout.js.map +1 -1
- package/models/components/classifierjobout.d.ts +2 -29
- package/models/components/classifierjobout.d.ts.map +1 -1
- package/models/components/classifierjobout.js +3 -19
- package/models/components/classifierjobout.js.map +1 -1
- package/models/components/codeinterpretertool.d.ts +3 -0
- package/models/components/codeinterpretertool.d.ts.map +1 -1
- package/models/components/codeinterpretertool.js +12 -0
- package/models/components/codeinterpretertool.js.map +1 -1
- package/models/components/completiondetailedjobout.d.ts +2 -17
- package/models/components/completiondetailedjobout.d.ts.map +1 -1
- package/models/components/completiondetailedjobout.js +3 -13
- package/models/components/completiondetailedjobout.js.map +1 -1
- package/models/components/completionftmodelout.d.ts +2 -15
- package/models/components/completionftmodelout.d.ts.map +1 -1
- package/models/components/completionftmodelout.js +3 -14
- package/models/components/completionftmodelout.js.map +1 -1
- package/models/components/completionjobout.d.ts +2 -29
- package/models/components/completionjobout.d.ts.map +1 -1
- package/models/components/completionjobout.js +3 -20
- package/models/components/completionjobout.js.map +1 -1
- package/models/components/conversationappendrequest.d.ts +5 -2
- package/models/components/conversationappendrequest.d.ts.map +1 -1
- package/models/components/conversationappendrequest.js +5 -1
- package/models/components/conversationappendrequest.js.map +1 -1
- package/models/components/conversationappendstreamrequest.d.ts +5 -2
- package/models/components/conversationappendstreamrequest.d.ts.map +1 -1
- package/models/components/conversationappendstreamrequest.js +5 -1
- package/models/components/conversationappendstreamrequest.js.map +1 -1
- package/models/components/conversationhistory.d.ts +1 -8
- package/models/components/conversationhistory.d.ts.map +1 -1
- package/models/components/conversationhistory.js +2 -7
- package/models/components/conversationhistory.js.map +1 -1
- package/models/components/conversationmessages.d.ts +1 -8
- package/models/components/conversationmessages.d.ts.map +1 -1
- package/models/components/conversationmessages.js +2 -7
- package/models/components/conversationmessages.js.map +1 -1
- package/models/components/conversationrequest.d.ts +8 -2
- package/models/components/conversationrequest.d.ts.map +1 -1
- package/models/components/conversationrequest.js +8 -2
- package/models/components/conversationrequest.js.map +1 -1
- package/models/components/conversationresponse.d.ts +1 -8
- package/models/components/conversationresponse.d.ts.map +1 -1
- package/models/components/conversationresponse.js +2 -7
- package/models/components/conversationresponse.js.map +1 -1
- package/models/components/conversationrestartrequest.d.ts +13 -4
- package/models/components/conversationrestartrequest.d.ts.map +1 -1
- package/models/components/conversationrestartrequest.js +9 -3
- package/models/components/conversationrestartrequest.js.map +1 -1
- package/models/components/conversationrestartstreamrequest.d.ts +13 -4
- package/models/components/conversationrestartstreamrequest.d.ts.map +1 -1
- package/models/components/conversationrestartstreamrequest.js +9 -3
- package/models/components/conversationrestartstreamrequest.js.map +1 -1
- package/models/components/conversationstreamrequest.d.ts +8 -2
- package/models/components/conversationstreamrequest.d.ts.map +1 -1
- package/models/components/conversationstreamrequest.js +8 -2
- package/models/components/conversationstreamrequest.js.map +1 -1
- package/models/components/documentlibrarytool.d.ts +3 -0
- package/models/components/documentlibrarytool.d.ts.map +1 -1
- package/models/components/documentlibrarytool.js +5 -0
- package/models/components/documentlibrarytool.js.map +1 -1
- package/models/components/documentout.d.ts +1 -1
- package/models/components/documentout.d.ts.map +1 -1
- package/models/components/documentout.js +2 -2
- package/models/components/documentout.js.map +1 -1
- package/models/components/documenturlchunk.d.ts +2 -11
- package/models/components/documenturlchunk.d.ts.map +1 -1
- package/models/components/documenturlchunk.js +3 -10
- package/models/components/documenturlchunk.js.map +1 -1
- package/models/components/ftmodelcard.d.ts +0 -7
- package/models/components/ftmodelcard.d.ts.map +1 -1
- package/models/components/ftmodelcard.js +1 -6
- package/models/components/ftmodelcard.js.map +1 -1
- package/models/components/functioncallentry.d.ts +13 -17
- package/models/components/functioncallentry.d.ts.map +1 -1
- package/models/components/functioncallentry.js +15 -16
- package/models/components/functioncallentry.js.map +1 -1
- package/models/components/functioncallevent.d.ts +8 -5
- package/models/components/functioncallevent.d.ts.map +1 -1
- package/models/components/functioncallevent.js +9 -5
- package/models/components/functioncallevent.js.map +1 -1
- package/models/components/functionresultentry.d.ts +4 -21
- package/models/components/functionresultentry.d.ts.map +1 -1
- package/models/components/functionresultentry.js +5 -19
- package/models/components/functionresultentry.js.map +1 -1
- package/models/components/functiontool.d.ts +5 -5
- package/models/components/functiontool.d.ts.map +1 -1
- package/models/components/functiontool.js +6 -6
- package/models/components/functiontool.js.map +1 -1
- package/models/components/githubrepositoryin.d.ts +2 -9
- package/models/components/githubrepositoryin.d.ts.map +1 -1
- package/models/components/githubrepositoryin.js +2 -7
- package/models/components/githubrepositoryin.js.map +1 -1
- package/models/components/githubrepositoryout.d.ts +1 -8
- package/models/components/githubrepositoryout.d.ts.map +1 -1
- package/models/components/githubrepositoryout.js +2 -7
- package/models/components/githubrepositoryout.js.map +1 -1
- package/models/components/imagedetail.d.ts +13 -0
- package/models/components/imagedetail.d.ts.map +1 -0
- package/models/components/imagedetail.js +51 -0
- package/models/components/imagedetail.js.map +1 -0
- package/models/components/imagegenerationtool.d.ts +3 -0
- package/models/components/imagegenerationtool.d.ts.map +1 -1
- package/models/components/imagegenerationtool.js +12 -0
- package/models/components/imagegenerationtool.js.map +1 -1
- package/models/components/imageurl.d.ts +2 -1
- package/models/components/imageurl.d.ts.map +1 -1
- package/models/components/imageurl.js +3 -2
- package/models/components/imageurl.js.map +1 -1
- package/models/components/imageurlchunk.d.ts +2 -11
- package/models/components/imageurlchunk.d.ts.map +1 -1
- package/models/components/imageurlchunk.js +3 -10
- package/models/components/imageurlchunk.js.map +1 -1
- package/models/components/index.d.ts +14 -0
- package/models/components/index.d.ts.map +1 -1
- package/models/components/index.js +14 -0
- package/models/components/index.js.map +1 -1
- package/models/components/jobin.d.ts +0 -3
- package/models/components/jobin.d.ts.map +1 -1
- package/models/components/jobin.js.map +1 -1
- package/models/components/jobsout.d.ts +1 -8
- package/models/components/jobsout.d.ts.map +1 -1
- package/models/components/jobsout.js +2 -7
- package/models/components/jobsout.js.map +1 -1
- package/models/components/legacyjobmetadataout.d.ts +1 -8
- package/models/components/legacyjobmetadataout.d.ts.map +1 -1
- package/models/components/legacyjobmetadataout.js +2 -7
- package/models/components/legacyjobmetadataout.js.map +1 -1
- package/models/components/messageinputentry.d.ts +9 -25
- package/models/components/messageinputentry.d.ts.map +1 -1
- package/models/components/messageinputentry.js +10 -25
- package/models/components/messageinputentry.js.map +1 -1
- package/models/components/messageoutputentry.d.ts +6 -31
- package/models/components/messageoutputentry.d.ts.map +1 -1
- package/models/components/messageoutputentry.js +7 -28
- package/models/components/messageoutputentry.js.map +1 -1
- package/models/components/messageoutputevent.d.ts +2 -15
- package/models/components/messageoutputevent.d.ts.map +1 -1
- package/models/components/messageoutputevent.js +3 -13
- package/models/components/messageoutputevent.js.map +1 -1
- package/models/components/mistralpromptmode.d.ts +14 -0
- package/models/components/mistralpromptmode.d.ts.map +1 -1
- package/models/components/mistralpromptmode.js +7 -0
- package/models/components/mistralpromptmode.js.map +1 -1
- package/models/components/modelcapabilities.d.ts +1 -0
- package/models/components/modelcapabilities.d.ts.map +1 -1
- package/models/components/modelcapabilities.js +2 -0
- package/models/components/modelcapabilities.js.map +1 -1
- package/models/components/modelconversation.d.ts +1 -8
- package/models/components/modelconversation.d.ts.map +1 -1
- package/models/components/modelconversation.js +2 -7
- package/models/components/modelconversation.js.map +1 -1
- package/models/components/realtimetranscriptionerror.d.ts +20 -0
- package/models/components/realtimetranscriptionerror.d.ts.map +1 -0
- package/models/components/realtimetranscriptionerror.js +61 -0
- package/models/components/realtimetranscriptionerror.js.map +1 -0
- package/models/components/realtimetranscriptionerrordetail.d.ts +45 -0
- package/models/components/realtimetranscriptionerrordetail.d.ts.map +1 -0
- package/models/components/realtimetranscriptionerrordetail.js +72 -0
- package/models/components/realtimetranscriptionerrordetail.js.map +1 -0
- package/models/components/realtimetranscriptioninputaudioappend.d.ts +22 -0
- package/models/components/realtimetranscriptioninputaudioappend.d.ts.map +1 -0
- package/models/components/realtimetranscriptioninputaudioappend.js +60 -0
- package/models/components/realtimetranscriptioninputaudioappend.js.map +1 -0
- package/models/components/realtimetranscriptioninputaudioend.d.ts +17 -0
- package/models/components/realtimetranscriptioninputaudioend.d.ts.map +1 -0
- package/models/components/realtimetranscriptioninputaudioend.js +58 -0
- package/models/components/realtimetranscriptioninputaudioend.js.map +1 -0
- package/models/components/realtimetranscriptioninputaudioflush.d.ts +17 -0
- package/models/components/realtimetranscriptioninputaudioflush.d.ts.map +1 -0
- package/models/components/realtimetranscriptioninputaudioflush.js +58 -0
- package/models/components/realtimetranscriptioninputaudioflush.js.map +1 -0
- package/models/components/realtimetranscriptionsession.d.ts +24 -0
- package/models/components/realtimetranscriptionsession.d.ts.map +1 -0
- package/models/components/realtimetranscriptionsession.js +78 -0
- package/models/components/realtimetranscriptionsession.js.map +1 -0
- package/models/components/realtimetranscriptionsessioncreated.d.ts +20 -0
- package/models/components/realtimetranscriptionsessioncreated.d.ts.map +1 -0
- package/models/components/realtimetranscriptionsessioncreated.js +61 -0
- package/models/components/realtimetranscriptionsessioncreated.js.map +1 -0
- package/models/components/realtimetranscriptionsessionupdated.d.ts +20 -0
- package/models/components/realtimetranscriptionsessionupdated.d.ts.map +1 -0
- package/models/components/realtimetranscriptionsessionupdated.js +61 -0
- package/models/components/realtimetranscriptionsessionupdated.js.map +1 -0
- package/models/components/realtimetranscriptionsessionupdatemessage.d.ts +20 -0
- package/models/components/realtimetranscriptionsessionupdatemessage.d.ts.map +1 -0
- package/models/components/realtimetranscriptionsessionupdatemessage.js +61 -0
- package/models/components/realtimetranscriptionsessionupdatemessage.js.map +1 -0
- package/models/components/realtimetranscriptionsessionupdatepayload.d.ts +26 -0
- package/models/components/realtimetranscriptionsessionupdatepayload.d.ts.map +1 -0
- package/models/components/realtimetranscriptionsessionupdatepayload.js +72 -0
- package/models/components/realtimetranscriptionsessionupdatepayload.js.map +1 -0
- package/models/components/referencechunk.d.ts +2 -11
- package/models/components/referencechunk.d.ts.map +1 -1
- package/models/components/referencechunk.js +3 -10
- package/models/components/referencechunk.js.map +1 -1
- package/models/components/responsedoneevent.d.ts +1 -8
- package/models/components/responsedoneevent.d.ts.map +1 -1
- package/models/components/responsedoneevent.js +2 -7
- package/models/components/responsedoneevent.js.map +1 -1
- package/models/components/responseerrorevent.d.ts +1 -8
- package/models/components/responseerrorevent.d.ts.map +1 -1
- package/models/components/responseerrorevent.js +2 -7
- package/models/components/responseerrorevent.js.map +1 -1
- package/models/components/responsestartedevent.d.ts +1 -8
- package/models/components/responsestartedevent.d.ts.map +1 -1
- package/models/components/responsestartedevent.js +2 -7
- package/models/components/responsestartedevent.js.map +1 -1
- package/models/components/systemmessage.d.ts +2 -9
- package/models/components/systemmessage.d.ts.map +1 -1
- package/models/components/systemmessage.js +2 -7
- package/models/components/systemmessage.js.map +1 -1
- package/models/components/textchunk.d.ts +2 -11
- package/models/components/textchunk.d.ts.map +1 -1
- package/models/components/textchunk.js +3 -10
- package/models/components/textchunk.js.map +1 -1
- package/models/components/thinkchunk.d.ts +8 -20
- package/models/components/thinkchunk.d.ts.map +1 -1
- package/models/components/thinkchunk.js +10 -17
- package/models/components/thinkchunk.js.map +1 -1
- package/models/components/timestampgranularity.d.ts +1 -0
- package/models/components/timestampgranularity.d.ts.map +1 -1
- package/models/components/timestampgranularity.js +1 -0
- package/models/components/timestampgranularity.js.map +1 -1
- package/models/components/toolcallconfirmation.d.ts +22 -0
- package/models/components/toolcallconfirmation.d.ts.map +1 -0
- package/models/components/toolcallconfirmation.js +61 -0
- package/models/components/toolcallconfirmation.js.map +1 -0
- package/models/components/toolconfiguration.d.ts +21 -0
- package/models/components/toolconfiguration.d.ts.map +1 -0
- package/models/components/toolconfiguration.js +71 -0
- package/models/components/toolconfiguration.js.map +1 -0
- package/models/components/toolexecutiondeltaevent.d.ts +1 -8
- package/models/components/toolexecutiondeltaevent.d.ts.map +1 -1
- package/models/components/toolexecutiondeltaevent.js +2 -7
- package/models/components/toolexecutiondeltaevent.js.map +1 -1
- package/models/components/toolexecutiondoneevent.d.ts +1 -8
- package/models/components/toolexecutiondoneevent.d.ts.map +1 -1
- package/models/components/toolexecutiondoneevent.js +2 -7
- package/models/components/toolexecutiondoneevent.js.map +1 -1
- package/models/components/toolexecutionentry.d.ts +4 -21
- package/models/components/toolexecutionentry.d.ts.map +1 -1
- package/models/components/toolexecutionentry.js +5 -19
- package/models/components/toolexecutionentry.js.map +1 -1
- package/models/components/toolexecutionstartedevent.d.ts +1 -8
- package/models/components/toolexecutionstartedevent.d.ts.map +1 -1
- package/models/components/toolexecutionstartedevent.js +2 -7
- package/models/components/toolexecutionstartedevent.js.map +1 -1
- package/models/components/toolfilechunk.d.ts +2 -11
- package/models/components/toolfilechunk.d.ts.map +1 -1
- package/models/components/toolfilechunk.js +3 -10
- package/models/components/toolfilechunk.js.map +1 -1
- package/models/components/toolmessage.d.ts +2 -9
- package/models/components/toolmessage.d.ts.map +1 -1
- package/models/components/toolmessage.js +2 -7
- package/models/components/toolmessage.js.map +1 -1
- package/models/components/toolreferencechunk.d.ts +2 -11
- package/models/components/toolreferencechunk.d.ts.map +1 -1
- package/models/components/toolreferencechunk.js +3 -10
- package/models/components/toolreferencechunk.js.map +1 -1
- package/models/components/transcriptionsegmentchunk.d.ts +6 -11
- package/models/components/transcriptionsegmentchunk.d.ts.map +1 -1
- package/models/components/transcriptionsegmentchunk.js +13 -11
- package/models/components/transcriptionsegmentchunk.js.map +1 -1
- package/models/components/transcriptionstreamdone.d.ts +2 -11
- package/models/components/transcriptionstreamdone.d.ts.map +1 -1
- package/models/components/transcriptionstreamdone.js +3 -10
- package/models/components/transcriptionstreamdone.js.map +1 -1
- package/models/components/transcriptionstreamlanguage.d.ts +2 -11
- package/models/components/transcriptionstreamlanguage.d.ts.map +1 -1
- package/models/components/transcriptionstreamlanguage.js +3 -10
- package/models/components/transcriptionstreamlanguage.js.map +1 -1
- package/models/components/transcriptionstreamsegmentdelta.d.ts +2 -8
- package/models/components/transcriptionstreamsegmentdelta.d.ts.map +1 -1
- package/models/components/transcriptionstreamsegmentdelta.js +9 -8
- package/models/components/transcriptionstreamsegmentdelta.js.map +1 -1
- package/models/components/transcriptionstreamtextdelta.d.ts +2 -11
- package/models/components/transcriptionstreamtextdelta.d.ts.map +1 -1
- package/models/components/transcriptionstreamtextdelta.js +3 -10
- package/models/components/transcriptionstreamtextdelta.js.map +1 -1
- package/models/components/unarchiveftmodelout.d.ts +1 -8
- package/models/components/unarchiveftmodelout.d.ts.map +1 -1
- package/models/components/unarchiveftmodelout.js +2 -7
- package/models/components/unarchiveftmodelout.js.map +1 -1
- package/models/components/usermessage.d.ts +2 -9
- package/models/components/usermessage.d.ts.map +1 -1
- package/models/components/usermessage.js +2 -7
- package/models/components/usermessage.js.map +1 -1
- package/models/components/wandbintegration.d.ts +2 -9
- package/models/components/wandbintegration.d.ts.map +1 -1
- package/models/components/wandbintegration.js +2 -7
- package/models/components/wandbintegration.js.map +1 -1
- package/models/components/wandbintegrationout.d.ts +1 -8
- package/models/components/wandbintegrationout.d.ts.map +1 -1
- package/models/components/wandbintegrationout.js +2 -7
- package/models/components/wandbintegrationout.js.map +1 -1
- package/models/components/websearchpremiumtool.d.ts +3 -0
- package/models/components/websearchpremiumtool.d.ts.map +1 -1
- package/models/components/websearchpremiumtool.js +12 -0
- package/models/components/websearchpremiumtool.js.map +1 -1
- package/models/components/websearchtool.d.ts +3 -0
- package/models/components/websearchtool.d.ts.map +1 -1
- package/models/components/websearchtool.js +12 -0
- package/models/components/websearchtool.js.map +1 -1
- package/models/operations/agentsapiv1agentscreateorupdatealias.d.ts +16 -0
- package/models/operations/agentsapiv1agentscreateorupdatealias.d.ts.map +1 -0
- package/models/operations/agentsapiv1agentscreateorupdatealias.js +56 -0
- package/models/operations/agentsapiv1agentscreateorupdatealias.js.map +1 -0
- package/models/operations/agentsapiv1agentsdeletealias.d.ts +14 -0
- package/models/operations/agentsapiv1agentsdeletealias.d.ts.map +1 -0
- package/models/operations/agentsapiv1agentsdeletealias.js +55 -0
- package/models/operations/agentsapiv1agentsdeletealias.js.map +1 -0
- package/models/operations/agentsapiv1agentsget.d.ts +8 -2
- package/models/operations/agentsapiv1agentsget.d.ts.map +1 -1
- package/models/operations/agentsapiv1agentsget.js +8 -2
- package/models/operations/agentsapiv1agentsget.js.map +1 -1
- package/models/operations/agentsapiv1agentsgetversion.d.ts +2 -2
- package/models/operations/agentsapiv1agentsgetversion.js +1 -1
- package/models/operations/agentsapiv1agentsgetversion.js.map +1 -1
- package/models/operations/agentsapiv1agentslist.d.ts +8 -0
- package/models/operations/agentsapiv1agentslist.d.ts.map +1 -1
- package/models/operations/agentsapiv1agentslist.js +1 -0
- package/models/operations/agentsapiv1agentslist.js.map +1 -1
- package/models/operations/agentsapiv1agentslistversionaliases.d.ts +12 -0
- package/models/operations/agentsapiv1agentslistversionaliases.d.ts.map +1 -0
- package/models/operations/agentsapiv1agentslistversionaliases.js +54 -0
- package/models/operations/agentsapiv1agentslistversionaliases.js.map +1 -0
- package/models/operations/filesapirouteslistfiles.d.ts +2 -0
- package/models/operations/filesapirouteslistfiles.d.ts.map +1 -1
- package/models/operations/filesapirouteslistfiles.js +1 -0
- package/models/operations/filesapirouteslistfiles.js.map +1 -1
- package/models/operations/index.d.ts +3 -0
- package/models/operations/index.d.ts.map +1 -1
- package/models/operations/index.js +3 -0
- package/models/operations/index.js.map +1 -1
- package/models/operations/jobsapiroutesbatchgetbatchjobs.d.ts +10 -0
- package/models/operations/jobsapiroutesbatchgetbatchjobs.d.ts.map +1 -1
- package/models/operations/jobsapiroutesbatchgetbatchjobs.js +10 -1
- package/models/operations/jobsapiroutesbatchgetbatchjobs.js.map +1 -1
- package/package.json +4 -1
- package/sdk/mistralagents.d.ts +22 -1
- package/sdk/mistralagents.d.ts.map +1 -1
- package/sdk/mistralagents.js +31 -1
- package/sdk/mistralagents.js.map +1 -1
- package/src/extra/realtime/connection.ts +459 -0
- package/src/extra/realtime/errors.ts +32 -0
- package/src/extra/realtime/index.ts +32 -0
- package/src/extra/realtime/transcription.ts +291 -0
- package/src/extra/structChat.ts +2 -2
- package/src/funcs/audioTranscriptionsComplete.ts +6 -0
- package/src/funcs/audioTranscriptionsStream.ts +6 -0
- package/src/funcs/batchJobsList.ts +1 -0
- package/src/funcs/betaAgentsCreateVersionAlias.ts +184 -0
- package/src/funcs/betaAgentsDeleteVersionAlias.ts +184 -0
- package/src/funcs/betaAgentsGet.ts +1 -1
- package/src/funcs/betaAgentsGetVersion.ts +1 -1
- package/src/funcs/betaAgentsList.ts +1 -0
- package/src/funcs/betaAgentsListVersionAliases.ts +179 -0
- package/src/funcs/filesList.ts +1 -0
- package/src/lib/config.ts +2 -2
- package/src/models/components/agent.ts +5 -12
- package/src/models/components/agentaliasresponse.ts +43 -0
- package/src/models/components/agentconversation.ts +20 -14
- package/src/models/components/agentcreationrequest.ts +4 -0
- package/src/models/components/agenthandoffdoneevent.ts +2 -15
- package/src/models/components/agenthandoffentry.ts +8 -39
- package/src/models/components/agenthandoffstartedevent.ts +2 -17
- package/src/models/components/agentupdaterequest.ts +4 -0
- package/src/models/components/archiveftmodelout.ts +2 -15
- package/src/models/components/assistantmessage.ts +4 -19
- package/src/models/components/audiochunk.ts +4 -19
- package/src/models/components/audiotranscriptionrequest.ts +7 -0
- package/src/models/components/audiotranscriptionrequeststream.ts +7 -0
- package/src/models/components/basemodelcard.ts +0 -11
- package/src/models/components/batchjobout.ts +2 -13
- package/src/models/components/batchjobsout.ts +2 -13
- package/src/models/components/classifierdetailedjobout.ts +4 -31
- package/src/models/components/classifierftmodelout.ts +4 -29
- package/src/models/components/classifierjobout.ts +4 -41
- package/src/models/components/codeinterpretertool.ts +19 -0
- package/src/models/components/completiondetailedjobout.ts +4 -31
- package/src/models/components/completionftmodelout.ts +4 -26
- package/src/models/components/completionjobout.ts +4 -38
- package/src/models/components/conversationappendrequest.ts +13 -3
- package/src/models/components/conversationappendstreamrequest.ts +13 -3
- package/src/models/components/conversationhistory.ts +2 -17
- package/src/models/components/conversationmessages.ts +2 -17
- package/src/models/components/conversationrequest.ts +19 -3
- package/src/models/components/conversationresponse.ts +2 -17
- package/src/models/components/conversationrestartrequest.ts +32 -6
- package/src/models/components/conversationrestartstreamrequest.ts +35 -6
- package/src/models/components/conversationstreamrequest.ts +25 -3
- package/src/models/components/documentlibrarytool.ts +12 -0
- package/src/models/components/documentout.ts +3 -3
- package/src/models/components/documenturlchunk.ts +4 -19
- package/src/models/components/ftmodelcard.ts +0 -11
- package/src/models/components/functioncallentry.ts +25 -33
- package/src/models/components/functioncallevent.ts +17 -8
- package/src/models/components/functionresultentry.ts +8 -41
- package/src/models/components/functiontool.ts +10 -11
- package/src/models/components/githubrepositoryin.ts +3 -14
- package/src/models/components/githubrepositoryout.ts +2 -15
- package/src/models/components/imagedetail.ts +20 -0
- package/src/models/components/imagegenerationtool.ts +19 -0
- package/src/models/components/imageurl.ts +8 -3
- package/src/models/components/imageurlchunk.ts +4 -19
- package/src/models/components/index.ts +14 -0
- package/src/models/components/jobin.ts +0 -3
- package/src/models/components/jobsout.ts +2 -13
- package/src/models/components/legacyjobmetadataout.ts +2 -15
- package/src/models/components/messageinputentry.ts +18 -45
- package/src/models/components/messageoutputentry.ts +12 -57
- package/src/models/components/messageoutputevent.ts +4 -25
- package/src/models/components/mistralpromptmode.ts +14 -0
- package/src/models/components/modelcapabilities.ts +3 -0
- package/src/models/components/modelconversation.ts +2 -15
- package/src/models/components/realtimetranscriptionerror.ts +61 -0
- package/src/models/components/realtimetranscriptionerrordetail.ts +94 -0
- package/src/models/components/realtimetranscriptioninputaudioappend.ts +61 -0
- package/src/models/components/realtimetranscriptioninputaudioend.ts +54 -0
- package/src/models/components/realtimetranscriptioninputaudioflush.ts +54 -0
- package/src/models/components/realtimetranscriptionsession.ts +84 -0
- package/src/models/components/realtimetranscriptionsessioncreated.ts +64 -0
- package/src/models/components/realtimetranscriptionsessionupdated.ts +64 -0
- package/src/models/components/realtimetranscriptionsessionupdatemessage.ts +71 -0
- package/src/models/components/realtimetranscriptionsessionupdatepayload.ts +88 -0
- package/src/models/components/referencechunk.ts +4 -19
- package/src/models/components/responsedoneevent.ts +2 -13
- package/src/models/components/responseerrorevent.ts +2 -13
- package/src/models/components/responsestartedevent.ts +2 -15
- package/src/models/components/systemmessage.ts +3 -14
- package/src/models/components/textchunk.ts +4 -19
- package/src/models/components/thinkchunk.ts +23 -39
- package/src/models/components/timestampgranularity.ts +1 -0
- package/src/models/components/toolcallconfirmation.ts +50 -0
- package/src/models/components/toolconfiguration.ts +68 -0
- package/src/models/components/toolexecutiondeltaevent.ts +2 -17
- package/src/models/components/toolexecutiondoneevent.ts +2 -15
- package/src/models/components/toolexecutionentry.ts +8 -39
- package/src/models/components/toolexecutionstartedevent.ts +2 -17
- package/src/models/components/toolfilechunk.ts +4 -19
- package/src/models/components/toolmessage.ts +3 -14
- package/src/models/components/toolreferencechunk.ts +4 -19
- package/src/models/components/transcriptionsegmentchunk.ts +20 -19
- package/src/models/components/transcriptionstreamdone.ts +4 -25
- package/src/models/components/transcriptionstreamlanguage.ts +5 -24
- package/src/models/components/transcriptionstreamsegmentdelta.ts +10 -18
- package/src/models/components/transcriptionstreamtextdelta.ts +7 -24
- package/src/models/components/unarchiveftmodelout.ts +2 -15
- package/src/models/components/usermessage.ts +3 -14
- package/src/models/components/wandbintegration.ts +3 -14
- package/src/models/components/wandbintegrationout.ts +2 -15
- package/src/models/components/websearchpremiumtool.ts +19 -0
- package/src/models/components/websearchtool.ts +19 -0
- package/src/models/operations/agentsapiv1agentscreateorupdatealias.ts +46 -0
- package/src/models/operations/agentsapiv1agentsdeletealias.ts +41 -0
- package/src/models/operations/agentsapiv1agentsget.ts +19 -3
- package/src/models/operations/agentsapiv1agentsgetversion.ts +3 -3
- package/src/models/operations/agentsapiv1agentslist.ts +9 -0
- package/src/models/operations/agentsapiv1agentslistversionaliases.ts +40 -0
- package/src/models/operations/filesapirouteslistfiles.ts +3 -0
- package/src/models/operations/index.ts +3 -0
- package/src/models/operations/jobsapiroutesbatchgetbatchjobs.ts +15 -0
- package/src/sdk/mistralagents.ts +55 -1
- package/tests/extra/realtime.test.ts +389 -0
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import WebSocket from "ws";
|
|
2
|
+
import { SDK_METADATA } from "../../lib/config.js";
|
|
3
|
+
import { ClientSDK } from "../../lib/sdks.js";
|
|
4
|
+
import { extractSecurity, resolveGlobalSecurity } from "../../lib/security.js";
|
|
5
|
+
import type { AudioFormat } from "../../models/components/audioformat.js";
|
|
6
|
+
import type {
|
|
7
|
+
RealtimeTranscriptionError,
|
|
8
|
+
} from "../../models/components/realtimetranscriptionerror.js";
|
|
9
|
+
import type { RealtimeTranscriptionSession } from "../../models/components/realtimetranscriptionsession.js";
|
|
10
|
+
import type { RealtimeEvent } from "./connection.js";
|
|
11
|
+
import {
|
|
12
|
+
RealtimeConnection,
|
|
13
|
+
isUnknownRealtimeEvent,
|
|
14
|
+
parseRealtimeEventFromData,
|
|
15
|
+
} from "./connection.js";
|
|
16
|
+
import {
|
|
17
|
+
RealtimeTranscriptionException,
|
|
18
|
+
RealtimeTranscriptionWSError,
|
|
19
|
+
} from "./errors.js";
|
|
20
|
+
|
|
21
|
+
export type RealtimeConnectOptions = Readonly<{
|
|
22
|
+
audioFormat?: AudioFormat | undefined;
|
|
23
|
+
serverUrl?: string | undefined;
|
|
24
|
+
timeoutMs?: number | undefined;
|
|
25
|
+
httpHeaders?: Record<string, string> | undefined;
|
|
26
|
+
}>;
|
|
27
|
+
|
|
28
|
+
/** Client for realtime transcription over WebSocket. */
|
|
29
|
+
export class RealtimeTranscription extends ClientSDK {
|
|
30
|
+
async connect(
|
|
31
|
+
model: string,
|
|
32
|
+
options: RealtimeConnectOptions = {},
|
|
33
|
+
): Promise<RealtimeConnection> {
|
|
34
|
+
const securityInput = await extractSecurity(this._options.apiKey);
|
|
35
|
+
const resolvedSecurity = resolveGlobalSecurity(
|
|
36
|
+
securityInput == null ? {} : { apiKey: securityInput },
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const headers: Record<string, string> = {};
|
|
40
|
+
|
|
41
|
+
headers["User-Agent"] = this._options.userAgent ?? SDK_METADATA.userAgent;
|
|
42
|
+
|
|
43
|
+
if (resolvedSecurity?.headers) {
|
|
44
|
+
Object.assign(headers, resolvedSecurity.headers);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (options.httpHeaders) {
|
|
48
|
+
Object.assign(headers, options.httpHeaders);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const url = this.getWsUrl(model, {
|
|
52
|
+
serverUrl: options.serverUrl,
|
|
53
|
+
queryParams: resolvedSecurity?.queryParams ?? {},
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
let websocket: WebSocket | undefined;
|
|
57
|
+
try {
|
|
58
|
+
websocket = new WebSocket(url, { headers });
|
|
59
|
+
const { session, initialEvents } = await recvSession(
|
|
60
|
+
websocket,
|
|
61
|
+
options.timeoutMs ?? this._options.timeoutMs,
|
|
62
|
+
);
|
|
63
|
+
const connection = new RealtimeConnection(websocket, session, initialEvents);
|
|
64
|
+
|
|
65
|
+
if (options.audioFormat) {
|
|
66
|
+
await connection.updateSession(options.audioFormat);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return connection;
|
|
70
|
+
} catch (err) {
|
|
71
|
+
if (err instanceof RealtimeTranscriptionException) {
|
|
72
|
+
throw err;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (websocket) {
|
|
76
|
+
websocket.close();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
throw new RealtimeTranscriptionException(
|
|
80
|
+
`Failed to connect to transcription service: ${String(err)}`,
|
|
81
|
+
{ cause: err },
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async *transcribeStream(
|
|
87
|
+
audioStream: AsyncIterable<Uint8Array>,
|
|
88
|
+
model: string,
|
|
89
|
+
options: RealtimeConnectOptions = {},
|
|
90
|
+
): AsyncIterable<RealtimeEvent> {
|
|
91
|
+
const connection = await this.connect(model, options);
|
|
92
|
+
|
|
93
|
+
let stopRequested = false;
|
|
94
|
+
const sendAudioTask = (async () => {
|
|
95
|
+
try {
|
|
96
|
+
for await (const chunk of audioStream) {
|
|
97
|
+
if (stopRequested || connection.isClosed) {
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
await connection.sendAudio(chunk);
|
|
101
|
+
}
|
|
102
|
+
} finally {
|
|
103
|
+
if (!connection.isClosed) {
|
|
104
|
+
await connection.flushAudio();
|
|
105
|
+
}
|
|
106
|
+
await connection.endAudio();
|
|
107
|
+
}
|
|
108
|
+
})();
|
|
109
|
+
|
|
110
|
+
try {
|
|
111
|
+
for await (const event of connection) {
|
|
112
|
+
yield event;
|
|
113
|
+
|
|
114
|
+
if (event.type === "transcription.done") {
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (event.type === "error") {
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
} finally {
|
|
123
|
+
stopRequested = true;
|
|
124
|
+
|
|
125
|
+
await connection.close();
|
|
126
|
+
await sendAudioTask;
|
|
127
|
+
const maybeReturn =
|
|
128
|
+
(audioStream as { return?: () => Promise<IteratorResult<Uint8Array>> }).return;
|
|
129
|
+
if (typeof maybeReturn === "function") {
|
|
130
|
+
await maybeReturn.call(audioStream);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
private getWsUrl(
|
|
136
|
+
model: string,
|
|
137
|
+
options: { serverUrl?: string | undefined; queryParams: Record<string, string> },
|
|
138
|
+
): string {
|
|
139
|
+
const baseUrl = options.serverUrl ?? this._baseURL?.toString();
|
|
140
|
+
if (!baseUrl) {
|
|
141
|
+
throw new RealtimeTranscriptionException("No server URL configured.");
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const wsUrl = new URL(
|
|
145
|
+
"v1/audio/transcriptions/realtime",
|
|
146
|
+
normalizeBaseUrl(baseUrl),
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
const params = new URLSearchParams({ model });
|
|
150
|
+
for (const [key, value] of Object.entries(options.queryParams)) {
|
|
151
|
+
if (value) {
|
|
152
|
+
params.set(key, value);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
wsUrl.search = params.toString();
|
|
156
|
+
|
|
157
|
+
return wsUrl.toString();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
async function recvSession(
|
|
162
|
+
websocket: WebSocket,
|
|
163
|
+
timeoutMs?: number,
|
|
164
|
+
): Promise<{ session: RealtimeTranscriptionSession; initialEvents: RealtimeEvent[] }> {
|
|
165
|
+
let timeoutId: ReturnType<typeof setTimeout> | undefined;
|
|
166
|
+
const initialEvents: RealtimeEvent[] = [];
|
|
167
|
+
|
|
168
|
+
return new Promise((resolve, reject) => {
|
|
169
|
+
const cleanup = () => {
|
|
170
|
+
websocket.removeEventListener("message", handleMessage);
|
|
171
|
+
websocket.removeEventListener("close", handleClose);
|
|
172
|
+
websocket.removeEventListener("error", handleError);
|
|
173
|
+
if (timeoutId) {
|
|
174
|
+
clearTimeout(timeoutId);
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
const fail = (error: Error) => {
|
|
179
|
+
cleanup();
|
|
180
|
+
try {
|
|
181
|
+
websocket.close();
|
|
182
|
+
} catch (closeError) {
|
|
183
|
+
void closeError;
|
|
184
|
+
}
|
|
185
|
+
reject(error);
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
const handleMessage = (event: WebSocket.MessageEvent) => {
|
|
189
|
+
const parsed = parseRealtimeEventFromData(event.data);
|
|
190
|
+
initialEvents.push(parsed);
|
|
191
|
+
|
|
192
|
+
if (parsed.type === "error") {
|
|
193
|
+
if (isUnknownRealtimeEvent(parsed)) {
|
|
194
|
+
fail(new RealtimeTranscriptionWSError(
|
|
195
|
+
parsed.error?.message ?? "Realtime transcription error during handshake.",
|
|
196
|
+
{
|
|
197
|
+
rawPayload: parsed.raw,
|
|
198
|
+
cause: parsed.error,
|
|
199
|
+
},
|
|
200
|
+
));
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (isRealtimeErrorEvent(parsed)) {
|
|
205
|
+
const errorMessage = typeof parsed.error.message === "string"
|
|
206
|
+
? parsed.error.message
|
|
207
|
+
: JSON.stringify(parsed.error.message);
|
|
208
|
+
fail(new RealtimeTranscriptionWSError(
|
|
209
|
+
errorMessage,
|
|
210
|
+
{
|
|
211
|
+
payload: parsed,
|
|
212
|
+
code: parsed.error.code,
|
|
213
|
+
},
|
|
214
|
+
));
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (isUnknownRealtimeEvent(parsed)) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (isSessionCreatedEvent(parsed)) {
|
|
224
|
+
cleanup();
|
|
225
|
+
resolve({ session: parsed.session, initialEvents });
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
const handleClose = () => {
|
|
230
|
+
fail(new RealtimeTranscriptionException(
|
|
231
|
+
"Unexpected websocket handshake close.",
|
|
232
|
+
));
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
const handleError = (event: unknown) => {
|
|
236
|
+
fail(new RealtimeTranscriptionException(
|
|
237
|
+
"Failed to connect to transcription service.",
|
|
238
|
+
{ cause: normalizeWsError(event) },
|
|
239
|
+
));
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
websocket.addEventListener("message", handleMessage);
|
|
243
|
+
websocket.addEventListener("close", handleClose);
|
|
244
|
+
websocket.addEventListener("error", handleError);
|
|
245
|
+
|
|
246
|
+
if (timeoutMs && timeoutMs > 0) {
|
|
247
|
+
timeoutId = setTimeout(() => {
|
|
248
|
+
fail(new RealtimeTranscriptionException(
|
|
249
|
+
"Timeout waiting for session creation.",
|
|
250
|
+
));
|
|
251
|
+
}, timeoutMs);
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function normalizeWsError(event: unknown): Error {
|
|
257
|
+
if (event instanceof Error) {
|
|
258
|
+
return event;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (
|
|
262
|
+
typeof event === "object"
|
|
263
|
+
&& event !== null
|
|
264
|
+
&& "error" in event
|
|
265
|
+
&& (event as { error?: unknown }).error instanceof Error
|
|
266
|
+
) {
|
|
267
|
+
return (event as { error: Error }).error;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return new Error("WebSocket connection error");
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function isRealtimeErrorEvent(
|
|
274
|
+
event: RealtimeEvent,
|
|
275
|
+
): event is RealtimeTranscriptionError {
|
|
276
|
+
return !isUnknownRealtimeEvent(event) && "error" in event;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function isSessionCreatedEvent(
|
|
280
|
+
event: RealtimeEvent,
|
|
281
|
+
): event is { type: "session.created"; session: RealtimeTranscriptionSession } {
|
|
282
|
+
return !isUnknownRealtimeEvent(event)
|
|
283
|
+
&& "session" in event
|
|
284
|
+
&& event.type === "session.created";
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function normalizeBaseUrl(baseUrl: string): URL {
|
|
288
|
+
const url = new URL(baseUrl);
|
|
289
|
+
url.pathname = url.pathname.replace(/\/+$/, "") + "/";
|
|
290
|
+
return url;
|
|
291
|
+
}
|
package/src/extra/structChat.ts
CHANGED
|
@@ -66,7 +66,7 @@ export function convertToParsedChatCompletionResponse<T extends z.ZodTypeAny>(re
|
|
|
66
66
|
|
|
67
67
|
// Function to convert Zod schema to strict JSON schema
|
|
68
68
|
export function responseFormatFromZodObject<T extends z.ZodTypeAny>(responseFormat: T): ResponseFormat {
|
|
69
|
-
const responseJsonSchema = zodToJsonSchema(responseFormat);
|
|
69
|
+
const responseJsonSchema = zodToJsonSchema(responseFormat as z.ZodType<any, z.ZodTypeDef, any>);
|
|
70
70
|
// It is not possible to get the variable name of a Zod object at runtime in TypeScript so we're using a placeholder name.
|
|
71
71
|
// This has not impact on the parsing as the initial Zod object is used to parse the response.
|
|
72
72
|
const placeholderName = "placeholderName"
|
|
@@ -78,4 +78,4 @@ export function responseFormatFromZodObject<T extends z.ZodTypeAny>(responseForm
|
|
|
78
78
|
strict: true,
|
|
79
79
|
},
|
|
80
80
|
};
|
|
81
|
-
}
|
|
81
|
+
}
|
|
@@ -89,6 +89,12 @@ async function $do(
|
|
|
89
89
|
const body = new FormData();
|
|
90
90
|
|
|
91
91
|
appendForm(body, "model", payload.model);
|
|
92
|
+
if (payload.context_bias !== undefined) {
|
|
93
|
+
appendForm(body, "context_bias", payload.context_bias);
|
|
94
|
+
}
|
|
95
|
+
if (payload.diarize !== undefined) {
|
|
96
|
+
appendForm(body, "diarize", payload.diarize);
|
|
97
|
+
}
|
|
92
98
|
if (payload.file !== undefined) {
|
|
93
99
|
if (isBlobLike(payload.file)) {
|
|
94
100
|
appendForm(body, "file", payload.file);
|
|
@@ -92,6 +92,12 @@ async function $do(
|
|
|
92
92
|
const body = new FormData();
|
|
93
93
|
|
|
94
94
|
appendForm(body, "model", payload.model);
|
|
95
|
+
if (payload.context_bias !== undefined) {
|
|
96
|
+
appendForm(body, "context_bias", payload.context_bias);
|
|
97
|
+
}
|
|
98
|
+
if (payload.diarize !== undefined) {
|
|
99
|
+
appendForm(body, "diarize", payload.diarize);
|
|
100
|
+
}
|
|
95
101
|
if (payload.file !== undefined) {
|
|
96
102
|
if (isBlobLike(payload.file)) {
|
|
97
103
|
appendForm(body, "file", payload.file);
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { MistralCore } from "../core.js";
|
|
6
|
+
import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
|
|
7
|
+
import * as M from "../lib/matchers.js";
|
|
8
|
+
import { compactMap } from "../lib/primitives.js";
|
|
9
|
+
import { safeParse } from "../lib/schemas.js";
|
|
10
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
11
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
12
|
+
import { pathToFunc } from "../lib/url.js";
|
|
13
|
+
import * as components from "../models/components/index.js";
|
|
14
|
+
import {
|
|
15
|
+
ConnectionError,
|
|
16
|
+
InvalidRequestError,
|
|
17
|
+
RequestAbortedError,
|
|
18
|
+
RequestTimeoutError,
|
|
19
|
+
UnexpectedClientError,
|
|
20
|
+
} from "../models/errors/httpclienterrors.js";
|
|
21
|
+
import * as errors from "../models/errors/index.js";
|
|
22
|
+
import { MistralError } from "../models/errors/mistralerror.js";
|
|
23
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
24
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
25
|
+
import * as operations from "../models/operations/index.js";
|
|
26
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
27
|
+
import { Result } from "../types/fp.js";
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Create or update an agent version alias.
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* Create a new alias or update an existing alias to point to a specific version. Aliases are unique per agent and can be reassigned to different versions.
|
|
34
|
+
*/
|
|
35
|
+
export function betaAgentsCreateVersionAlias(
|
|
36
|
+
client: MistralCore,
|
|
37
|
+
request: operations.AgentsApiV1AgentsCreateOrUpdateAliasRequest,
|
|
38
|
+
options?: RequestOptions,
|
|
39
|
+
): APIPromise<
|
|
40
|
+
Result<
|
|
41
|
+
components.AgentAliasResponse,
|
|
42
|
+
| errors.HTTPValidationError
|
|
43
|
+
| MistralError
|
|
44
|
+
| ResponseValidationError
|
|
45
|
+
| ConnectionError
|
|
46
|
+
| RequestAbortedError
|
|
47
|
+
| RequestTimeoutError
|
|
48
|
+
| InvalidRequestError
|
|
49
|
+
| UnexpectedClientError
|
|
50
|
+
| SDKValidationError
|
|
51
|
+
>
|
|
52
|
+
> {
|
|
53
|
+
return new APIPromise($do(
|
|
54
|
+
client,
|
|
55
|
+
request,
|
|
56
|
+
options,
|
|
57
|
+
));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function $do(
|
|
61
|
+
client: MistralCore,
|
|
62
|
+
request: operations.AgentsApiV1AgentsCreateOrUpdateAliasRequest,
|
|
63
|
+
options?: RequestOptions,
|
|
64
|
+
): Promise<
|
|
65
|
+
[
|
|
66
|
+
Result<
|
|
67
|
+
components.AgentAliasResponse,
|
|
68
|
+
| errors.HTTPValidationError
|
|
69
|
+
| MistralError
|
|
70
|
+
| ResponseValidationError
|
|
71
|
+
| ConnectionError
|
|
72
|
+
| RequestAbortedError
|
|
73
|
+
| RequestTimeoutError
|
|
74
|
+
| InvalidRequestError
|
|
75
|
+
| UnexpectedClientError
|
|
76
|
+
| SDKValidationError
|
|
77
|
+
>,
|
|
78
|
+
APICall,
|
|
79
|
+
]
|
|
80
|
+
> {
|
|
81
|
+
const parsed = safeParse(
|
|
82
|
+
request,
|
|
83
|
+
(value) =>
|
|
84
|
+
operations.AgentsApiV1AgentsCreateOrUpdateAliasRequest$outboundSchema
|
|
85
|
+
.parse(value),
|
|
86
|
+
"Input validation failed",
|
|
87
|
+
);
|
|
88
|
+
if (!parsed.ok) {
|
|
89
|
+
return [parsed, { status: "invalid" }];
|
|
90
|
+
}
|
|
91
|
+
const payload = parsed.value;
|
|
92
|
+
const body = null;
|
|
93
|
+
|
|
94
|
+
const pathParams = {
|
|
95
|
+
agent_id: encodeSimple("agent_id", payload.agent_id, {
|
|
96
|
+
explode: false,
|
|
97
|
+
charEncoding: "percent",
|
|
98
|
+
}),
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const path = pathToFunc("/v1/agents/{agent_id}/aliases")(pathParams);
|
|
102
|
+
|
|
103
|
+
const query = encodeFormQuery({
|
|
104
|
+
"alias": payload.alias,
|
|
105
|
+
"version": payload.version,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const headers = new Headers(compactMap({
|
|
109
|
+
Accept: "application/json",
|
|
110
|
+
}));
|
|
111
|
+
|
|
112
|
+
const secConfig = await extractSecurity(client._options.apiKey);
|
|
113
|
+
const securityInput = secConfig == null ? {} : { apiKey: secConfig };
|
|
114
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
115
|
+
|
|
116
|
+
const context = {
|
|
117
|
+
options: client._options,
|
|
118
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
119
|
+
operationID: "agents_api_v1_agents_create_or_update_alias",
|
|
120
|
+
oAuth2Scopes: null,
|
|
121
|
+
|
|
122
|
+
resolvedSecurity: requestSecurity,
|
|
123
|
+
|
|
124
|
+
securitySource: client._options.apiKey,
|
|
125
|
+
retryConfig: options?.retries
|
|
126
|
+
|| client._options.retryConfig
|
|
127
|
+
|| { strategy: "none" },
|
|
128
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const requestRes = client._createRequest(context, {
|
|
132
|
+
security: requestSecurity,
|
|
133
|
+
method: "PUT",
|
|
134
|
+
baseURL: options?.serverURL,
|
|
135
|
+
path: path,
|
|
136
|
+
headers: headers,
|
|
137
|
+
query: query,
|
|
138
|
+
body: body,
|
|
139
|
+
userAgent: client._options.userAgent,
|
|
140
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
141
|
+
}, options);
|
|
142
|
+
if (!requestRes.ok) {
|
|
143
|
+
return [requestRes, { status: "invalid" }];
|
|
144
|
+
}
|
|
145
|
+
const req = requestRes.value;
|
|
146
|
+
|
|
147
|
+
const doResult = await client._do(req, {
|
|
148
|
+
context,
|
|
149
|
+
errorCodes: ["422", "4XX", "5XX"],
|
|
150
|
+
retryConfig: context.retryConfig,
|
|
151
|
+
retryCodes: context.retryCodes,
|
|
152
|
+
});
|
|
153
|
+
if (!doResult.ok) {
|
|
154
|
+
return [doResult, { status: "request-error", request: req }];
|
|
155
|
+
}
|
|
156
|
+
const response = doResult.value;
|
|
157
|
+
|
|
158
|
+
const responseFields = {
|
|
159
|
+
HttpMeta: { Response: response, Request: req },
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const [result] = await M.match<
|
|
163
|
+
components.AgentAliasResponse,
|
|
164
|
+
| errors.HTTPValidationError
|
|
165
|
+
| MistralError
|
|
166
|
+
| ResponseValidationError
|
|
167
|
+
| ConnectionError
|
|
168
|
+
| RequestAbortedError
|
|
169
|
+
| RequestTimeoutError
|
|
170
|
+
| InvalidRequestError
|
|
171
|
+
| UnexpectedClientError
|
|
172
|
+
| SDKValidationError
|
|
173
|
+
>(
|
|
174
|
+
M.json(200, components.AgentAliasResponse$inboundSchema),
|
|
175
|
+
M.jsonErr(422, errors.HTTPValidationError$inboundSchema),
|
|
176
|
+
M.fail("4XX"),
|
|
177
|
+
M.fail("5XX"),
|
|
178
|
+
)(response, req, { extraFields: responseFields });
|
|
179
|
+
if (!result.ok) {
|
|
180
|
+
return [result, { status: "complete", request: req, response }];
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return [result, { status: "complete", request: req, response }];
|
|
184
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v3";
|
|
6
|
+
import { MistralCore } from "../core.js";
|
|
7
|
+
import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
|
|
8
|
+
import * as M from "../lib/matchers.js";
|
|
9
|
+
import { compactMap } from "../lib/primitives.js";
|
|
10
|
+
import { safeParse } from "../lib/schemas.js";
|
|
11
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
12
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
13
|
+
import { pathToFunc } from "../lib/url.js";
|
|
14
|
+
import {
|
|
15
|
+
ConnectionError,
|
|
16
|
+
InvalidRequestError,
|
|
17
|
+
RequestAbortedError,
|
|
18
|
+
RequestTimeoutError,
|
|
19
|
+
UnexpectedClientError,
|
|
20
|
+
} from "../models/errors/httpclienterrors.js";
|
|
21
|
+
import * as errors from "../models/errors/index.js";
|
|
22
|
+
import { MistralError } from "../models/errors/mistralerror.js";
|
|
23
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
24
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
25
|
+
import * as operations from "../models/operations/index.js";
|
|
26
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
27
|
+
import { Result } from "../types/fp.js";
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Delete an agent version alias.
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* Delete an existing alias for an agent.
|
|
34
|
+
*/
|
|
35
|
+
export function betaAgentsDeleteVersionAlias(
|
|
36
|
+
client: MistralCore,
|
|
37
|
+
request: operations.AgentsApiV1AgentsDeleteAliasRequest,
|
|
38
|
+
options?: RequestOptions,
|
|
39
|
+
): APIPromise<
|
|
40
|
+
Result<
|
|
41
|
+
void,
|
|
42
|
+
| errors.HTTPValidationError
|
|
43
|
+
| MistralError
|
|
44
|
+
| ResponseValidationError
|
|
45
|
+
| ConnectionError
|
|
46
|
+
| RequestAbortedError
|
|
47
|
+
| RequestTimeoutError
|
|
48
|
+
| InvalidRequestError
|
|
49
|
+
| UnexpectedClientError
|
|
50
|
+
| SDKValidationError
|
|
51
|
+
>
|
|
52
|
+
> {
|
|
53
|
+
return new APIPromise($do(
|
|
54
|
+
client,
|
|
55
|
+
request,
|
|
56
|
+
options,
|
|
57
|
+
));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function $do(
|
|
61
|
+
client: MistralCore,
|
|
62
|
+
request: operations.AgentsApiV1AgentsDeleteAliasRequest,
|
|
63
|
+
options?: RequestOptions,
|
|
64
|
+
): Promise<
|
|
65
|
+
[
|
|
66
|
+
Result<
|
|
67
|
+
void,
|
|
68
|
+
| errors.HTTPValidationError
|
|
69
|
+
| MistralError
|
|
70
|
+
| ResponseValidationError
|
|
71
|
+
| ConnectionError
|
|
72
|
+
| RequestAbortedError
|
|
73
|
+
| RequestTimeoutError
|
|
74
|
+
| InvalidRequestError
|
|
75
|
+
| UnexpectedClientError
|
|
76
|
+
| SDKValidationError
|
|
77
|
+
>,
|
|
78
|
+
APICall,
|
|
79
|
+
]
|
|
80
|
+
> {
|
|
81
|
+
const parsed = safeParse(
|
|
82
|
+
request,
|
|
83
|
+
(value) =>
|
|
84
|
+
operations.AgentsApiV1AgentsDeleteAliasRequest$outboundSchema.parse(
|
|
85
|
+
value,
|
|
86
|
+
),
|
|
87
|
+
"Input validation failed",
|
|
88
|
+
);
|
|
89
|
+
if (!parsed.ok) {
|
|
90
|
+
return [parsed, { status: "invalid" }];
|
|
91
|
+
}
|
|
92
|
+
const payload = parsed.value;
|
|
93
|
+
const body = null;
|
|
94
|
+
|
|
95
|
+
const pathParams = {
|
|
96
|
+
agent_id: encodeSimple("agent_id", payload.agent_id, {
|
|
97
|
+
explode: false,
|
|
98
|
+
charEncoding: "percent",
|
|
99
|
+
}),
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const path = pathToFunc("/v1/agents/{agent_id}/aliases")(pathParams);
|
|
103
|
+
|
|
104
|
+
const query = encodeFormQuery({
|
|
105
|
+
"alias": payload.alias,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const headers = new Headers(compactMap({
|
|
109
|
+
Accept: "application/json",
|
|
110
|
+
}));
|
|
111
|
+
|
|
112
|
+
const secConfig = await extractSecurity(client._options.apiKey);
|
|
113
|
+
const securityInput = secConfig == null ? {} : { apiKey: secConfig };
|
|
114
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
115
|
+
|
|
116
|
+
const context = {
|
|
117
|
+
options: client._options,
|
|
118
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
119
|
+
operationID: "agents_api_v1_agents_delete_alias",
|
|
120
|
+
oAuth2Scopes: null,
|
|
121
|
+
|
|
122
|
+
resolvedSecurity: requestSecurity,
|
|
123
|
+
|
|
124
|
+
securitySource: client._options.apiKey,
|
|
125
|
+
retryConfig: options?.retries
|
|
126
|
+
|| client._options.retryConfig
|
|
127
|
+
|| { strategy: "none" },
|
|
128
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const requestRes = client._createRequest(context, {
|
|
132
|
+
security: requestSecurity,
|
|
133
|
+
method: "DELETE",
|
|
134
|
+
baseURL: options?.serverURL,
|
|
135
|
+
path: path,
|
|
136
|
+
headers: headers,
|
|
137
|
+
query: query,
|
|
138
|
+
body: body,
|
|
139
|
+
userAgent: client._options.userAgent,
|
|
140
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
141
|
+
}, options);
|
|
142
|
+
if (!requestRes.ok) {
|
|
143
|
+
return [requestRes, { status: "invalid" }];
|
|
144
|
+
}
|
|
145
|
+
const req = requestRes.value;
|
|
146
|
+
|
|
147
|
+
const doResult = await client._do(req, {
|
|
148
|
+
context,
|
|
149
|
+
errorCodes: ["422", "4XX", "5XX"],
|
|
150
|
+
retryConfig: context.retryConfig,
|
|
151
|
+
retryCodes: context.retryCodes,
|
|
152
|
+
});
|
|
153
|
+
if (!doResult.ok) {
|
|
154
|
+
return [doResult, { status: "request-error", request: req }];
|
|
155
|
+
}
|
|
156
|
+
const response = doResult.value;
|
|
157
|
+
|
|
158
|
+
const responseFields = {
|
|
159
|
+
HttpMeta: { Response: response, Request: req },
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const [result] = await M.match<
|
|
163
|
+
void,
|
|
164
|
+
| errors.HTTPValidationError
|
|
165
|
+
| MistralError
|
|
166
|
+
| ResponseValidationError
|
|
167
|
+
| ConnectionError
|
|
168
|
+
| RequestAbortedError
|
|
169
|
+
| RequestTimeoutError
|
|
170
|
+
| InvalidRequestError
|
|
171
|
+
| UnexpectedClientError
|
|
172
|
+
| SDKValidationError
|
|
173
|
+
>(
|
|
174
|
+
M.nil(204, z.void()),
|
|
175
|
+
M.jsonErr(422, errors.HTTPValidationError$inboundSchema),
|
|
176
|
+
M.fail("4XX"),
|
|
177
|
+
M.fail("5XX"),
|
|
178
|
+
)(response, req, { extraFields: responseFields });
|
|
179
|
+
if (!result.ok) {
|
|
180
|
+
return [result, { status: "complete", request: req, response }];
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return [result, { status: "complete", request: req, response }];
|
|
184
|
+
}
|