wuyiqunLu commited on
Commit
7e3ba51
1 Parent(s): 04f7bdd

fix: add local env for connecting local server (#106)

Browse files

<img width="334" alt="image"
src="https://github.com/landing-ai/vision-agent-ui/assets/132986242/e124adc4-acd1-409b-971f-914562d5ac00">

.github/workflows/cicd.yaml CHANGED
@@ -142,3 +142,4 @@ jobs:
142
  --set env.LOKI_AUTH_USER_PASSWORD=${{ vars.LOKI_AUTH_USER_PASSWORD }} \
143
  --set env.OPENAI_API_KEY=${{ vars.OPENAI_API_KEY }} \
144
  --set env.POSTGRES_PRISMA_URL=${{ vars.POSTGRES_PRISMA_URL }}
 
 
142
  --set env.LOKI_AUTH_USER_PASSWORD=${{ vars.LOKI_AUTH_USER_PASSWORD }} \
143
  --set env.OPENAI_API_KEY=${{ vars.OPENAI_API_KEY }} \
144
  --set env.POSTGRES_PRISMA_URL=${{ vars.POSTGRES_PRISMA_URL }}
145
+ --set env.AGENT_HOST=${{ vars.AGENT_HOST }}
.github/workflows/prod-deploy.yml CHANGED
@@ -102,3 +102,4 @@ jobs:
102
  --set env.LOKI_AUTH_USER_PASSWORD=${{ vars.LOKI_AUTH_USER_PASSWORD }} \
103
  --set env.OPENAI_API_KEY=${{ vars.OPENAI_API_KEY }} \
104
  --set env.POSTGRES_PRISMA_URL=${{ vars.POSTGRES_PRISMA_URL }}
 
 
102
  --set env.LOKI_AUTH_USER_PASSWORD=${{ vars.LOKI_AUTH_USER_PASSWORD }} \
103
  --set env.OPENAI_API_KEY=${{ vars.OPENAI_API_KEY }} \
104
  --set env.POSTGRES_PRISMA_URL=${{ vars.POSTGRES_PRISMA_URL }}
105
+ --set env.AGENT_HOST=${{ vars.AGENT_HOST }}
app/api/vision-agent/route.ts CHANGED
@@ -121,14 +121,8 @@ export const POST = withLogging(
121
  formData.append('input', apiMessages);
122
  formData.append('image', encodeURI(mediaUrl));
123
 
124
- const agentHost = process.env.LND_TIER
125
- ? 'http://publicrestapi-app-lndsvc.publicrestapi.svc.cluster.local:5000'
126
- : 'https://api.dev.landing.ai';
127
-
128
  const fetchResponse = await fetch(
129
- // `${agentHost}/v1/agent/chat?agent_class=vision_agent&self_reflection=false`,
130
- // `https://api.dev.landing.ai/v1/agent/chat?agent_class=vision_agent&self_reflection=false`,
131
- `http://localhost:5001/v1/agent/chat?agent_class=vision_agent&self_reflection=false`,
132
  {
133
  method: 'POST',
134
  headers: {
@@ -183,6 +177,8 @@ export const POST = withLogging(
183
  message: 'Streaming cancelled',
184
  maxChunkSize,
185
  reason,
 
 
186
  },
187
  request,
188
  '__AGENT_STREAM_CANCELLED',
@@ -335,6 +331,8 @@ export const POST = withLogging(
335
  maxChunkSize,
336
  reason,
337
  error,
 
 
338
  },
339
  request,
340
  error ? '__AGENT_DONE_WITH_ERROR' : '__AGENT_DONE',
 
121
  formData.append('input', apiMessages);
122
  formData.append('image', encodeURI(mediaUrl));
123
 
 
 
 
 
124
  const fetchResponse = await fetch(
125
+ `${process.env.AGENT_HOST}/v1/agent/chat?agent_class=vision_agent&self_reflection=false`,
 
 
126
  {
127
  method: 'POST',
128
  headers: {
 
177
  message: 'Streaming cancelled',
178
  maxChunkSize,
179
  reason,
180
+ messageId,
181
+ chatId,
182
  },
183
  request,
184
  '__AGENT_STREAM_CANCELLED',
 
331
  maxChunkSize,
332
  reason,
333
  error,
334
+ messageId,
335
+ chatId,
336
  },
337
  request,
338
  error ? '__AGENT_DONE_WITH_ERROR' : '__AGENT_DONE',
chart/values.yaml CHANGED
@@ -98,6 +98,7 @@ env:
98
  POSTGRES_PRISMA_URL: ""
99
  NEXTAUTH_URL: ""
100
  LND_TIER: ""
 
101
 
102
  # Additional volumes on the output Deployment definition.
103
  volumes: []
 
98
  POSTGRES_PRISMA_URL: ""
99
  NEXTAUTH_URL: ""
100
  LND_TIER: ""
101
+ AGENT_HOST: ""
102
 
103
  # Additional volumes on the output Deployment definition.
104
  volumes: []
lib/logger.ts CHANGED
@@ -118,14 +118,14 @@ export const withLogging = (
118
  return async (req: Request) => {
119
  const session = await auth();
120
  const json = await req.json();
121
- // logger.info(
122
- // session,
123
- // {
124
- // params: json,
125
- // },
126
- // req,
127
- // '_API_REQUEST',
128
- // );
129
  return handler(session, json, req);
130
  };
131
  };
 
118
  return async (req: Request) => {
119
  const session = await auth();
120
  const json = await req.json();
121
+ logger.info(
122
+ session,
123
+ {
124
+ params: json,
125
+ },
126
+ req,
127
+ '_API_REQUEST',
128
+ );
129
  return handler(session, json, req);
130
  };
131
  };