Spaces:
Running
Running
wuyiqunLu
commited on
feat: temp to test in prod (#22)
Browse filesseems like to work in local need to run docker, so test it in prod
- app/api/sign/route.ts +3 -0
- lib/hooks/useVisionAgent.tsx +0 -1
- lib/logger.ts +41 -0
- package.json +3 -1
- pnpm-lock.yaml +0 -0
app/api/sign/route.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import { auth } from '@/auth';
|
2 |
import { getPresignedUrl } from '@/lib/aws';
|
|
|
3 |
import { nanoid } from '@/lib/utils';
|
4 |
|
5 |
/**
|
@@ -24,6 +25,8 @@ export async function POST(req: Request): Promise<Response> {
|
|
24 |
|
25 |
const signedFileName = `${user}/${id ?? nanoid()}/${fileName}`;
|
26 |
const res = await getPresignedUrl(signedFileName, fileType);
|
|
|
|
|
27 |
return Response.json({
|
28 |
id,
|
29 |
signedUrl: res.url,
|
|
|
1 |
import { auth } from '@/auth';
|
2 |
import { getPresignedUrl } from '@/lib/aws';
|
3 |
+
import { getLogger } from '@/lib/logger';
|
4 |
import { nanoid } from '@/lib/utils';
|
5 |
|
6 |
/**
|
|
|
25 |
|
26 |
const signedFileName = `${user}/${id ?? nanoid()}/${fileName}`;
|
27 |
const res = await getPresignedUrl(signedFileName, fileType);
|
28 |
+
const logger = getLogger();
|
29 |
+
logger.info('get presigned url for chat id ' + id);
|
30 |
return Response.json({
|
31 |
id,
|
32 |
signedUrl: res.url,
|
lib/hooks/useVisionAgent.tsx
CHANGED
@@ -82,7 +82,6 @@ const useVisionAgent = (chat: ChatEntity) => {
|
|
82 |
...message,
|
83 |
content: logs + CLEANED_SEPARATOR + newContent,
|
84 |
};
|
85 |
-
console.log(messages);
|
86 |
setMessages([...messages, newMessage]);
|
87 |
saveKVChatMessage(id, newMessage);
|
88 |
} else {
|
|
|
82 |
...message,
|
83 |
content: logs + CLEANED_SEPARATOR + newContent,
|
84 |
};
|
|
|
85 |
setMessages([...messages, newMessage]);
|
86 |
saveKVChatMessage(id, newMessage);
|
87 |
} else {
|
lib/logger.ts
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { createLogger, transports, format, Logger } from 'winston';
|
2 |
+
import LokiTransport from 'winston-loki';
|
3 |
+
|
4 |
+
let logger: Logger;
|
5 |
+
|
6 |
+
const initializeLogger = () => {
|
7 |
+
if (logger) {
|
8 |
+
return;
|
9 |
+
}
|
10 |
+
|
11 |
+
logger = createLogger({
|
12 |
+
level: 'debug',
|
13 |
+
transports: [
|
14 |
+
new LokiTransport({
|
15 |
+
host: 'https://logs-prod3.grafana.net',
|
16 |
+
labels: {
|
17 |
+
app: 'grafanacloud-landingai-logs',
|
18 |
+
namespace: 'vision-agent',
|
19 |
+
},
|
20 |
+
basicAuth: `${process.env.LOKI_AUTH_USER_ID}:${process.env.LOKI_AUTH_USER_PASSWORD}`,
|
21 |
+
json: true,
|
22 |
+
format: format.json(),
|
23 |
+
replaceTimestamp: true,
|
24 |
+
onConnectionError: err => console.log(err),
|
25 |
+
}),
|
26 |
+
new transports.Console({
|
27 |
+
format: format.combine(format.simple(), format.colorize()),
|
28 |
+
}),
|
29 |
+
],
|
30 |
+
});
|
31 |
+
};
|
32 |
+
|
33 |
+
export const getLogger = () => {
|
34 |
+
initializeLogger();
|
35 |
+
logger.info('Starting test');
|
36 |
+
logger.debug('sending debug message');
|
37 |
+
logger.warn('sending warn message');
|
38 |
+
logger.error('sending error message');
|
39 |
+
logger.info('done testing');
|
40 |
+
return logger;
|
41 |
+
};
|
package.json
CHANGED
@@ -48,7 +48,9 @@
|
|
48 |
"react-textarea-autosize": "^8.5.3",
|
49 |
"remark-gfm": "^3.0.1",
|
50 |
"remark-math": "^5.1.1",
|
51 |
-
"uuid": "^9.0.1"
|
|
|
|
|
52 |
},
|
53 |
"devDependencies": {
|
54 |
"@tailwindcss/typography": "^0.5.10",
|
|
|
48 |
"react-textarea-autosize": "^8.5.3",
|
49 |
"remark-gfm": "^3.0.1",
|
50 |
"remark-math": "^5.1.1",
|
51 |
+
"uuid": "^9.0.1",
|
52 |
+
"winston": "^3.13.0",
|
53 |
+
"winston-loki": "^6.1.2"
|
54 |
},
|
55 |
"devDependencies": {
|
56 |
"@tailwindcss/typography": "^0.5.10",
|
pnpm-lock.yaml
CHANGED
The diff for this file is too large to render.
See raw diff
|
|