chore: adjust eslint rules

old-agentic-v1^2
Travis Fischer 2023-06-10 17:50:52 -07:00
rodzic eba1060ba5
commit ddcbe1f7f3
7 zmienionych plików z 27 dodań i 2 usunięć

Wyświetl plik

@ -22,7 +22,12 @@
"no-useless-catch": "warn",
"@typescript-eslint/no-extra-semi": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-explicit-any": "off"
"@typescript-eslint/no-explicit-any": "off",
"padding-line-between-statements": [
"error",
{ "blankLine": "always", "prev": ["block", "block-like"], "next": "*" },
{ "blankLine": "always", "prev": "*", "next": ["block", "block-like"] }
]
},
"overrides": [
{

Wyświetl plik

@ -109,6 +109,7 @@ export abstract class BaseLLM<
}
const tokenizer = await this._tokenizerP
if (tokenizer) {
return tokenizer.encode(text).length
}
@ -255,6 +256,7 @@ export abstract class BaseChatModel<
}
const booleanOutput = booleanOutputs[output]
if (booleanOutput !== undefined) {
output = booleanOutput
} else {

Wyświetl plik

@ -26,6 +26,7 @@ type SeverityType = (typeof Severity)[keyof typeof Severity]
* Define minimum LOG_LEVEL, defaulting to Severity.INFO if not provided or if an invalid value is provided. Any events below that level won't be logged to the console.
*/
let LOG_LEVEL: SeverityType = Severity.INFO
if (
process.env.DEBUG_LOG_LEVEL &&
Severity[process.env.DEBUG_LOG_LEVEL.toUpperCase()] !== undefined

Wyświetl plik

@ -32,6 +32,7 @@ export class NovuClient {
if (!apiKey) {
throw new Error(`Error NovuClient missing required "apiKey"`)
}
this.apiKey = apiKey
this.baseUrl = baseUrl
}

Wyświetl plik

@ -148,11 +148,13 @@ export class TwilioConversationClient {
`Error TwilioConversationClient missing required "accountSid" and/or "authToken"`
)
}
if (!phoneNumber) {
throw new Error(
`Error TwilioConversationClient missing required "phoneNumber"`
)
}
this.phoneNumber = phoneNumber
this.api = ky.create({
prefixUrl: baseUrl,
@ -239,7 +241,7 @@ export class TwilioConversationClient {
*
* ### Notes
*
* - The implementation will poll for replies to the message until the timeout is reached. This is not ideal, but it is the only way to retrieve replies without spinning up a local server to receive webhook events.
* - The implementation will poll for replies to the message until the timeout is reached. This is not ideal, but it is the only way to retrieve replies without spinning up a local server to receive webhook events.
*/
public async sendAndWaitForReply({
text,
@ -262,36 +264,45 @@ export class TwilioConversationClient {
const { sid: conversationSid } = await this.createConversation(name)
await this.addParticipant({ conversationSid, recipientPhoneNumber })
await this.sendMessage({ conversationSid, text })
const start = Date.now()
let nUserMessages = 0
do {
if (aborted) {
await this.deleteConversation(conversationSid)
const reason = stopSignal?.reason || 'Aborted waiting for reply'
if (reason instanceof Error) {
throw reason
} else {
throw new Error(reason)
}
}
const response = await this.fetchMessages(conversationSid)
if (response.messages.length > 1) {
const candidates = response.messages.filter(
(message) => message.author !== BOT_NAME
)
const candidate = candidates[candidates.length - 1]
if (validate(candidate)) {
await this.deleteConversation(conversationSid)
return candidate
}
if (nUserMessages !== candidates.length) {
await this.sendMessage({
text: `Invalid response: ${candidate.body}. Please try again with a valid response format.`,
conversationSid
})
}
nUserMessages = candidates.length
}
await sleep(intervalMs)
} while (Date.now() - start < timeoutMs)

1
test/_utils.ts vendored
Wyświetl plik

@ -27,6 +27,7 @@ const keyv = new Keyv({ store: keyvRedis, namespace: 'agentic-test' })
// TODO: this is a lil hacky
const keyvHas = (keyv.has as any).bind(keyv)
keyv.has = async (key, ...rest) => {
if (refreshTestCache) {
return undefined

Wyświetl plik

@ -8,6 +8,7 @@ test('TwilioConversationClient.createConversation', async (t) => {
if (!process.env.TWILIO_ACCOUNT_SID || !process.env.TWILIO_AUTH_TOKEN) {
return t.pass()
}
const client = new TwilioConversationClient()
const friendlyName = 'create-conversation-test'
@ -25,6 +26,7 @@ test('TwilioConversationClient.addParticipant', async (t) => {
) {
return t.pass()
}
const client = new TwilioConversationClient()
const { sid: conversationSid } = await client.createConversation(
@ -43,6 +45,7 @@ test('TwilioConversationClient.sendMessage', async (t) => {
if (!process.env.TWILIO_ACCOUNT_SID || !process.env.TWILIO_AUTH_TOKEN) {
return t.pass()
}
const client = new TwilioConversationClient()
const text = 'Hello, world!'
@ -59,6 +62,7 @@ test('TwilioConversationClient.fetchMessages', async (t) => {
if (!process.env.TWILIO_ACCOUNT_SID || !process.env.TWILIO_AUTH_TOKEN) {
return t.pass()
}
const client = new TwilioConversationClient()
const { sid: conversationSid } = await client.createConversation(