kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
fix: ensure messages are sent sequentially and update in light of chunking
rodzic
fd253b2ef0
commit
52bea40846
|
@ -249,9 +249,16 @@ export class TwilioConversationClient {
|
||||||
maxChunkLength?: number
|
maxChunkLength?: number
|
||||||
}) {
|
}) {
|
||||||
const chunks = chunkString(text, TWILIO_SMS_LENGTH_SOFT_LIMIT)
|
const chunks = chunkString(text, TWILIO_SMS_LENGTH_SOFT_LIMIT)
|
||||||
return Promise.all(
|
const out: TwilioConversationMessage[] = []
|
||||||
chunks.map((chunk) => this.sendMessage({ conversationSid, text: chunk }))
|
for (const chunk of chunks) {
|
||||||
)
|
const sent = await this.sendMessage({
|
||||||
|
conversationSid,
|
||||||
|
text: chunk
|
||||||
|
})
|
||||||
|
out.push(sent)
|
||||||
|
}
|
||||||
|
|
||||||
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -339,11 +346,11 @@ export class TwilioConversationClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await this.fetchMessages(conversationSid)
|
const response = await this.fetchMessages(conversationSid)
|
||||||
|
|
||||||
if (response.messages.length > 1) {
|
|
||||||
const candidates = response.messages.filter(
|
const candidates = response.messages.filter(
|
||||||
(message) => message.author !== this.botName
|
(message) => message.author !== this.botName
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (candidates.length > 0) {
|
||||||
const candidate = candidates[candidates.length - 1]
|
const candidate = candidates[candidates.length - 1]
|
||||||
|
|
||||||
if (validate(candidate)) {
|
if (validate(candidate)) {
|
||||||
|
|
Ładowanie…
Reference in New Issue