-
Notifications
You must be signed in to change notification settings - Fork 604
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #217 from midday-ai/feature/filters
Feature/filters
- Loading branch information
Showing
52 changed files
with
1,113 additions
and
1,001 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
"use server"; | ||
|
||
import { filterQuerySchema } from "@/actions/schema"; | ||
import { openai } from "@ai-sdk/openai"; | ||
import { streamObject } from "ai"; | ||
import { createStreamableValue } from "ai/rsc"; | ||
|
||
export async function generateFilters( | ||
prompt: string, | ||
validFilters: string[], | ||
context: string, | ||
) { | ||
const stream = createStreamableValue(); | ||
|
||
(async () => { | ||
const { partialObjectStream } = await streamObject({ | ||
model: openai("gpt-4o-mini"), | ||
system: `You are a helpful assistant that generates filters for a given prompt. \n | ||
Current date is: ${new Date().toISOString().split("T")[0]} \n | ||
Only use categories if it's specificed in the prompt. \n | ||
${context} | ||
`, | ||
schema: filterQuerySchema.pick({ | ||
...(validFilters.reduce((acc, filter) => { | ||
acc[filter] = true; | ||
return acc; | ||
}, {}) as any), | ||
}), | ||
prompt, | ||
temperature: 0.7, | ||
}); | ||
|
||
for await (const partialObject of partialObjectStream) { | ||
stream.update(partialObject); | ||
} | ||
|
||
stream.done(); | ||
})(); | ||
|
||
return { object: stream.value }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
apps/dashboard/src/app/[locale]/(app)/(sidebar)/account/teams/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
apps/dashboard/src/app/[locale]/(app)/(sidebar)/transactions/filters.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export const VALID_FILTERS = [ | ||
"name", | ||
"attachments", | ||
"categories", | ||
"start", | ||
"end", | ||
"accounts", | ||
"assignees", | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
apps/dashboard/src/app/[locale]/(app)/(sidebar)/transactions/search-params.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { | ||
createSearchParamsCache, | ||
parseAsArrayOf, | ||
parseAsInteger, | ||
parseAsString, | ||
parseAsStringLiteral, | ||
} from "nuqs/server"; | ||
|
||
export const searchParamsCache = createSearchParamsCache({ | ||
q: parseAsString, | ||
page: parseAsInteger.withDefault(0), | ||
attachments: parseAsStringLiteral(["exclude", "include"] as const), | ||
start: parseAsString, | ||
end: parseAsString, | ||
categories: parseAsArrayOf(parseAsString), | ||
accounts: parseAsArrayOf(parseAsString), | ||
assignees: parseAsArrayOf(parseAsString), | ||
statuses: parseAsStringLiteral([ | ||
"fullfilled", | ||
"unfulfilled", | ||
"excluded", | ||
] as const), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.