@cord-sdk/chatbot-base
Advanced tools
Comparing version 1.45.1 to 1.46.0
@@ -178,28 +178,30 @@ 'use strict'; | ||
else if (isAsyncIterable(response)) { | ||
[{ messageID }] = await Promise.all([ | ||
__classPrivateFieldGet(this, _ChatbotRegistryImpl_instances, "m", _ChatbotRegistryImpl_fetch).call(this, `v1/threads/${thread.id}/messages`, 'POST', { | ||
void __classPrivateFieldGet(this, _ChatbotRegistryImpl_instances, "m", _ChatbotRegistryImpl_typing).call(this, thread.id, botID, true); | ||
const typingInterval = setInterval(() => void __classPrivateFieldGet(this, _ChatbotRegistryImpl_instances, "m", _ChatbotRegistryImpl_typing).call(this, thread.id, botID, true), 1000); | ||
try { | ||
({ messageID } = await __classPrivateFieldGet(this, _ChatbotRegistryImpl_instances, "m", _ChatbotRegistryImpl_fetch).call(this, `v1/threads/${thread.id}/messages`, 'POST', { | ||
authorID: botID, | ||
content: [], | ||
metadata: { [BOT_METADATA_KEY]: true }, | ||
}), | ||
__classPrivateFieldGet(this, _ChatbotRegistryImpl_instances, "m", _ChatbotRegistryImpl_typing).call(this, thread.id, botID, true), | ||
]); | ||
// TODO: is this the right way to do this? Is it too "eager", do we have any | ||
// backpressure issues? | ||
// TODO: should we provide a way to cancel an ongoing answer if someone else | ||
// adds a message to the thread, or some other cancellation mechanism? | ||
let full = ''; | ||
for await (const chunk of response) { | ||
if (chunk !== null && chunk !== undefined) { | ||
full += chunk; | ||
} | ||
await Promise.all([ | ||
__classPrivateFieldGet(this, _ChatbotRegistryImpl_instances, "m", _ChatbotRegistryImpl_typing).call(this, thread.id, botID, true), | ||
__classPrivateFieldGet(this, _ChatbotRegistryImpl_instances, "m", _ChatbotRegistryImpl_fetch).call(this, `v1/threads/${thread.id}/messages/${messageID}`, 'PUT', { | ||
})); | ||
// TODO: is this the right way to do this? Is it too "eager", do we have | ||
// any backpressure issues? | ||
// TODO: should we provide a way to cancel an ongoing answer if someone | ||
// else adds a message to the thread, or some other cancellation | ||
// mechanism? | ||
let full = ''; | ||
for await (const chunk of response) { | ||
if (chunk !== null && chunk !== undefined) { | ||
full += chunk; | ||
} | ||
await __classPrivateFieldGet(this, _ChatbotRegistryImpl_instances, "m", _ChatbotRegistryImpl_fetch).call(this, `v1/threads/${thread.id}/messages/${messageID}`, 'PUT', { | ||
content: stringToMessageContent(full), | ||
updatedTimestamp: null, | ||
}), | ||
]); | ||
}); | ||
} | ||
} | ||
await __classPrivateFieldGet(this, _ChatbotRegistryImpl_instances, "m", _ChatbotRegistryImpl_typing).call(this, thread.id, botID, false); | ||
finally { | ||
clearInterval(typingInterval); | ||
} | ||
void __classPrivateFieldGet(this, _ChatbotRegistryImpl_instances, "m", _ChatbotRegistryImpl_typing).call(this, thread.id, botID, false); | ||
} | ||
@@ -206,0 +208,0 @@ else { |
@@ -176,28 +176,30 @@ import { fetchCordRESTApi, validateWebhookSignature } from '@cord-sdk/server'; | ||
else if (isAsyncIterable(response)) { | ||
[{ messageID }] = await Promise.all([ | ||
__classPrivateFieldGet(this, _ChatbotRegistryImpl_instances, "m", _ChatbotRegistryImpl_fetch).call(this, `v1/threads/${thread.id}/messages`, 'POST', { | ||
void __classPrivateFieldGet(this, _ChatbotRegistryImpl_instances, "m", _ChatbotRegistryImpl_typing).call(this, thread.id, botID, true); | ||
const typingInterval = setInterval(() => void __classPrivateFieldGet(this, _ChatbotRegistryImpl_instances, "m", _ChatbotRegistryImpl_typing).call(this, thread.id, botID, true), 1000); | ||
try { | ||
({ messageID } = await __classPrivateFieldGet(this, _ChatbotRegistryImpl_instances, "m", _ChatbotRegistryImpl_fetch).call(this, `v1/threads/${thread.id}/messages`, 'POST', { | ||
authorID: botID, | ||
content: [], | ||
metadata: { [BOT_METADATA_KEY]: true }, | ||
}), | ||
__classPrivateFieldGet(this, _ChatbotRegistryImpl_instances, "m", _ChatbotRegistryImpl_typing).call(this, thread.id, botID, true), | ||
]); | ||
// TODO: is this the right way to do this? Is it too "eager", do we have any | ||
// backpressure issues? | ||
// TODO: should we provide a way to cancel an ongoing answer if someone else | ||
// adds a message to the thread, or some other cancellation mechanism? | ||
let full = ''; | ||
for await (const chunk of response) { | ||
if (chunk !== null && chunk !== undefined) { | ||
full += chunk; | ||
} | ||
await Promise.all([ | ||
__classPrivateFieldGet(this, _ChatbotRegistryImpl_instances, "m", _ChatbotRegistryImpl_typing).call(this, thread.id, botID, true), | ||
__classPrivateFieldGet(this, _ChatbotRegistryImpl_instances, "m", _ChatbotRegistryImpl_fetch).call(this, `v1/threads/${thread.id}/messages/${messageID}`, 'PUT', { | ||
})); | ||
// TODO: is this the right way to do this? Is it too "eager", do we have | ||
// any backpressure issues? | ||
// TODO: should we provide a way to cancel an ongoing answer if someone | ||
// else adds a message to the thread, or some other cancellation | ||
// mechanism? | ||
let full = ''; | ||
for await (const chunk of response) { | ||
if (chunk !== null && chunk !== undefined) { | ||
full += chunk; | ||
} | ||
await __classPrivateFieldGet(this, _ChatbotRegistryImpl_instances, "m", _ChatbotRegistryImpl_fetch).call(this, `v1/threads/${thread.id}/messages/${messageID}`, 'PUT', { | ||
content: stringToMessageContent(full), | ||
updatedTimestamp: null, | ||
}), | ||
]); | ||
}); | ||
} | ||
} | ||
await __classPrivateFieldGet(this, _ChatbotRegistryImpl_instances, "m", _ChatbotRegistryImpl_typing).call(this, thread.id, botID, false); | ||
finally { | ||
clearInterval(typingInterval); | ||
} | ||
void __classPrivateFieldGet(this, _ChatbotRegistryImpl_instances, "m", _ChatbotRegistryImpl_typing).call(this, thread.id, botID, false); | ||
} | ||
@@ -204,0 +206,0 @@ else { |
{ | ||
"name": "@cord-sdk/chatbot-base", | ||
"description": "Base chatbot library for Cord", | ||
"version": "1.45.1", | ||
"version": "1.46.0", | ||
"homepage": "https://docs.cord.com/", | ||
@@ -22,4 +22,4 @@ "license": "MIT", | ||
"dependencies": { | ||
"@cord-sdk/server": "1.45.1", | ||
"@cord-sdk/types": "1.45.1" | ||
"@cord-sdk/server": "1.46.0", | ||
"@cord-sdk/types": "1.46.0" | ||
}, | ||
@@ -26,0 +26,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35826
601
1
+ Added@cord-sdk/server@1.46.0(transitive)
+ Added@cord-sdk/types@1.46.0(transitive)
- Removed@cord-sdk/server@1.45.1(transitive)
- Removed@cord-sdk/types@1.45.1(transitive)
Updated@cord-sdk/server@1.46.0
Updated@cord-sdk/types@1.46.0