Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions server/ai/provider/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import type {
ChainBreakClassifications,
ConverseResponse,
Cost,
Intent,
MailParticipant,
LLMProvider,
ModelParams,
QueryRouterLLMResponse,
Expand Down Expand Up @@ -431,7 +431,7 @@ export const getAISDKProviderByModel = (modelId: Models): ProviderV2 => {
: VertexProjectId && VertexRegion
? AIProviders.VertexAI
: null

console.log("Provider type:", providerType, "for model:", modelId)
switch (providerType) {
case AIProviders.VertexAI: {
if (!VertexProjectId || !VertexRegion) {
Expand Down Expand Up @@ -855,7 +855,7 @@ export const generateTitleUsingQuery = async (

params.json = true
Logger.info("inside generateTitleUsingQuery")
if(assistantResponse === undefined){
if (assistantResponse === undefined) {
assistantResponse = ""
}

Expand Down Expand Up @@ -1204,7 +1204,7 @@ export const baselineRAGJson = async (
userCtx,
retrievedCtx,
parseAgentPrompt(params.agentPrompt),
dateForAI
dateForAI,
)
} else {
params.systemPrompt = baselinePromptJson(userCtx, retrievedCtx, dateForAI)
Expand Down Expand Up @@ -1386,10 +1386,14 @@ export const temporalPromptJsonStream = (
userCtx,
retrievedCtx,
parseAgentPrompt(params.agentPrompt),
dateForAI
dateForAI,
)
} else {
params.systemPrompt = temporalDirectionJsonPrompt(userCtx, retrievedCtx, dateForAI)
params.systemPrompt = temporalDirectionJsonPrompt(
userCtx,
retrievedCtx,
dateForAI,
)
}
params.json = true
const baseMessage = {
Expand Down Expand Up @@ -1597,7 +1601,7 @@ export async function generateToolSelectionOutput(
reasoning?: string | null
} | null> {
params.json = true
const dateForAI = getDateForAI({userTimeZone: "Asia/Kolkata"})
const dateForAI = getDateForAI({ userTimeZone: "Asia/Kolkata" })

let defaultReasoning = isReasoning
params.systemPrompt = SearchQueryToolContextPrompt(
Expand Down Expand Up @@ -1753,7 +1757,7 @@ export function generateSynthesisBasedOnToolOutput(
userCtx,
currentMessage,
gatheredFragments,
dateForAI
dateForAI,
)

const baseMessage = {
Expand Down Expand Up @@ -1873,16 +1877,16 @@ export const generateFallback = async (
}

export const extractEmailsFromContext = async (
names: Intent,
names: MailParticipant,
userCtx: string,
retrievedCtx: string,
params: ModelParams,
): Promise<{ emails: Intent }> => {
): Promise<{ emails: MailParticipant }> => {
if (!params.modelId) {
params.modelId = defaultFastModel
}

const intentNames =
const participants =
[
...(names.from?.length ? [`From: ${names.from.join(", ")}`] : []),
...(names.to?.length ? [`To: ${names.to.join(", ")}`] : []),
Expand All @@ -1893,7 +1897,7 @@ export const extractEmailsFromContext = async (
params.systemPrompt = nameToEmailResolutionPrompt(
userCtx,
retrievedCtx,
intentNames,
participants,
names,
)
params.json = false
Expand All @@ -1902,7 +1906,7 @@ export const extractEmailsFromContext = async (
role: ConversationRole.USER,
content: [
{
text: `Help me find emails for these names: ${intentNames}`,
text: `Help me find emails for these names: ${participants}`,
},
],
}
Expand Down
6 changes: 3 additions & 3 deletions server/ai/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,15 +382,15 @@ export const ToolAnswerResponse = z.object({
})

// Intent Schema - only includes fields with actual values (modular for different apps)
export const IntentSchema = z.object({
export const MailParticipantSchema = z.object({
from: z.array(z.string()).optional(),
to: z.array(z.string()).optional(),
cc: z.array(z.string()).optional(),
bcc: z.array(z.string()).optional(),
subject: z.array(z.string()).optional(),
})

export type Intent = z.infer<typeof IntentSchema>
export type MailParticipant = z.infer<typeof MailParticipantSchema>

// Zod schemas for filters
export const FiltersSchema = z.object({
Expand All @@ -401,7 +401,7 @@ export const FiltersSchema = z.object({
sortDirection: z.string().optional(),
count: z.preprocess((val) => (val == null ? 5 : val), z.number()),
offset: z.preprocess((val) => (val == null ? 0 : val), z.number()),
intent: IntentSchema.optional(),
mailParticipants: MailParticipantSchema.optional(),
})

const TemporalClassifierSchema = z.object({
Expand Down
6 changes: 3 additions & 3 deletions server/api/chat/agents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4145,7 +4145,7 @@ export const AgentMessageApi = async (c: Context) => {
endTime: "",
count: 0,
sortDirection: "",
intent: {},
mailParticipants: {},
offset: 0,
}
let parsed = {
Expand All @@ -4154,7 +4154,7 @@ export const AgentMessageApi = async (c: Context) => {
temporalDirection: null,
filter_query: "",
type: "",
intent: {},
mailParticipants: {},
filters: queryFilters,
}

Expand Down Expand Up @@ -4327,7 +4327,7 @@ export const AgentMessageApi = async (c: Context) => {
...(parsed?.filters ?? {}),
apps: parsed.filters?.apps || [],
entities: parsed.filters?.entities as any,
intent: parsed.intent || {},
mailParticipants: parsed.mailParticipants || {},
},
}

Expand Down
Loading