forked from muyangzhou/hacktx-2025
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAPIExample.js
More file actions
54 lines (43 loc) · 1.89 KB
/
APIExample.js
File metadata and controls
54 lines (43 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import path from 'path';
const GENAI_API_URL = 'http://localhost:3001/api/ai';
const NESSIE_API_URL = 'http://localhost:3001/api/nessie';
const PARSE_API_URL = 'http://localhost:3001/api/process-receipt';
var response = null;
var data = null;
response = await fetch(NESSIE_API_URL, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ prompt: '68f426849683f20dd519ff49' }), // Send the user's text as JSON
});
data = await response.json();
const formattedTransactionData = JSON.stringify(data.text, null, 2);
const instructions = "Analyze the following list of transactions in terms of \
how healthy or unhealthy this list of transastions is. Give the overall list \
of transactions a score value from 0 - 100, where higher scores represent healthy \
transaction histories and lower scores represent unhealthy transaction histories. \
Respond only with a text analysis, not JSON.";
const prompt = `${instructions}\n\n--- TRANSACTION DATA ---\n${formattedTransactionData}`;
response = await fetch(GENAI_API_URL, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ prompt: prompt }), // Send the user's text as JSON
});
data = await response.json();
// const RECEIPT_IMAGE_PATH = "./my_receipt2.jpg";
// const NESSIE_ACCOUNT_ID = "68f426849683f20dd519ff49"; // Get this from your state/context
// response = await fetch(PARSE_API_URL, {
// method: 'POST',
// headers: {
// 'Content-Type': 'application/json',
// },
// body: JSON.stringify({
// imagePath: RECEIPT_IMAGE_PATH, // Use the correct key from your server logic
// nessieAccountId: NESSIE_ACCOUNT_ID // Add the second required key
// }),
// });
// data = await response.json();
console.log(data.text);