Skip to content

Commit 6e99813

Browse files
committed
PEER-226: Fix bug
Signed-off-by: SeeuSim <[email protected]>
1 parent 6f40cda commit 6e99813

File tree

8 files changed

+12
-15
lines changed

8 files changed

+12
-15
lines changed

.env.local

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ COLLAB_SERVICE_NAME=collab-express
1212
COLLAB_EXPRESS_PORT=9003
1313
COLLAB_EXPRESS_DB_PORT=5434
1414
COLLAB_PGDATA="/data/collab-db"
15-
OPENAI_API_KEY=PUT_YOUR_OPENAI_API_KEY_HERE
16-
15+
OPENAI_API_KEY="<insert_key>"
1716

1817
MATCHING_SERVICE_NAME=match-express
1918
MATCHING_EXPRESS_PORT=9004
@@ -28,7 +27,4 @@ CHAT_EXPRESS_DB_PORT=5435
2827
CHAT_PGDATA="/data/chat-db"
2928

3029
FRONTEND_SERVICE_NAME=frontend
31-
FRONTEND_PORT=3000
32-
33-
OPENAI_API_KEY=PUT_YOUR_OPENAI_API_KEY_HERE
34-
30+
FRONTEND_PORT=3000

backend/collaboration/.env.compose

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ POSTGRES_DB="collab"
88
POSTGRES_USER="peerprep-collab-express"
99
POSTGRES_PASSWORD="6rYE0nIzI2ThzDO"
1010
PGDATA="/data/collab-db"
11-
OPENAI_API_KEY="PUT_YOUR_OPENAI_API_KEY_HERE"
11+
OPENAI_API_KEY="<insert_key>"

backend/collaboration/.env.docker

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ POSTGRES_DB=collab
77
POSTGRES_USER=peerprep-collab-express
88
POSTGRES_PASSWORD=6rYE0nIzI2ThzDO
99
PGDATA=/data/collab-db
10-
OPENAI_API_KEY=OPENAI_KEY_HERE
10+
OPENAI_API_KEY="<insert_key>"

backend/collaboration/.env.local

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ POSTGRES_DB="collab"
77
POSTGRES_USER="peerprep-collab-express"
88
POSTGRES_PASSWORD="6rYE0nIzI2ThzDO"
99
PGDATA="/data/collab-db"
10-
OPENAI_API_KEY=PUT-YOUR-KEYS-HERE
10+
OPENAI_API_KEY="<insert_key>"

backend/collaboration/src/routes/chat.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ import { queryOpenAI } from '@/controller/openai-controller';
44

55
const router = express.Router();
66

7-
router.get('/chat', queryOpenAI);
7+
router.post('/chat', queryOpenAI);
88

99
export default router;

backend/collaboration/src/server.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ app.use(
3939
})
4040
);
4141

42+
app.use('/ai', aiChatRoutes);
4243
app.use('/room', roomRoutes);
4344

4445
// Health Check for Docker
@@ -56,8 +57,6 @@ export const dbHealthCheck = async () => {
5657
}
5758
};
5859

59-
app.post('/ai', aiChatRoutes);
60-
6160
// Ensure DB service is up before running.
6261
app.get('/test-db', async (_req, res) => {
6362
await dbHealthCheck();

backend/collaboration/src/service/post/openai-service.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ export async function getOpenAIResponse(messages: OpenAIMessage[]) {
1717
{
1818
role: 'system',
1919
content:
20-
'You are a helpful coding assistant. You are helping a user with a coding problem. Provide tips to the user on solving the problem but do not provide the solution directly.',
20+
`You are a helpful coding assistant. ` +
21+
`You are helping a user with a coding problem. ` +
22+
`Provide tips to the user on solving the problem ` +
23+
`but do NOT provide the solution directly.`,
2124
},
2225
...messages,
2326
],
@@ -26,7 +29,7 @@ export async function getOpenAIResponse(messages: OpenAIMessage[]) {
2629
if (response.choices && response.choices[0].message) {
2730
return {
2831
success: true,
29-
data: response.choices[0].message.content,
32+
message: response.choices[0].message.content,
3033
};
3134
} else {
3235
throw new Error('No valid response from OpenAI');

frontend/.env.docker

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ VITE_COLLAB_SERVICE=http://host.docker.internal:9003
66
VITE_MATCHING_SERVICE=http://host.docker.internal:9004
77
VITE_CHAT_SERVICE=http://host.docker.internal:9005
88
FRONTEND_PORT=3000
9-
OPENAI_API_KEY=PUT_YOUR_OPENAI_API_KEY_HERE

0 commit comments

Comments
 (0)