assemblyai 4.4.7 → 4.5.0
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/CHANGELOG.md +5 -0
- package/dist/assemblyai.umd.js +4 -1
- package/dist/assemblyai.umd.min.js +1 -1
- package/dist/browser.mjs +4 -1
- package/dist/bun.mjs +4 -1
- package/dist/deno.mjs +4 -1
- package/dist/index.cjs +4 -1
- package/dist/index.mjs +4 -1
- package/dist/node.cjs +4 -1
- package/dist/node.mjs +4 -1
- package/dist/services/lemur/index.d.ts +8 -1
- package/dist/types/openapi.generated.d.ts +43 -5
- package/dist/workerd.mjs +4 -1
- package/package.json +1 -1
- package/src/services/lemur/index.ts +12 -0
- package/src/types/openapi.generated.ts +49 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [4.5.0]
|
|
4
|
+
|
|
5
|
+
- You can now retrieve previous LeMUR responses using `client.lemur.getResponse<LemurTask>("YOUR_REQUEST_ID")`.
|
|
6
|
+
- LeMUR functions now return `usage` with the number of `input_tokens` and `output_tokens`.
|
|
7
|
+
|
|
3
8
|
## [4.4.7]
|
|
4
9
|
|
|
5
10
|
- Rename `TranscriptService.redactions` function to `TranscriptService.redactedAudio`.
|
package/dist/assemblyai.umd.js
CHANGED
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
defaultUserAgentString += navigator.userAgent;
|
|
66
66
|
}
|
|
67
67
|
const defaultUserAgent = {
|
|
68
|
-
sdk: { name: "JavaScript", version: "4.
|
|
68
|
+
sdk: { name: "JavaScript", version: "4.5.0" },
|
|
69
69
|
};
|
|
70
70
|
if (typeof process !== "undefined") {
|
|
71
71
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -179,6 +179,9 @@
|
|
|
179
179
|
body: JSON.stringify(params),
|
|
180
180
|
});
|
|
181
181
|
}
|
|
182
|
+
getResponse(id) {
|
|
183
|
+
return this.fetchJson(`/lemur/v3/${id}`);
|
|
184
|
+
}
|
|
182
185
|
/**
|
|
183
186
|
* Delete the data for a previously submitted LeMUR request.
|
|
184
187
|
* @param id - ID of the LeMUR request
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).assemblyai={})}(this,(function(e){"use strict";function t(e,t,s,i){return new(s||(s=Promise))((function(n,o){function r(e){try{d(i.next(e))}catch(e){o(e)}}function a(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(r,a)}d((i=i.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const s={cache:"no-store"};let i="";"undefined"!=typeof navigator&&navigator.userAgent&&(i+=navigator.userAgent);const n={sdk:{name:"JavaScript",version:"4.4.7"}};"undefined"!=typeof process&&(process.versions.node&&-1===i.indexOf("Node")&&(n.runtime_env={name:"Node",version:process.versions.node}),process.versions.bun&&-1===i.indexOf("Bun")&&(n.runtime_env={name:"Bun",version:process.versions.bun})),"undefined"!=typeof Deno&&process.versions.bun&&-1===i.indexOf("Deno")&&(n.runtime_env={name:"Deno",version:Deno.version.deno});class o{constructor(e){var t;this.params=e,!1===e.userAgent?this.userAgent=void 0:this.userAgent=(t=e.userAgent||{},i+(!1===t?"":" AssemblyAI/1.0 ("+Object.entries(Object.assign(Object.assign({},n),t)).map((([e,t])=>t?`${e}=${t.name}/${t.version}`:"")).join(" ")+")"))}fetch(e,i){return t(this,void 0,void 0,(function*(){i=Object.assign(Object.assign({},s),i);let t={Authorization:this.params.apiKey,"Content-Type":"application/json"};(null==s?void 0:s.headers)&&(t=Object.assign(Object.assign({},t),s.headers)),(null==i?void 0:i.headers)&&(t=Object.assign(Object.assign({},t),i.headers)),this.userAgent&&(t["User-Agent"]=this.userAgent,"undefined"!=typeof window&&"chrome"in window&&(t["AssemblyAI-Agent"]=this.userAgent)),i.headers=t,e.startsWith("http")||(e=this.params.baseUrl+e);const n=yield fetch(e,i);if(n.status>=400){let e;const t=yield n.text();if(t){try{e=JSON.parse(t)}catch(e){}if(null==e?void 0:e.error)throw new Error(e.error);throw new Error(t)}throw new Error(`HTTP Error: ${n.status} ${n.statusText}`)}return n}))}fetchJson(e,s){return t(this,void 0,void 0,(function*(){return(yield this.fetch(e,s)).json()}))}}class r extends o{summary(e){return this.fetchJson("/lemur/v3/generate/summary",{method:"POST",body:JSON.stringify(e)})}questionAnswer(e){return this.fetchJson("/lemur/v3/generate/question-answer",{method:"POST",body:JSON.stringify(e)})}actionItems(e){return this.fetchJson("/lemur/v3/generate/action-items",{method:"POST",body:JSON.stringify(e)})}task(e){return this.fetchJson("/lemur/v3/generate/task",{method:"POST",body:JSON.stringify(e)})}purgeRequestData(e){return this.fetchJson(`/lemur/v3/${e}`,{method:"DELETE"})}}const{WritableStream:a}="undefined"!=typeof window?window:"undefined"!=typeof global?global:globalThis;var d,c;const l=null!==(c=null!==(d=null!==WebSocket&&void 0!==WebSocket?WebSocket:null===global||void 0===global?void 0:global.WebSocket)&&void 0!==d?d:null===window||void 0===window?void 0:window.WebSocket)&&void 0!==c?c:null===self||void 0===self?void 0:self.WebSocket,u=(e,t)=>t?new l(e,t):new l(e);var h;!function(e){e[e.BadSampleRate=4e3]="BadSampleRate",e[e.AuthFailed=4001]="AuthFailed",e[e.InsufficientFundsOrFreeAccount=4002]="InsufficientFundsOrFreeAccount",e[e.NonexistentSessionId=4004]="NonexistentSessionId",e[e.SessionExpired=4008]="SessionExpired",e[e.ClosedSession=4010]="ClosedSession",e[e.RateLimited=4029]="RateLimited",e[e.UniqueSessionViolation=4030]="UniqueSessionViolation",e[e.SessionTimeout=4031]="SessionTimeout",e[e.AudioTooShort=4032]="AudioTooShort",e[e.AudioTooLong=4033]="AudioTooLong",e[e.BadJson=4100]="BadJson",e[e.BadSchema=4101]="BadSchema",e[e.TooManyStreams=4102]="TooManyStreams",e[e.Reconnected=4103]="Reconnected",e[e.ReconnectAttemptsExhausted=1013]="ReconnectAttemptsExhausted"}(h||(h={}));const f={[h.BadSampleRate]:"Sample rate must be a positive integer",[h.AuthFailed]:"Not Authorized",[h.InsufficientFundsOrFreeAccount]:"Insufficient funds or you are using a free account. This feature is paid-only and requires you to add a credit card. Please visit https://assemblyai.com/dashboard/ to add a credit card to your account.",[h.NonexistentSessionId]:"Session ID does not exist",[h.SessionExpired]:"Session has expired",[h.ClosedSession]:"Session is closed",[h.RateLimited]:"Rate limited",[h.UniqueSessionViolation]:"Unique session violation",[h.SessionTimeout]:"Session Timeout",[h.AudioTooShort]:"Audio too short",[h.AudioTooLong]:"Audio too long",[h.BadJson]:"Bad JSON",[h.BadSchema]:"Bad schema",[h.TooManyStreams]:"Too many streams",[h.Reconnected]:"Reconnected",[h.ReconnectAttemptsExhausted]:"Reconnect attempts exhausted"};class p extends Error{}const m='{"terminate_session":true}';class v{constructor(e){var t,s;if(this.listeners={},this.realtimeUrl=null!==(t=e.realtimeUrl)&&void 0!==t?t:"wss://api.assemblyai.com/v2/realtime/ws",this.sampleRate=null!==(s=e.sampleRate)&&void 0!==s?s:16e3,this.wordBoost=e.wordBoost,this.encoding=e.encoding,this.endUtteranceSilenceThreshold=e.endUtteranceSilenceThreshold,this.disablePartialTranscripts=e.disablePartialTranscripts,"token"in e&&e.token&&(this.token=e.token),"apiKey"in e&&e.apiKey&&(this.apiKey=e.apiKey),!this.token&&!this.apiKey)throw new Error("API key or temporary token is required.")}connectionUrl(){const e=new URL(this.realtimeUrl);if("wss:"!==e.protocol)throw new Error("Invalid protocol, must be wss");const t=new URLSearchParams;return this.token&&t.set("token",this.token),t.set("sample_rate",this.sampleRate.toString()),this.wordBoost&&this.wordBoost.length>0&&t.set("word_boost",JSON.stringify(this.wordBoost)),this.encoding&&t.set("encoding",this.encoding),t.set("enable_extra_session_information","true"),this.disablePartialTranscripts&&t.set("disable_partial_transcripts",this.disablePartialTranscripts.toString()),e.search=t.toString(),e}on(e,t){this.listeners[e]=t}connect(){return new Promise((e=>{if(this.socket)throw new Error("Already connected");const t=this.connectionUrl();this.token?this.socket=u(t.toString()):this.socket=u(t.toString(),{headers:{Authorization:this.apiKey}}),this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{void 0!==this.endUtteranceSilenceThreshold&&null!==this.endUtteranceSilenceThreshold&&this.configureEndUtteranceSilenceThreshold(this.endUtteranceSilenceThreshold)},this.socket.onclose=({code:e,reason:t})=>{var s,i;t||e in h&&(t=f[e]),null===(i=(s=this.listeners).close)||void 0===i||i.call(s,e,t)},this.socket.onerror=e=>{var t,s,i,n;e.error?null===(s=(t=this.listeners).error)||void 0===s||s.call(t,e.error):null===(n=(i=this.listeners).error)||void 0===n||n.call(i,new Error(e.message))},this.socket.onmessage=({data:t})=>{var s,i,n,o,r,a,d,c,l,u,h,f,m,v,y;const b=JSON.parse(t.toString());if("error"in b)null===(i=(s=this.listeners).error)||void 0===i||i.call(s,new p(b.error));else switch(b.message_type){case"SessionBegins":{const t={sessionId:b.session_id,expiresAt:new Date(b.expires_at)};e(t),null===(o=(n=this.listeners).open)||void 0===o||o.call(n,t);break}case"PartialTranscript":b.created=new Date(b.created),null===(a=(r=this.listeners).transcript)||void 0===a||a.call(r,b),null===(c=(d=this.listeners)["transcript.partial"])||void 0===c||c.call(d,b);break;case"FinalTranscript":b.created=new Date(b.created),null===(u=(l=this.listeners).transcript)||void 0===u||u.call(l,b),null===(f=(h=this.listeners)["transcript.final"])||void 0===f||f.call(h,b);break;case"SessionInformation":null===(v=(m=this.listeners).session_information)||void 0===v||v.call(m,b);break;case"SessionTerminated":null===(y=this.sessionTerminatedResolve)||void 0===y||y.call(this)}}}))}sendAudio(e){this.send(e)}stream(){return new a({write:e=>{this.sendAudio(e)}})}forceEndUtterance(){this.send('{"force_end_utterance":true}')}configureEndUtteranceSilenceThreshold(e){this.send(`{"end_utterance_silence_threshold":${e}}`)}send(e){if(!this.socket||this.socket.readyState!==this.socket.OPEN)throw new Error("Socket is not open for communication");this.socket.send(e)}close(){return t(this,arguments,void 0,(function*(e=!0){var t;if(this.socket){if(this.socket.readyState===this.socket.OPEN)if(e){const e=new Promise((e=>{this.sessionTerminatedResolve=e}));this.socket.send(m),yield e}else this.socket.send(m);(null===(t=this.socket)||void 0===t?void 0:t.removeAllListeners)&&this.socket.removeAllListeners(),this.socket.close()}this.listeners={},this.socket=void 0}))}}class y extends o{constructor(e){super(e),this.rtFactoryParams=e}createService(e){return this.transcriber(e)}transcriber(e){const t=Object.assign({},e);return t.token||t.apiKey||(t.apiKey=this.rtFactoryParams.apiKey),new v(t)}createTemporaryToken(e){return t(this,void 0,void 0,(function*(){return(yield this.fetchJson("/v2/realtime/token",{method:"POST",body:JSON.stringify(e)})).token}))}}function b(e){return e.startsWith("http")||e.startsWith("https")||e.startsWith("data:")?null:e.startsWith("file://")?e.substring(7):e.startsWith("file:")?e.substring(5):e}class S extends o{constructor(e,t){super(e),this.files=t}transcribe(e,s){return t(this,void 0,void 0,(function*(){w(e);const t=yield this.submit(e);return yield this.waitUntilReady(t.id,s)}))}submit(e){return t(this,void 0,void 0,(function*(){let t,s;if(w(e),"audio"in e){const{audio:i}=e,n=function(e,t){var s={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(s[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(i=Object.getOwnPropertySymbols(e);n<i.length;n++)t.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(s[i[n]]=e[i[n]])}return s}(e,["audio"]);if("string"==typeof i){const e=b(i);t=null!==e?yield this.files.upload(e):i.startsWith("data:")?yield this.files.upload(i):i}else t=yield this.files.upload(i);s=Object.assign(Object.assign({},n),{audio_url:t})}else s=e;return yield this.fetchJson("/v2/transcript",{method:"POST",body:JSON.stringify(s)})}))}create(e,s){return t(this,void 0,void 0,(function*(){var t;w(e);const i=b(e.audio_url);if(null!==i){const t=yield this.files.upload(i);e.audio_url=t}const n=yield this.fetchJson("/v2/transcript",{method:"POST",body:JSON.stringify(e)});return null===(t=null==s?void 0:s.poll)||void 0===t||t?yield this.waitUntilReady(n.id,s):n}))}waitUntilReady(e,s){return t(this,void 0,void 0,(function*(){var t,i;const n=null!==(t=null==s?void 0:s.pollingInterval)&&void 0!==t?t:3e3,o=null!==(i=null==s?void 0:s.pollingTimeout)&&void 0!==i?i:-1,r=Date.now();for(;;){const t=yield this.get(e);if("completed"===t.status||"error"===t.status)return t;if(o>0&&Date.now()-r>o)throw new Error("Polling timeout");yield new Promise((e=>setTimeout(e,n)))}}))}get(e){return this.fetchJson(`/v2/transcript/${e}`)}list(e){return t(this,void 0,void 0,(function*(){let t="/v2/transcript";"string"==typeof e?t=e:e&&(t=`${t}?${new URLSearchParams(Object.keys(e).map((t=>{var s;return[t,(null===(s=e[t])||void 0===s?void 0:s.toString())||""]})))}`);const s=yield this.fetchJson(t);for(const e of s.transcripts)e.created=new Date(e.created),e.completed&&(e.completed=new Date(e.completed));return s}))}delete(e){return this.fetchJson(`/v2/transcript/${e}`,{method:"DELETE"})}wordSearch(e,t){const s=new URLSearchParams({words:t.join(",")});return this.fetchJson(`/v2/transcript/${e}/word-search?${s.toString()}`)}sentences(e){return this.fetchJson(`/v2/transcript/${e}/sentences`)}paragraphs(e){return this.fetchJson(`/v2/transcript/${e}/paragraphs`)}subtitles(e){return t(this,arguments,void 0,(function*(e,t="srt",s){let i=`/v2/transcript/${e}/${t}`;if(s){const e=new URLSearchParams;e.set("chars_per_caption",s.toString()),i+=`?${e.toString()}`}const n=yield this.fetch(i);return yield n.text()}))}redactions(e){return this.redactedAudio(e)}redactedAudio(e){return this.fetchJson(`/v2/transcript/${e}/redacted-audio`)}redactedAudioFile(e){return t(this,void 0,void 0,(function*(){const{redacted_audio_url:t,status:s}=yield this.redactedAudio(e);if("redacted_audio_ready"!==s)throw new Error(`Redacted audio status is ${s}`);const i=yield fetch(t);if(!i.ok)throw new Error(`Failed to fetch redacted audio: ${i.statusText}`);return{arrayBuffer:i.arrayBuffer.bind(i),blob:i.blob.bind(i),body:i.body,bodyUsed:i.bodyUsed}}))}}function w(e){e&&"conformer-2"===e.speech_model&&console.warn("The speech_model conformer-2 option is deprecated and will stop working in the near future. Use best or nano instead.")}class g extends o{upload(e){return t(this,void 0,void 0,(function*(){let s;s="string"==typeof e?e.startsWith("data:")?function(e){const t=e.split(","),s=t[0].match(/:(.*?);/)[1],i=atob(t[1]);let n=i.length;const o=new Uint8Array(n);for(;n--;)o[n]=i.charCodeAt(n);return new Blob([o],{type:s})}(e):yield function(e){return t(this,void 0,void 0,(function*(){throw new Error("Interacting with the file system is not supported in this environment.")}))}():e;return(yield this.fetchJson("/v2/upload",{method:"POST",body:s,headers:{"Content-Type":"application/octet-stream"},duplex:"half"})).upload_url}))}}e.AssemblyAI=class{constructor(e){e.baseUrl=e.baseUrl||"https://api.assemblyai.com",e.baseUrl&&e.baseUrl.endsWith("/")&&(e.baseUrl=e.baseUrl.slice(0,-1)),this.files=new g(e),this.transcripts=new S(e,this.files),this.lemur=new r(e),this.realtime=new y(e)}},e.FileService=g,e.LemurService=r,e.RealtimeService=class extends v{},e.RealtimeServiceFactory=class extends y{},e.RealtimeTranscriber=v,e.RealtimeTranscriberFactory=y,e.TranscriptService=S}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).assemblyai={})}(this,(function(e){"use strict";function t(e,t,s,i){return new(s||(s=Promise))((function(n,o){function r(e){try{c(i.next(e))}catch(e){o(e)}}function a(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(r,a)}c((i=i.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const s={cache:"no-store"};let i="";"undefined"!=typeof navigator&&navigator.userAgent&&(i+=navigator.userAgent);const n={sdk:{name:"JavaScript",version:"4.5.0"}};"undefined"!=typeof process&&(process.versions.node&&-1===i.indexOf("Node")&&(n.runtime_env={name:"Node",version:process.versions.node}),process.versions.bun&&-1===i.indexOf("Bun")&&(n.runtime_env={name:"Bun",version:process.versions.bun})),"undefined"!=typeof Deno&&process.versions.bun&&-1===i.indexOf("Deno")&&(n.runtime_env={name:"Deno",version:Deno.version.deno});class o{constructor(e){var t;this.params=e,!1===e.userAgent?this.userAgent=void 0:this.userAgent=(t=e.userAgent||{},i+(!1===t?"":" AssemblyAI/1.0 ("+Object.entries(Object.assign(Object.assign({},n),t)).map((([e,t])=>t?`${e}=${t.name}/${t.version}`:"")).join(" ")+")"))}fetch(e,i){return t(this,void 0,void 0,(function*(){i=Object.assign(Object.assign({},s),i);let t={Authorization:this.params.apiKey,"Content-Type":"application/json"};(null==s?void 0:s.headers)&&(t=Object.assign(Object.assign({},t),s.headers)),(null==i?void 0:i.headers)&&(t=Object.assign(Object.assign({},t),i.headers)),this.userAgent&&(t["User-Agent"]=this.userAgent,"undefined"!=typeof window&&"chrome"in window&&(t["AssemblyAI-Agent"]=this.userAgent)),i.headers=t,e.startsWith("http")||(e=this.params.baseUrl+e);const n=yield fetch(e,i);if(n.status>=400){let e;const t=yield n.text();if(t){try{e=JSON.parse(t)}catch(e){}if(null==e?void 0:e.error)throw new Error(e.error);throw new Error(t)}throw new Error(`HTTP Error: ${n.status} ${n.statusText}`)}return n}))}fetchJson(e,s){return t(this,void 0,void 0,(function*(){return(yield this.fetch(e,s)).json()}))}}class r extends o{summary(e){return this.fetchJson("/lemur/v3/generate/summary",{method:"POST",body:JSON.stringify(e)})}questionAnswer(e){return this.fetchJson("/lemur/v3/generate/question-answer",{method:"POST",body:JSON.stringify(e)})}actionItems(e){return this.fetchJson("/lemur/v3/generate/action-items",{method:"POST",body:JSON.stringify(e)})}task(e){return this.fetchJson("/lemur/v3/generate/task",{method:"POST",body:JSON.stringify(e)})}getResponse(e){return this.fetchJson(`/lemur/v3/${e}`)}purgeRequestData(e){return this.fetchJson(`/lemur/v3/${e}`,{method:"DELETE"})}}const{WritableStream:a}="undefined"!=typeof window?window:"undefined"!=typeof global?global:globalThis;var c,d;const l=null!==(d=null!==(c=null!==WebSocket&&void 0!==WebSocket?WebSocket:null===global||void 0===global?void 0:global.WebSocket)&&void 0!==c?c:null===window||void 0===window?void 0:window.WebSocket)&&void 0!==d?d:null===self||void 0===self?void 0:self.WebSocket,u=(e,t)=>t?new l(e,t):new l(e);var h;!function(e){e[e.BadSampleRate=4e3]="BadSampleRate",e[e.AuthFailed=4001]="AuthFailed",e[e.InsufficientFundsOrFreeAccount=4002]="InsufficientFundsOrFreeAccount",e[e.NonexistentSessionId=4004]="NonexistentSessionId",e[e.SessionExpired=4008]="SessionExpired",e[e.ClosedSession=4010]="ClosedSession",e[e.RateLimited=4029]="RateLimited",e[e.UniqueSessionViolation=4030]="UniqueSessionViolation",e[e.SessionTimeout=4031]="SessionTimeout",e[e.AudioTooShort=4032]="AudioTooShort",e[e.AudioTooLong=4033]="AudioTooLong",e[e.BadJson=4100]="BadJson",e[e.BadSchema=4101]="BadSchema",e[e.TooManyStreams=4102]="TooManyStreams",e[e.Reconnected=4103]="Reconnected",e[e.ReconnectAttemptsExhausted=1013]="ReconnectAttemptsExhausted"}(h||(h={}));const f={[h.BadSampleRate]:"Sample rate must be a positive integer",[h.AuthFailed]:"Not Authorized",[h.InsufficientFundsOrFreeAccount]:"Insufficient funds or you are using a free account. This feature is paid-only and requires you to add a credit card. Please visit https://assemblyai.com/dashboard/ to add a credit card to your account.",[h.NonexistentSessionId]:"Session ID does not exist",[h.SessionExpired]:"Session has expired",[h.ClosedSession]:"Session is closed",[h.RateLimited]:"Rate limited",[h.UniqueSessionViolation]:"Unique session violation",[h.SessionTimeout]:"Session Timeout",[h.AudioTooShort]:"Audio too short",[h.AudioTooLong]:"Audio too long",[h.BadJson]:"Bad JSON",[h.BadSchema]:"Bad schema",[h.TooManyStreams]:"Too many streams",[h.Reconnected]:"Reconnected",[h.ReconnectAttemptsExhausted]:"Reconnect attempts exhausted"};class p extends Error{}const m='{"terminate_session":true}';class v{constructor(e){var t,s;if(this.listeners={},this.realtimeUrl=null!==(t=e.realtimeUrl)&&void 0!==t?t:"wss://api.assemblyai.com/v2/realtime/ws",this.sampleRate=null!==(s=e.sampleRate)&&void 0!==s?s:16e3,this.wordBoost=e.wordBoost,this.encoding=e.encoding,this.endUtteranceSilenceThreshold=e.endUtteranceSilenceThreshold,this.disablePartialTranscripts=e.disablePartialTranscripts,"token"in e&&e.token&&(this.token=e.token),"apiKey"in e&&e.apiKey&&(this.apiKey=e.apiKey),!this.token&&!this.apiKey)throw new Error("API key or temporary token is required.")}connectionUrl(){const e=new URL(this.realtimeUrl);if("wss:"!==e.protocol)throw new Error("Invalid protocol, must be wss");const t=new URLSearchParams;return this.token&&t.set("token",this.token),t.set("sample_rate",this.sampleRate.toString()),this.wordBoost&&this.wordBoost.length>0&&t.set("word_boost",JSON.stringify(this.wordBoost)),this.encoding&&t.set("encoding",this.encoding),t.set("enable_extra_session_information","true"),this.disablePartialTranscripts&&t.set("disable_partial_transcripts",this.disablePartialTranscripts.toString()),e.search=t.toString(),e}on(e,t){this.listeners[e]=t}connect(){return new Promise((e=>{if(this.socket)throw new Error("Already connected");const t=this.connectionUrl();this.token?this.socket=u(t.toString()):this.socket=u(t.toString(),{headers:{Authorization:this.apiKey}}),this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{void 0!==this.endUtteranceSilenceThreshold&&null!==this.endUtteranceSilenceThreshold&&this.configureEndUtteranceSilenceThreshold(this.endUtteranceSilenceThreshold)},this.socket.onclose=({code:e,reason:t})=>{var s,i;t||e in h&&(t=f[e]),null===(i=(s=this.listeners).close)||void 0===i||i.call(s,e,t)},this.socket.onerror=e=>{var t,s,i,n;e.error?null===(s=(t=this.listeners).error)||void 0===s||s.call(t,e.error):null===(n=(i=this.listeners).error)||void 0===n||n.call(i,new Error(e.message))},this.socket.onmessage=({data:t})=>{var s,i,n,o,r,a,c,d,l,u,h,f,m,v,y;const b=JSON.parse(t.toString());if("error"in b)null===(i=(s=this.listeners).error)||void 0===i||i.call(s,new p(b.error));else switch(b.message_type){case"SessionBegins":{const t={sessionId:b.session_id,expiresAt:new Date(b.expires_at)};e(t),null===(o=(n=this.listeners).open)||void 0===o||o.call(n,t);break}case"PartialTranscript":b.created=new Date(b.created),null===(a=(r=this.listeners).transcript)||void 0===a||a.call(r,b),null===(d=(c=this.listeners)["transcript.partial"])||void 0===d||d.call(c,b);break;case"FinalTranscript":b.created=new Date(b.created),null===(u=(l=this.listeners).transcript)||void 0===u||u.call(l,b),null===(f=(h=this.listeners)["transcript.final"])||void 0===f||f.call(h,b);break;case"SessionInformation":null===(v=(m=this.listeners).session_information)||void 0===v||v.call(m,b);break;case"SessionTerminated":null===(y=this.sessionTerminatedResolve)||void 0===y||y.call(this)}}}))}sendAudio(e){this.send(e)}stream(){return new a({write:e=>{this.sendAudio(e)}})}forceEndUtterance(){this.send('{"force_end_utterance":true}')}configureEndUtteranceSilenceThreshold(e){this.send(`{"end_utterance_silence_threshold":${e}}`)}send(e){if(!this.socket||this.socket.readyState!==this.socket.OPEN)throw new Error("Socket is not open for communication");this.socket.send(e)}close(){return t(this,arguments,void 0,(function*(e=!0){var t;if(this.socket){if(this.socket.readyState===this.socket.OPEN)if(e){const e=new Promise((e=>{this.sessionTerminatedResolve=e}));this.socket.send(m),yield e}else this.socket.send(m);(null===(t=this.socket)||void 0===t?void 0:t.removeAllListeners)&&this.socket.removeAllListeners(),this.socket.close()}this.listeners={},this.socket=void 0}))}}class y extends o{constructor(e){super(e),this.rtFactoryParams=e}createService(e){return this.transcriber(e)}transcriber(e){const t=Object.assign({},e);return t.token||t.apiKey||(t.apiKey=this.rtFactoryParams.apiKey),new v(t)}createTemporaryToken(e){return t(this,void 0,void 0,(function*(){return(yield this.fetchJson("/v2/realtime/token",{method:"POST",body:JSON.stringify(e)})).token}))}}function b(e){return e.startsWith("http")||e.startsWith("https")||e.startsWith("data:")?null:e.startsWith("file://")?e.substring(7):e.startsWith("file:")?e.substring(5):e}class S extends o{constructor(e,t){super(e),this.files=t}transcribe(e,s){return t(this,void 0,void 0,(function*(){g(e);const t=yield this.submit(e);return yield this.waitUntilReady(t.id,s)}))}submit(e){return t(this,void 0,void 0,(function*(){let t,s;if(g(e),"audio"in e){const{audio:i}=e,n=function(e,t){var s={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(s[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(i=Object.getOwnPropertySymbols(e);n<i.length;n++)t.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(s[i[n]]=e[i[n]])}return s}(e,["audio"]);if("string"==typeof i){const e=b(i);t=null!==e?yield this.files.upload(e):i.startsWith("data:")?yield this.files.upload(i):i}else t=yield this.files.upload(i);s=Object.assign(Object.assign({},n),{audio_url:t})}else s=e;return yield this.fetchJson("/v2/transcript",{method:"POST",body:JSON.stringify(s)})}))}create(e,s){return t(this,void 0,void 0,(function*(){var t;g(e);const i=b(e.audio_url);if(null!==i){const t=yield this.files.upload(i);e.audio_url=t}const n=yield this.fetchJson("/v2/transcript",{method:"POST",body:JSON.stringify(e)});return null===(t=null==s?void 0:s.poll)||void 0===t||t?yield this.waitUntilReady(n.id,s):n}))}waitUntilReady(e,s){return t(this,void 0,void 0,(function*(){var t,i;const n=null!==(t=null==s?void 0:s.pollingInterval)&&void 0!==t?t:3e3,o=null!==(i=null==s?void 0:s.pollingTimeout)&&void 0!==i?i:-1,r=Date.now();for(;;){const t=yield this.get(e);if("completed"===t.status||"error"===t.status)return t;if(o>0&&Date.now()-r>o)throw new Error("Polling timeout");yield new Promise((e=>setTimeout(e,n)))}}))}get(e){return this.fetchJson(`/v2/transcript/${e}`)}list(e){return t(this,void 0,void 0,(function*(){let t="/v2/transcript";"string"==typeof e?t=e:e&&(t=`${t}?${new URLSearchParams(Object.keys(e).map((t=>{var s;return[t,(null===(s=e[t])||void 0===s?void 0:s.toString())||""]})))}`);const s=yield this.fetchJson(t);for(const e of s.transcripts)e.created=new Date(e.created),e.completed&&(e.completed=new Date(e.completed));return s}))}delete(e){return this.fetchJson(`/v2/transcript/${e}`,{method:"DELETE"})}wordSearch(e,t){const s=new URLSearchParams({words:t.join(",")});return this.fetchJson(`/v2/transcript/${e}/word-search?${s.toString()}`)}sentences(e){return this.fetchJson(`/v2/transcript/${e}/sentences`)}paragraphs(e){return this.fetchJson(`/v2/transcript/${e}/paragraphs`)}subtitles(e){return t(this,arguments,void 0,(function*(e,t="srt",s){let i=`/v2/transcript/${e}/${t}`;if(s){const e=new URLSearchParams;e.set("chars_per_caption",s.toString()),i+=`?${e.toString()}`}const n=yield this.fetch(i);return yield n.text()}))}redactions(e){return this.redactedAudio(e)}redactedAudio(e){return this.fetchJson(`/v2/transcript/${e}/redacted-audio`)}redactedAudioFile(e){return t(this,void 0,void 0,(function*(){const{redacted_audio_url:t,status:s}=yield this.redactedAudio(e);if("redacted_audio_ready"!==s)throw new Error(`Redacted audio status is ${s}`);const i=yield fetch(t);if(!i.ok)throw new Error(`Failed to fetch redacted audio: ${i.statusText}`);return{arrayBuffer:i.arrayBuffer.bind(i),blob:i.blob.bind(i),body:i.body,bodyUsed:i.bodyUsed}}))}}function g(e){e&&"conformer-2"===e.speech_model&&console.warn("The speech_model conformer-2 option is deprecated and will stop working in the near future. Use best or nano instead.")}class w extends o{upload(e){return t(this,void 0,void 0,(function*(){let s;s="string"==typeof e?e.startsWith("data:")?function(e){const t=e.split(","),s=t[0].match(/:(.*?);/)[1],i=atob(t[1]);let n=i.length;const o=new Uint8Array(n);for(;n--;)o[n]=i.charCodeAt(n);return new Blob([o],{type:s})}(e):yield function(e){return t(this,void 0,void 0,(function*(){throw new Error("Interacting with the file system is not supported in this environment.")}))}():e;return(yield this.fetchJson("/v2/upload",{method:"POST",body:s,headers:{"Content-Type":"application/octet-stream"},duplex:"half"})).upload_url}))}}e.AssemblyAI=class{constructor(e){e.baseUrl=e.baseUrl||"https://api.assemblyai.com",e.baseUrl&&e.baseUrl.endsWith("/")&&(e.baseUrl=e.baseUrl.slice(0,-1)),this.files=new w(e),this.transcripts=new S(e,this.files),this.lemur=new r(e),this.realtime=new y(e)}},e.FileService=w,e.LemurService=r,e.RealtimeService=class extends v{},e.RealtimeServiceFactory=class extends y{},e.RealtimeTranscriber=v,e.RealtimeTranscriberFactory=y,e.TranscriptService=S}));
|
package/dist/browser.mjs
CHANGED
|
@@ -15,7 +15,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
|
|
|
15
15
|
defaultUserAgentString += navigator.userAgent;
|
|
16
16
|
}
|
|
17
17
|
const defaultUserAgent = {
|
|
18
|
-
sdk: { name: "JavaScript", version: "4.
|
|
18
|
+
sdk: { name: "JavaScript", version: "4.5.0" },
|
|
19
19
|
};
|
|
20
20
|
if (typeof process !== "undefined") {
|
|
21
21
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -125,6 +125,9 @@ class LemurService extends BaseService {
|
|
|
125
125
|
body: JSON.stringify(params),
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
|
+
getResponse(id) {
|
|
129
|
+
return this.fetchJson(`/lemur/v3/${id}`);
|
|
130
|
+
}
|
|
128
131
|
/**
|
|
129
132
|
* Delete the data for a previously submitted LeMUR request.
|
|
130
133
|
* @param id - ID of the LeMUR request
|
package/dist/bun.mjs
CHANGED
|
@@ -17,7 +17,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
|
|
|
17
17
|
defaultUserAgentString += navigator.userAgent;
|
|
18
18
|
}
|
|
19
19
|
const defaultUserAgent = {
|
|
20
|
-
sdk: { name: "JavaScript", version: "4.
|
|
20
|
+
sdk: { name: "JavaScript", version: "4.5.0" },
|
|
21
21
|
};
|
|
22
22
|
if (typeof process !== "undefined") {
|
|
23
23
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -127,6 +127,9 @@ class LemurService extends BaseService {
|
|
|
127
127
|
body: JSON.stringify(params),
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
|
+
getResponse(id) {
|
|
131
|
+
return this.fetchJson(`/lemur/v3/${id}`);
|
|
132
|
+
}
|
|
130
133
|
/**
|
|
131
134
|
* Delete the data for a previously submitted LeMUR request.
|
|
132
135
|
* @param id - ID of the LeMUR request
|
package/dist/deno.mjs
CHANGED
|
@@ -17,7 +17,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
|
|
|
17
17
|
defaultUserAgentString += navigator.userAgent;
|
|
18
18
|
}
|
|
19
19
|
const defaultUserAgent = {
|
|
20
|
-
sdk: { name: "JavaScript", version: "4.
|
|
20
|
+
sdk: { name: "JavaScript", version: "4.5.0" },
|
|
21
21
|
};
|
|
22
22
|
if (typeof process !== "undefined") {
|
|
23
23
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -127,6 +127,9 @@ class LemurService extends BaseService {
|
|
|
127
127
|
body: JSON.stringify(params),
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
|
+
getResponse(id) {
|
|
131
|
+
return this.fetchJson(`/lemur/v3/${id}`);
|
|
132
|
+
}
|
|
130
133
|
/**
|
|
131
134
|
* Delete the data for a previously submitted LeMUR request.
|
|
132
135
|
* @param id - ID of the LeMUR request
|
package/dist/index.cjs
CHANGED
|
@@ -63,7 +63,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
|
|
|
63
63
|
defaultUserAgentString += navigator.userAgent;
|
|
64
64
|
}
|
|
65
65
|
const defaultUserAgent = {
|
|
66
|
-
sdk: { name: "JavaScript", version: "4.
|
|
66
|
+
sdk: { name: "JavaScript", version: "4.5.0" },
|
|
67
67
|
};
|
|
68
68
|
if (typeof process !== "undefined") {
|
|
69
69
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -177,6 +177,9 @@ class LemurService extends BaseService {
|
|
|
177
177
|
body: JSON.stringify(params),
|
|
178
178
|
});
|
|
179
179
|
}
|
|
180
|
+
getResponse(id) {
|
|
181
|
+
return this.fetchJson(`/lemur/v3/${id}`);
|
|
182
|
+
}
|
|
180
183
|
/**
|
|
181
184
|
* Delete the data for a previously submitted LeMUR request.
|
|
182
185
|
* @param id - ID of the LeMUR request
|
package/dist/index.mjs
CHANGED
|
@@ -61,7 +61,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
|
|
|
61
61
|
defaultUserAgentString += navigator.userAgent;
|
|
62
62
|
}
|
|
63
63
|
const defaultUserAgent = {
|
|
64
|
-
sdk: { name: "JavaScript", version: "4.
|
|
64
|
+
sdk: { name: "JavaScript", version: "4.5.0" },
|
|
65
65
|
};
|
|
66
66
|
if (typeof process !== "undefined") {
|
|
67
67
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -175,6 +175,9 @@ class LemurService extends BaseService {
|
|
|
175
175
|
body: JSON.stringify(params),
|
|
176
176
|
});
|
|
177
177
|
}
|
|
178
|
+
getResponse(id) {
|
|
179
|
+
return this.fetchJson(`/lemur/v3/${id}`);
|
|
180
|
+
}
|
|
178
181
|
/**
|
|
179
182
|
* Delete the data for a previously submitted LeMUR request.
|
|
180
183
|
* @param id - ID of the LeMUR request
|
package/dist/node.cjs
CHANGED
|
@@ -22,7 +22,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
|
|
|
22
22
|
defaultUserAgentString += navigator.userAgent;
|
|
23
23
|
}
|
|
24
24
|
const defaultUserAgent = {
|
|
25
|
-
sdk: { name: "JavaScript", version: "4.
|
|
25
|
+
sdk: { name: "JavaScript", version: "4.5.0" },
|
|
26
26
|
};
|
|
27
27
|
if (typeof process !== "undefined") {
|
|
28
28
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -132,6 +132,9 @@ class LemurService extends BaseService {
|
|
|
132
132
|
body: JSON.stringify(params),
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
|
+
getResponse(id) {
|
|
136
|
+
return this.fetchJson(`/lemur/v3/${id}`);
|
|
137
|
+
}
|
|
135
138
|
/**
|
|
136
139
|
* Delete the data for a previously submitted LeMUR request.
|
|
137
140
|
* @param id - ID of the LeMUR request
|
package/dist/node.mjs
CHANGED
|
@@ -20,7 +20,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
|
|
|
20
20
|
defaultUserAgentString += navigator.userAgent;
|
|
21
21
|
}
|
|
22
22
|
const defaultUserAgent = {
|
|
23
|
-
sdk: { name: "JavaScript", version: "4.
|
|
23
|
+
sdk: { name: "JavaScript", version: "4.5.0" },
|
|
24
24
|
};
|
|
25
25
|
if (typeof process !== "undefined") {
|
|
26
26
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -130,6 +130,9 @@ class LemurService extends BaseService {
|
|
|
130
130
|
body: JSON.stringify(params),
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
|
+
getResponse(id) {
|
|
134
|
+
return this.fetchJson(`/lemur/v3/${id}`);
|
|
135
|
+
}
|
|
133
136
|
/**
|
|
134
137
|
* Delete the data for a previously submitted LeMUR request.
|
|
135
138
|
* @param id - ID of the LeMUR request
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import { LemurSummaryParams, LemurActionItemsParams, LemurQuestionAnswerParams, LemurTaskParams, LemurSummaryResponse, LemurQuestionAnswerResponse, LemurActionItemsResponse, LemurTaskResponse, PurgeLemurRequestDataResponse } from "../..";
|
|
1
|
+
import { LemurSummaryParams, LemurActionItemsParams, LemurQuestionAnswerParams, LemurTaskParams, LemurSummaryResponse, LemurQuestionAnswerResponse, LemurActionItemsResponse, LemurTaskResponse, PurgeLemurRequestDataResponse, LemurResponse } from "../..";
|
|
2
2
|
import { BaseService } from "../base";
|
|
3
3
|
export declare class LemurService extends BaseService {
|
|
4
4
|
summary(params: LemurSummaryParams): Promise<LemurSummaryResponse>;
|
|
5
5
|
questionAnswer(params: LemurQuestionAnswerParams): Promise<LemurQuestionAnswerResponse>;
|
|
6
6
|
actionItems(params: LemurActionItemsParams): Promise<LemurActionItemsResponse>;
|
|
7
7
|
task(params: LemurTaskParams): Promise<LemurTaskResponse>;
|
|
8
|
+
/**
|
|
9
|
+
* Retrieve a LeMUR response that was previously generated.
|
|
10
|
+
* @param id - The ID of the LeMUR request you previously made. This would be found in the response of the original request.
|
|
11
|
+
* @returns The LeMUR response.
|
|
12
|
+
*/
|
|
13
|
+
getResponse<T extends LemurResponse>(id: string): Promise<T>;
|
|
14
|
+
getResponse(id: string): Promise<LemurResponse>;
|
|
8
15
|
/**
|
|
9
16
|
* Delete the data for a previously submitted LeMUR request.
|
|
10
17
|
* @param id - ID of the LeMUR request
|
|
@@ -521,7 +521,11 @@ export type LemurActionItemsParams = LemurBaseParams & {
|
|
|
521
521
|
* ```js
|
|
522
522
|
* {
|
|
523
523
|
* "request_id": "5"e1b27c2-691f-4414-8bc5-f14678442f9e",
|
|
524
|
-
* "response": "Here are some potential action items based on the transcript:\n\n- Monitor air quality levels in affected areas and issue warnings as needed.\n\n- Advise vulnerable populations like children, the elderly, and those with respiratory conditions to limit time outdoors.\n\n- Have schools cancel outdoor activities when air quality is poor.\n\n- Educate the public on health impacts of smoke inhalation and precautions to take.\n\n- Track progression of smoke plumes using weather and air quality monitoring systems.\n\n- Coordinate cross-regionally to manage smoke exposure as air masses shift.\n\n- Plan for likely increase in such events due to climate change. Expand monitoring and forecasting capabilities.\n\n- Conduct research to better understand health impacts of wildfire smoke and mitigation strategies.\n\n- Develop strategies to prevent and manage wildfires to limit air quality impacts.\n"
|
|
524
|
+
* "response": "Here are some potential action items based on the transcript:\n\n- Monitor air quality levels in affected areas and issue warnings as needed.\n\n- Advise vulnerable populations like children, the elderly, and those with respiratory conditions to limit time outdoors.\n\n- Have schools cancel outdoor activities when air quality is poor.\n\n- Educate the public on health impacts of smoke inhalation and precautions to take.\n\n- Track progression of smoke plumes using weather and air quality monitoring systems.\n\n- Coordinate cross-regionally to manage smoke exposure as air masses shift.\n\n- Plan for likely increase in such events due to climate change. Expand monitoring and forecasting capabilities.\n\n- Conduct research to better understand health impacts of wildfire smoke and mitigation strategies.\n\n- Develop strategies to prevent and manage wildfires to limit air quality impacts.\n",
|
|
525
|
+
* "usage": {
|
|
526
|
+
* "input_tokens": 27,
|
|
527
|
+
* "output_tokens": 3
|
|
528
|
+
* }
|
|
525
529
|
* }
|
|
526
530
|
* ```
|
|
527
531
|
*/
|
|
@@ -588,7 +592,11 @@ export type LemurBaseParams = {
|
|
|
588
592
|
* @example
|
|
589
593
|
* ```js
|
|
590
594
|
* {
|
|
591
|
-
* "request_id": "5e1b27c2-691f-4414-8bc5-f14678442f9e"
|
|
595
|
+
* "request_id": "5e1b27c2-691f-4414-8bc5-f14678442f9e",
|
|
596
|
+
* "usage": {
|
|
597
|
+
* "input_tokens": 27,
|
|
598
|
+
* "output_tokens": 3
|
|
599
|
+
* }
|
|
592
600
|
* }
|
|
593
601
|
* ```
|
|
594
602
|
*/
|
|
@@ -597,6 +605,10 @@ export type LemurBaseResponse = {
|
|
|
597
605
|
* The ID of the LeMUR request
|
|
598
606
|
*/
|
|
599
607
|
request_id: string;
|
|
608
|
+
/**
|
|
609
|
+
* The usage numbers for the LeMUR request
|
|
610
|
+
*/
|
|
611
|
+
usage: LemurUsage;
|
|
600
612
|
};
|
|
601
613
|
/**
|
|
602
614
|
* The model that is used for the final prompt after compression is performed.
|
|
@@ -706,7 +718,11 @@ export type LemurQuestionAnswerParams = LemurBaseParams & {
|
|
|
706
718
|
* "answer": "yes",
|
|
707
719
|
* "question": "Is global warming affecting wildfires?"
|
|
708
720
|
* }
|
|
709
|
-
* ]
|
|
721
|
+
* ],
|
|
722
|
+
* "usage": {
|
|
723
|
+
* "input_tokens": 27,
|
|
724
|
+
* "output_tokens": 3
|
|
725
|
+
* }
|
|
710
726
|
* }
|
|
711
727
|
* ```
|
|
712
728
|
*/
|
|
@@ -716,6 +732,7 @@ export type LemurQuestionAnswerResponse = LemurBaseResponse & {
|
|
|
716
732
|
*/
|
|
717
733
|
response: LemurQuestionAnswer[];
|
|
718
734
|
};
|
|
735
|
+
export type LemurResponse = LemurTaskResponse | LemurSummaryResponse | LemurQuestionAnswerResponse | LemurActionItemsResponse;
|
|
719
736
|
/**
|
|
720
737
|
* @example
|
|
721
738
|
* ```js
|
|
@@ -741,7 +758,11 @@ export type LemurSummaryParams = LemurBaseParams & {
|
|
|
741
758
|
* ```js
|
|
742
759
|
* {
|
|
743
760
|
* "request_id": "5e1b27c2-691f-4414-8bc5-f14678442f9e",
|
|
744
|
-
* "response": "- Wildfires in Canada are sending smoke and air pollution across parts of the US, triggering air quality alerts from Maine to Minnesota. Concentrations of particulate matter have exceeded safety levels.\n\n- Weather systems are channeling the smoke through Pennsylvania into the Mid-Atlantic and Northeast regions. New York City has canceled outdoor activities to keep children and vulnerable groups indoors.\n\n- Very small particulate matter can enter the lungs and impact respiratory, cardiovascular and neurological health. Young children, the elderly and those with preexisting conditions are most at risk.\n\n- The conditions causing the poor air quality could get worse or shift to different areas in coming days depending on weather patterns. More wildfires may also contribute to higher concentrations.\n\n- Climate change is leading to longer and more severe fire seasons. Events of smoke traveling long distances and affecting air quality over wide areas will likely become more common in the future.\"\n"
|
|
761
|
+
* "response": "- Wildfires in Canada are sending smoke and air pollution across parts of the US, triggering air quality alerts from Maine to Minnesota. Concentrations of particulate matter have exceeded safety levels.\n\n- Weather systems are channeling the smoke through Pennsylvania into the Mid-Atlantic and Northeast regions. New York City has canceled outdoor activities to keep children and vulnerable groups indoors.\n\n- Very small particulate matter can enter the lungs and impact respiratory, cardiovascular and neurological health. Young children, the elderly and those with preexisting conditions are most at risk.\n\n- The conditions causing the poor air quality could get worse or shift to different areas in coming days depending on weather patterns. More wildfires may also contribute to higher concentrations.\n\n- Climate change is leading to longer and more severe fire seasons. Events of smoke traveling long distances and affecting air quality over wide areas will likely become more common in the future.\"\n",
|
|
762
|
+
* "usage": {
|
|
763
|
+
* "input_tokens": 27,
|
|
764
|
+
* "output_tokens": 3
|
|
765
|
+
* }
|
|
745
766
|
* }
|
|
746
767
|
* ```
|
|
747
768
|
*/
|
|
@@ -777,7 +798,11 @@ export type LemurTaskParams = {
|
|
|
777
798
|
* ```js
|
|
778
799
|
* {
|
|
779
800
|
* "request_id": "5e1b27c2-691f-4414-8bc5-f14678442f9e",
|
|
780
|
-
* "response": "Based on the transcript, the following locations were mentioned as being affected by wildfire smoke from Canada:\n\n- Maine\n- Maryland\n- Minnesota\n- Mid Atlantic region\n- Northeast region\n- New York City\n- Baltimore\n"
|
|
801
|
+
* "response": "Based on the transcript, the following locations were mentioned as being affected by wildfire smoke from Canada:\n\n- Maine\n- Maryland\n- Minnesota\n- Mid Atlantic region\n- Northeast region\n- New York City\n- Baltimore\n",
|
|
802
|
+
* "usage": {
|
|
803
|
+
* "input_tokens": 27,
|
|
804
|
+
* "output_tokens": 3
|
|
805
|
+
* }
|
|
781
806
|
* }
|
|
782
807
|
* ```
|
|
783
808
|
*/
|
|
@@ -787,6 +812,19 @@ export type LemurTaskResponse = {
|
|
|
787
812
|
*/
|
|
788
813
|
response: string;
|
|
789
814
|
} & LemurBaseResponse;
|
|
815
|
+
/**
|
|
816
|
+
* The usage numbers for the LeMUR request
|
|
817
|
+
*/
|
|
818
|
+
export type LemurUsage = {
|
|
819
|
+
/**
|
|
820
|
+
* The number of input tokens used by the model
|
|
821
|
+
*/
|
|
822
|
+
input_tokens: number;
|
|
823
|
+
/**
|
|
824
|
+
* The number of output tokens generated by the model
|
|
825
|
+
*/
|
|
826
|
+
output_tokens: number;
|
|
827
|
+
};
|
|
790
828
|
/**
|
|
791
829
|
* @example
|
|
792
830
|
* ```js
|
package/dist/workerd.mjs
CHANGED
|
@@ -15,7 +15,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
|
|
|
15
15
|
defaultUserAgentString += navigator.userAgent;
|
|
16
16
|
}
|
|
17
17
|
const defaultUserAgent = {
|
|
18
|
-
sdk: { name: "JavaScript", version: "4.
|
|
18
|
+
sdk: { name: "JavaScript", version: "4.5.0" },
|
|
19
19
|
};
|
|
20
20
|
if (typeof process !== "undefined") {
|
|
21
21
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -125,6 +125,9 @@ class LemurService extends BaseService {
|
|
|
125
125
|
body: JSON.stringify(params),
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
|
+
getResponse(id) {
|
|
129
|
+
return this.fetchJson(`/lemur/v3/${id}`);
|
|
130
|
+
}
|
|
128
131
|
/**
|
|
129
132
|
* Delete the data for a previously submitted LeMUR request.
|
|
130
133
|
* @param id - ID of the LeMUR request
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "assemblyai",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"description": "The AssemblyAI JavaScript SDK provides an easy-to-use interface for interacting with the AssemblyAI API, which supports async and real-time transcription, as well as the latest LeMUR models.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18"
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
LemurActionItemsResponse,
|
|
9
9
|
LemurTaskResponse,
|
|
10
10
|
PurgeLemurRequestDataResponse,
|
|
11
|
+
LemurResponse,
|
|
11
12
|
} from "../..";
|
|
12
13
|
import { BaseService } from "../base";
|
|
13
14
|
|
|
@@ -50,6 +51,17 @@ export class LemurService extends BaseService {
|
|
|
50
51
|
});
|
|
51
52
|
}
|
|
52
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Retrieve a LeMUR response that was previously generated.
|
|
56
|
+
* @param id - The ID of the LeMUR request you previously made. This would be found in the response of the original request.
|
|
57
|
+
* @returns The LeMUR response.
|
|
58
|
+
*/
|
|
59
|
+
getResponse<T extends LemurResponse>(id: string): Promise<T>;
|
|
60
|
+
getResponse(id: string): Promise<LemurResponse>;
|
|
61
|
+
getResponse(id: string): Promise<LemurResponse> {
|
|
62
|
+
return this.fetchJson<LemurResponse>(`/lemur/v3/${id}`);
|
|
63
|
+
}
|
|
64
|
+
|
|
53
65
|
/**
|
|
54
66
|
* Delete the data for a previously submitted LeMUR request.
|
|
55
67
|
* @param id - ID of the LeMUR request
|
|
@@ -588,7 +588,11 @@ export type LemurActionItemsParams = LemurBaseParams & {
|
|
|
588
588
|
* ```js
|
|
589
589
|
* {
|
|
590
590
|
* "request_id": "5"e1b27c2-691f-4414-8bc5-f14678442f9e",
|
|
591
|
-
* "response": "Here are some potential action items based on the transcript:\n\n- Monitor air quality levels in affected areas and issue warnings as needed.\n\n- Advise vulnerable populations like children, the elderly, and those with respiratory conditions to limit time outdoors.\n\n- Have schools cancel outdoor activities when air quality is poor.\n\n- Educate the public on health impacts of smoke inhalation and precautions to take.\n\n- Track progression of smoke plumes using weather and air quality monitoring systems.\n\n- Coordinate cross-regionally to manage smoke exposure as air masses shift.\n\n- Plan for likely increase in such events due to climate change. Expand monitoring and forecasting capabilities.\n\n- Conduct research to better understand health impacts of wildfire smoke and mitigation strategies.\n\n- Develop strategies to prevent and manage wildfires to limit air quality impacts.\n"
|
|
591
|
+
* "response": "Here are some potential action items based on the transcript:\n\n- Monitor air quality levels in affected areas and issue warnings as needed.\n\n- Advise vulnerable populations like children, the elderly, and those with respiratory conditions to limit time outdoors.\n\n- Have schools cancel outdoor activities when air quality is poor.\n\n- Educate the public on health impacts of smoke inhalation and precautions to take.\n\n- Track progression of smoke plumes using weather and air quality monitoring systems.\n\n- Coordinate cross-regionally to manage smoke exposure as air masses shift.\n\n- Plan for likely increase in such events due to climate change. Expand monitoring and forecasting capabilities.\n\n- Conduct research to better understand health impacts of wildfire smoke and mitigation strategies.\n\n- Develop strategies to prevent and manage wildfires to limit air quality impacts.\n",
|
|
592
|
+
* "usage": {
|
|
593
|
+
* "input_tokens": 27,
|
|
594
|
+
* "output_tokens": 3
|
|
595
|
+
* }
|
|
592
596
|
* }
|
|
593
597
|
* ```
|
|
594
598
|
*/
|
|
@@ -659,7 +663,11 @@ export type LemurBaseParams = {
|
|
|
659
663
|
* @example
|
|
660
664
|
* ```js
|
|
661
665
|
* {
|
|
662
|
-
* "request_id": "5e1b27c2-691f-4414-8bc5-f14678442f9e"
|
|
666
|
+
* "request_id": "5e1b27c2-691f-4414-8bc5-f14678442f9e",
|
|
667
|
+
* "usage": {
|
|
668
|
+
* "input_tokens": 27,
|
|
669
|
+
* "output_tokens": 3
|
|
670
|
+
* }
|
|
663
671
|
* }
|
|
664
672
|
* ```
|
|
665
673
|
*/
|
|
@@ -668,6 +676,10 @@ export type LemurBaseResponse = {
|
|
|
668
676
|
* The ID of the LeMUR request
|
|
669
677
|
*/
|
|
670
678
|
request_id: string;
|
|
679
|
+
/**
|
|
680
|
+
* The usage numbers for the LeMUR request
|
|
681
|
+
*/
|
|
682
|
+
usage: LemurUsage;
|
|
671
683
|
};
|
|
672
684
|
|
|
673
685
|
/**
|
|
@@ -788,7 +800,11 @@ export type LemurQuestionAnswerParams = LemurBaseParams & {
|
|
|
788
800
|
* "answer": "yes",
|
|
789
801
|
* "question": "Is global warming affecting wildfires?"
|
|
790
802
|
* }
|
|
791
|
-
* ]
|
|
803
|
+
* ],
|
|
804
|
+
* "usage": {
|
|
805
|
+
* "input_tokens": 27,
|
|
806
|
+
* "output_tokens": 3
|
|
807
|
+
* }
|
|
792
808
|
* }
|
|
793
809
|
* ```
|
|
794
810
|
*/
|
|
@@ -799,6 +815,12 @@ export type LemurQuestionAnswerResponse = LemurBaseResponse & {
|
|
|
799
815
|
response: LemurQuestionAnswer[];
|
|
800
816
|
};
|
|
801
817
|
|
|
818
|
+
export type LemurResponse =
|
|
819
|
+
| LemurTaskResponse
|
|
820
|
+
| LemurSummaryResponse
|
|
821
|
+
| LemurQuestionAnswerResponse
|
|
822
|
+
| LemurActionItemsResponse;
|
|
823
|
+
|
|
802
824
|
/**
|
|
803
825
|
* @example
|
|
804
826
|
* ```js
|
|
@@ -825,7 +847,11 @@ export type LemurSummaryParams = LemurBaseParams & {
|
|
|
825
847
|
* ```js
|
|
826
848
|
* {
|
|
827
849
|
* "request_id": "5e1b27c2-691f-4414-8bc5-f14678442f9e",
|
|
828
|
-
* "response": "- Wildfires in Canada are sending smoke and air pollution across parts of the US, triggering air quality alerts from Maine to Minnesota. Concentrations of particulate matter have exceeded safety levels.\n\n- Weather systems are channeling the smoke through Pennsylvania into the Mid-Atlantic and Northeast regions. New York City has canceled outdoor activities to keep children and vulnerable groups indoors.\n\n- Very small particulate matter can enter the lungs and impact respiratory, cardiovascular and neurological health. Young children, the elderly and those with preexisting conditions are most at risk.\n\n- The conditions causing the poor air quality could get worse or shift to different areas in coming days depending on weather patterns. More wildfires may also contribute to higher concentrations.\n\n- Climate change is leading to longer and more severe fire seasons. Events of smoke traveling long distances and affecting air quality over wide areas will likely become more common in the future.\"\n"
|
|
850
|
+
* "response": "- Wildfires in Canada are sending smoke and air pollution across parts of the US, triggering air quality alerts from Maine to Minnesota. Concentrations of particulate matter have exceeded safety levels.\n\n- Weather systems are channeling the smoke through Pennsylvania into the Mid-Atlantic and Northeast regions. New York City has canceled outdoor activities to keep children and vulnerable groups indoors.\n\n- Very small particulate matter can enter the lungs and impact respiratory, cardiovascular and neurological health. Young children, the elderly and those with preexisting conditions are most at risk.\n\n- The conditions causing the poor air quality could get worse or shift to different areas in coming days depending on weather patterns. More wildfires may also contribute to higher concentrations.\n\n- Climate change is leading to longer and more severe fire seasons. Events of smoke traveling long distances and affecting air quality over wide areas will likely become more common in the future.\"\n",
|
|
851
|
+
* "usage": {
|
|
852
|
+
* "input_tokens": 27,
|
|
853
|
+
* "output_tokens": 3
|
|
854
|
+
* }
|
|
829
855
|
* }
|
|
830
856
|
* ```
|
|
831
857
|
*/
|
|
@@ -863,7 +889,11 @@ export type LemurTaskParams = {
|
|
|
863
889
|
* ```js
|
|
864
890
|
* {
|
|
865
891
|
* "request_id": "5e1b27c2-691f-4414-8bc5-f14678442f9e",
|
|
866
|
-
* "response": "Based on the transcript, the following locations were mentioned as being affected by wildfire smoke from Canada:\n\n- Maine\n- Maryland\n- Minnesota\n- Mid Atlantic region\n- Northeast region\n- New York City\n- Baltimore\n"
|
|
892
|
+
* "response": "Based on the transcript, the following locations were mentioned as being affected by wildfire smoke from Canada:\n\n- Maine\n- Maryland\n- Minnesota\n- Mid Atlantic region\n- Northeast region\n- New York City\n- Baltimore\n",
|
|
893
|
+
* "usage": {
|
|
894
|
+
* "input_tokens": 27,
|
|
895
|
+
* "output_tokens": 3
|
|
896
|
+
* }
|
|
867
897
|
* }
|
|
868
898
|
* ```
|
|
869
899
|
*/
|
|
@@ -874,6 +904,20 @@ export type LemurTaskResponse = {
|
|
|
874
904
|
response: string;
|
|
875
905
|
} & LemurBaseResponse;
|
|
876
906
|
|
|
907
|
+
/**
|
|
908
|
+
* The usage numbers for the LeMUR request
|
|
909
|
+
*/
|
|
910
|
+
export type LemurUsage = {
|
|
911
|
+
/**
|
|
912
|
+
* The number of input tokens used by the model
|
|
913
|
+
*/
|
|
914
|
+
input_tokens: number;
|
|
915
|
+
/**
|
|
916
|
+
* The number of output tokens generated by the model
|
|
917
|
+
*/
|
|
918
|
+
output_tokens: number;
|
|
919
|
+
};
|
|
920
|
+
|
|
877
921
|
/**
|
|
878
922
|
* @example
|
|
879
923
|
* ```js
|