@terreno/ai 0.13.3 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/langfuseCache.d.ts +5 -6
- package/dist/langfuseCache.js +11 -2
- package/dist/langfuseClient.js +5 -1
- package/dist/models/fileAttachment.js +17 -6
- package/dist/models/gptHistory.js +36 -17
- package/dist/models/project.js +1 -1
- package/dist/routes/aiRequestsExplorer.d.ts +2 -1
- package/dist/routes/aiRequestsExplorer.js +18 -4
- package/dist/routes/files.d.ts +2 -1
- package/dist/routes/files.js +2 -2
- package/dist/routes/gpt.d.ts +2 -1
- package/dist/routes/gptHistories.d.ts +2 -1
- package/dist/routes/mcp.d.ts +2 -1
- package/dist/routes/mcp.js +2 -5
- package/dist/routes/projects.d.ts +2 -1
- package/dist/service/aiService.d.ts +3 -3
- package/dist/service/fileStorage.js +3 -2
- package/package.json +4 -3
- package/src/langfuseCache.ts +19 -5
- package/src/langfuseClient.test.ts +29 -36
- package/src/langfuseClient.ts +5 -1
- package/src/models/aiRequest.ts +2 -2
- package/src/models/fileAttachment.ts +17 -6
- package/src/models/gptHistory.ts +36 -17
- package/src/models/project.ts +1 -1
- package/src/routes/aiRequestsExplorer.ts +20 -6
- package/src/routes/files.ts +8 -6
- package/src/routes/gpt.ts +21 -16
- package/src/routes/gptHistories.ts +2 -1
- package/src/routes/mcp.ts +7 -8
- package/src/routes/projects.ts +1 -1
- package/src/routes/routes.test.ts +174 -1
- package/src/service/aiService.test.ts +11 -9
- package/src/service/aiService.ts +4 -4
- package/src/service/fileStorage.ts +3 -2
- package/src/tests/bunSetup.ts +1 -0
- package/src/types/index.ts +2 -0
package/src/service/aiService.ts
CHANGED
|
@@ -39,8 +39,8 @@ const getModelId = (model: LanguageModel): string => {
|
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
export class AIService {
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
readonly model: LanguageModel;
|
|
43
|
+
readonly defaultTemperature: number;
|
|
44
44
|
|
|
45
45
|
constructor({model, defaultTemperature = TemperaturePresets.DEFAULT}: AIServiceOptions) {
|
|
46
46
|
this.model = model;
|
|
@@ -216,13 +216,13 @@ export class AIService {
|
|
|
216
216
|
parts.push({image: new URL(part.url), mediaType: part.mimeType, type: "image"});
|
|
217
217
|
} else if (part.type === "file") {
|
|
218
218
|
logger.debug("Building file message part", {
|
|
219
|
-
filename:
|
|
219
|
+
filename: part.filename,
|
|
220
220
|
mediaType: part.mimeType,
|
|
221
221
|
urlPrefix: part.url?.substring(0, 50),
|
|
222
222
|
});
|
|
223
223
|
parts.push({
|
|
224
224
|
data: new URL(part.url),
|
|
225
|
-
filename:
|
|
225
|
+
filename: part.filename,
|
|
226
226
|
mediaType: part.mimeType,
|
|
227
227
|
type: "file",
|
|
228
228
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {Storage, type StorageOptions} from "@google-cloud/storage";
|
|
2
|
+
import {DateTime} from "luxon";
|
|
2
3
|
|
|
3
4
|
import {FileAttachment} from "../models/fileAttachment";
|
|
4
5
|
|
|
@@ -31,7 +32,7 @@ export class FileStorageService {
|
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
async upload({buffer, filename, mimeType, userId}: UploadFileParams): Promise<UploadFileResult> {
|
|
34
|
-
const timestamp =
|
|
35
|
+
const timestamp = DateTime.now().toMillis();
|
|
35
36
|
const sanitizedFilename = filename.replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
36
37
|
const gcsKey = `uploads/${userId.toString()}/${timestamp}-${sanitizedFilename}`;
|
|
37
38
|
|
|
@@ -59,7 +60,7 @@ export class FileStorageService {
|
|
|
59
60
|
const file = this.bucket.file(gcsKey);
|
|
60
61
|
const [url] = await file.getSignedUrl({
|
|
61
62
|
action: "read",
|
|
62
|
-
expires:
|
|
63
|
+
expires: DateTime.now().plus({hours: 1}).toMillis(),
|
|
63
64
|
version: "v4",
|
|
64
65
|
});
|
|
65
66
|
return url;
|
package/src/tests/bunSetup.ts
CHANGED
package/src/types/index.ts
CHANGED
|
@@ -161,6 +161,7 @@ export interface AIServiceOptions {
|
|
|
161
161
|
export interface GenerateTextOptions {
|
|
162
162
|
maxOutputTokens?: number;
|
|
163
163
|
prompt: string;
|
|
164
|
+
// biome-ignore lint/suspicious/noExplicitAny: Vercel AI SDK's StopCondition is generic over the tool set; consumers may pass any tool shape.
|
|
164
165
|
stopWhen?: import("ai").StopCondition<any>;
|
|
165
166
|
systemPrompt?: string;
|
|
166
167
|
temperature?: number;
|
|
@@ -179,6 +180,7 @@ export interface GenerateStreamOptions {
|
|
|
179
180
|
|
|
180
181
|
export interface GenerateChatStreamOptions {
|
|
181
182
|
messages: Array<{content: string; role: "user" | "assistant" | "system"}>;
|
|
183
|
+
// biome-ignore lint/suspicious/noExplicitAny: Vercel AI SDK's StopCondition is generic over the tool set; consumers may pass any tool shape.
|
|
182
184
|
stopWhen?: import("ai").StopCondition<any>;
|
|
183
185
|
systemPrompt?: string;
|
|
184
186
|
toolChoice?: "auto" | "none" | "required";
|