Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
finwise-miniapp-be
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ThinhNC
finwise-miniapp-be
Commits
efbc2710
Commit
efbc2710
authored
Aug 18, 2026
by
ThinhNC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(ai-assistant): infer response types from Zod schemas
parent
ab1b126a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
ai-assistant.service.ts
src/modules/ai-assistant/ai-assistant.service.ts
+6
-6
No files found.
src/modules/ai-assistant/ai-assistant.service.ts
View file @
efbc2710
import
{
Prisma
,
TransactionType
}
from
'@prisma/client'
;
import
{
z
}
from
'zod'
;
import
{
getAIProvider
}
from
'../../common/ai/ai-provider.factory'
;
import
{
AIContentPart
,
...
...
@@ -37,7 +38,6 @@ import {
receiptResponseSchema
,
recommendationsResponseSchema
,
}
from
'./ai-assistant-response.validation'
;
import
type
{
AIResponseValidator
}
from
'./ai-assistant-response.validation'
;
const
MILLISECONDS_PER_DAY
=
24
*
60
*
60
*
1000
;
const
DEFAULT_CONTEXT_DAYS
=
90
;
...
...
@@ -227,12 +227,12 @@ export class AIAssistantService {
);
}
private async generateWithContext<T>(
private async generateWithContext<T
Schema extends z.ZodTypeAny
>(
context: ResolvedContext,
prompt: string,
responseJsonSchema: Record<string, unknown>,
outputSchema:
AIResponseValidator<T>
,
): Promise<AIServiceResult<
T
>> {
outputSchema:
TSchema
,
): Promise<AIServiceResult<
z.output<TSchema>
>> {
const response = await this.generate(
{
systemInstruction: SYSTEM_INSTRUCTION,
...
...
@@ -259,9 +259,9 @@ export class AIAssistantService {
};
}
private async generate<T>(
private async generate<T
Schema extends z.ZodTypeAny
>(
request: AIGenerateRequest,
outputSchema:
AIResponseValidator<T>
,
outputSchema:
TSchema
,
) {
try {
const response = await getAIProvider().generateStructured(request);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment