Skip to content

Commit

Permalink
chore: improve assistant's config validation
Browse files Browse the repository at this point in the history
  • Loading branch information
psanders committed Dec 28, 2024
1 parent 7024c03 commit cda4511
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 11 additions & 3 deletions mods/autopilot/src/assistants/AssistantSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import { z } from "zod";
import { toolSchema } from "../tools/ToolSchema";
import { LANGUAGE_MODEL_PROVIDER } from "../types";

const NUMBER_BETWEEN_0_AND_1 = "must be a number between 0 and 1";
const NUMBER_BETWEEN_0_AND_2 = "must be a number between 0 and 2";

const conversationSettingsSchema = z.object({
firstMessage: z.string().optional(),
systemTemplate: z.string(),
Expand Down Expand Up @@ -60,8 +63,11 @@ const conversationSettingsSchema = z.object({
.optional(),
vad: z.object({
pathToModel: z.string().optional(),
activationThreshold: z.number(),
deactivationThreshold: z.number(),
activationThreshold: z.number()
.max(1)
.min(0)
.positive({ message: NUMBER_BETWEEN_0_AND_1 }),
deactivationThreshold: z.number().max(1).min(0).positive({ message: NUMBER_BETWEEN_0_AND_1 }),
debounceFrames: z
.number()
.int({ message: Messages.POSITIVE_INTEGER_MESSAGE })
Expand All @@ -75,7 +81,9 @@ const languageModelConfigSchema = z.object({
}),
apiKey: z.string().optional(),
model: z.string(),
temperature: z.number(),
temperature: z.number()
.max(2, { message: NUMBER_BETWEEN_0_AND_2 })
.min(0, { message: NUMBER_BETWEEN_0_AND_2 }),
maxTokens: z
.number()
.int({ message: Messages.POSITIVE_INTEGER_MESSAGE })
Expand Down
2 changes: 0 additions & 2 deletions mods/autopilot/test/machine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,11 @@ const getActorInput = () => ({
maxSpeechWaitTimeout: 10000,
initialDtmf: "1",
idleOptions: {
enabled: true,
message: IDLE_MESSAGE,
timeout: 3000,
maxTimeoutCount: 3
},
transferOptions: {
enabled: false,
phoneNumber: "+1234567890",
message: "Transferring call"
},
Expand Down

0 comments on commit cda4511

Please sign in to comment.