mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-14 08:53:11 +00:00
Introduce a closed-catalog URL builder that delegates to existing list/detail href helpers, with role-based guards for leader lockdown and unrestricted-only assessor routes. Register the tool in the AI chat and teach the system prompt when to offer markdown links after resolving entity ids/slugs. Closes #383
30 lines
1.3 KiB
TypeScript
30 lines
1.3 KiB
TypeScript
/**
|
|
* AI chat tools — exposed to the model via `streamText({ tools })`.
|
|
*
|
|
* Each domain tool is a factory that receives an `AIToolContext` (user + payload instance)
|
|
* so database queries respect the authenticated user's access scope.
|
|
*/
|
|
|
|
import type { AIToolContext } from '@/lib/ai/types'
|
|
|
|
import { buildCampaignLinks } from '@/utilities/ai/tools/buildCampaignLinks'
|
|
import { calculate } from '@/utilities/ai/tools/calculate'
|
|
import { getDobradinhas } from '@/utilities/ai/tools/getDobradinhas'
|
|
import { getLeaderships } from '@/utilities/ai/tools/getLeaderships'
|
|
import { getMunicipalityOverview } from '@/utilities/ai/tools/getMunicipalityOverview'
|
|
import { getMunicipalityVotes } from '@/utilities/ai/tools/getMunicipalityVotes'
|
|
import { getOrganizations } from '@/utilities/ai/tools/getOrganizations'
|
|
import { getTopDeputies } from '@/utilities/ai/tools/getTopDeputies'
|
|
import { searchEntities } from '@/utilities/ai/tools/searchEntities'
|
|
|
|
export const buildAITools = (ctx: AIToolContext) => ({
|
|
calculate,
|
|
buildCampaignLinks: buildCampaignLinks(ctx),
|
|
getMunicipalityVotes: getMunicipalityVotes(ctx),
|
|
getTopDeputies: getTopDeputies(ctx),
|
|
getDobradinhas: getDobradinhas(ctx),
|
|
getMunicipalityOverview: getMunicipalityOverview(ctx),
|
|
getLeaderships: getLeaderships(ctx),
|
|
getOrganizations: getOrganizations(ctx),
|
|
searchEntities: searchEntities(ctx),
|
|
})
|