Skip to content

Commit 0a8bca1

Browse files
authored
Merge pull request #21 from ConnerWithAnE/gpt-controller-refactor
Fixed prompts and datatypes
2 parents 787b5e2 + 2a8e133 commit 0a8bca1

12 files changed

+1215
-98
lines changed

server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"main": "index.js",
55
"scripts": {
66
"test": "jest",
7-
"dev": "cross-env MOCK_DATA=${MOCK_DATA:-true} AUTH_OFF=${AUTH_OFF:-false} npx nodemon",
7+
"dev": "cross-env MOCK_DATA=${MOCK_DATA:-false} AUTH_OFF=${AUTH_OFF:-false} GPT_RUNTABLES=${GPT_RUNTABLES:-false} nodemon",
88
"start": "npm run build && node build/src/index.js",
99
"build": "tsc"
1010
},

server/src/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const config = {
22
MockData: process.env.MOCK_DATA === 'true',
3-
AuthEnable: process.env.AUTH_OFF === 'false'
3+
AuthEnable: process.env.AUTH_OFF === 'false',
4+
RunTables: process.env.GPT_RUNTABLES === 'true'
45
};
56

67
export default config;

server/src/gpt-controller.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
PreliminaryTestData,
1111
} from "./types";
1212
import { GPTModel } from "./enums";
13+
import config from "./config";
1314

1415
export class GPTController {
1516
private static client: OpenAI;
@@ -282,21 +283,21 @@ export class GPTController {
282283
await this.addMessage(
283284
threadId,
284285
fileId,
285-
`You are to only look for data related to this part ${
286-
part!.device_name
287-
}, ${questions.testingConditions.prompt}`,
286+
`You are to only look for data related to this part ${part!.name}, ${
287+
questions.testingConditions.prompt
288+
}`,
288289
);
289290
console.log(
290-
`Getting Prelim data for part ${part.device_name} File ID: ${fileId} (Thread ID: ${threadId})`,
291+
`Getting Prelim data for part ${part.name} File ID: ${fileId} (Thread ID: ${threadId})`,
291292
);
292293
const partRun = await this.runThread(threadId, assistantId);
293-
console.log(partRun)
294+
console.log(partRun);
294295
partTests.push({
295296
...part,
296297
preliminary_test_types: partRun.map((data: string) => data),
297298
seeData: [],
298299
tidData: [],
299-
ddData: []
300+
ddData: [],
300301
} as ai_part);
301302
}
302303
console.log(
@@ -336,24 +337,24 @@ export class GPTController {
336337
await this.addMessage(
337338
threadId,
338339
fileId,
339-
`You are to only look for data related to this part ${part.device_name}, ${questions.seeData.prompt}`,
340+
`You are to only look for data related to this part ${part.name}, ${questions.seeData.prompt}`,
340341
);
341342
console.log(
342-
`Getting Specifc Data for Part ${part.device_name} File ID: ${fileId} (Thread ID: ${threadId})`,
343+
`Getting Specifc Data for Part ${part.name} File ID: ${fileId} (Thread ID: ${threadId})`,
343344
);
344345
part.seeData.push(await this.runThread(threadId, assistantId));
345346
} else if (test === "TID") {
346347
await this.addMessage(
347348
threadId,
348349
fileId,
349-
`You are to only look for data related to this part ${part.device_name}, ${questions.tidData.prompt}`,
350+
`You are to only look for data related to this part ${part.name}, ${questions.tidData.prompt}`,
350351
);
351352
part.tidData.push(await this.runThread(threadId, assistantId));
352353
} else if (test === "DD") {
353354
await this.addMessage(
354355
threadId,
355356
fileId,
356-
`You are to only look for data related to this part ${part.device_name}, ${questions.ddData.prompt}`,
357+
`You are to only look for data related to this part ${part.name}, ${questions.ddData.prompt}`,
357358
);
358359
part.ddData.push(await this.runThread(threadId, assistantId));
359360
} else {
@@ -421,6 +422,9 @@ export class GPTController {
421422
if (!threadId) return;
422423
const ids = { assistantId, fileId, threadId };
423424
const papersData = await this.getPaperData({ ...ids });
425+
if (config.RunTables) {
426+
const tbfgs = await this.getTablesAndFigures({ ...ids });
427+
}
424428
const partData = await this.getSpecificTest({
425429
...ids,
426430
parts: await this.getPartTests({

server/src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ async function initializeSystem(): Promise<{
105105
app.get("/test2-gpt", async (req, res) => {
106106
try {
107107
//const pdfFile = "./test/Radiation_effects_predicted_observed_and_compared_for_spacecraft_systems.pdf";
108-
const pdfFile = "./test/SEE_in-flight_data_for_two_static_32KB_memories_on_high_earth_orbit.pdf"; // Replace with actual file path
108+
//const pdfFile = "./test/SEE_in-flight_data_for_two_static_32KB_memories_on_high_earth_orbit.pdf"; // Replace with actual file path
109109
//const pdfFile = "./test/Single-Event_Effects_Measurements_on_COTS_Electronic_Devices_for_Use_on_NASA_Mars_Missions.pdf";
110-
//const pdfFile = "./test/Review_of_TID_Effects_Reported_in_ProASIC3_and_ProASIC3L_FPGAs_for_3D_PLUS_Camera_Heads.pdf";
110+
const pdfFile = ["./test/Review_of_TID_Effects_Reported_in_ProASIC3_and_ProASIC3L_FPGAs_for_3D_PLUS_Camera_Heads.pdf"];
111111
const pdfFiles = [
112112
"./test/Radiation_effects_predicted_observed_and_compared_for_spacecraft_systems.pdf",
113113
"./test/SEE_in-flight_data_for_two_static_32KB_memories_on_high_earth_orbit.pdf",
@@ -116,7 +116,7 @@ async function initializeSystem(): Promise<{
116116
];
117117
const gptController = new GPTController(GPTModel.GPT4O);
118118
console.log("Running GPT Analysis...");
119-
const results = await gptController.processRadiationPapers(pdfFiles);
119+
const results = await gptController.processRadiationPapers(pdfFile);
120120

121121
fs.writeFileSync(
122122
"./test/1-paper-output.json",

server/src/models.ts

Lines changed: 44 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class Paper extends Model<
4545
declare id: CreationOptional<number>;
4646
declare name: string;
4747
declare year: number;
48+
declare objective: string;
4849
declare createdAt: CreationOptional<Date>;
4950
declare updatedAt: CreationOptional<Date>;
5051

@@ -76,6 +77,7 @@ Paper.init(
7677
id: { type: DataTypes.INTEGER, autoIncrement: true, primaryKey: true },
7778
name: { type: DataTypes.TEXT, allowNull: false },
7879
year: { type: DataTypes.INTEGER },
80+
objective: { type: DataTypes.TEXT },
7981
createdAt: DataTypes.DATE,
8082
updatedAt: DataTypes.DATE,
8183
},
@@ -94,6 +96,7 @@ class Part extends Model<InferAttributes<Part>, InferCreationAttributes<Part>> {
9496
declare name: string;
9597
declare type: string;
9698
declare manufacturer: string;
99+
declare other_details: string;
97100

98101
// Mixins for associations
99102
declare addPaper: BelongsToManyAddAssociationMixin<Paper, number>;
@@ -120,6 +123,7 @@ Part.init(
120123
name: { type: DataTypes.TEXT, allowNull: false },
121124
type: { type: DataTypes.TEXT },
122125
manufacturer: { type: DataTypes.TEXT },
126+
other_details: { type: DataTypes.TEXT },
123127
},
124128
{ sequelize, modelName: "part" },
125129
);
@@ -135,9 +139,9 @@ Part.belongsToMany(Paper, { through: PaperPart });
135139
// declare id: CreationOptional<number>;
136140
// declare testing_type: "TID" | "SEE" | "DD";
137141
// declare max_fluence: number;
138-
// declare energy: number;
139-
// declare facility: string;
140-
// declare environment: string;
142+
// declare energy_levels: number;
143+
// declare facility_name: string;
144+
// declare environmental_conditions: string;
141145
// declare terrestrial: boolean;
142146
// declare flight: boolean;
143147

@@ -156,9 +160,9 @@ Part.belongsToMany(Paper, { through: PaperPart });
156160
// id: { type: DataTypes.INTEGER, autoIncrement: true, primaryKey: true },
157161
// testing_type: { type: DataTypes.ENUM("TID", "SEE", "DD") },
158162
// max_fluence: { type: DataTypes.FLOAT },
159-
// energy: { type: DataTypes.FLOAT },
160-
// facility: { type: DataTypes.TEXT },
161-
// environment: { type: DataTypes.TEXT },
163+
// energy_levels: { type: DataTypes.FLOAT },
164+
// facility_name: { type: DataTypes.TEXT },
165+
// environmental_conditions: { type: DataTypes.TEXT },
162166
// terrestrial: { type: DataTypes.BOOLEAN },
163167
// flight: { type: DataTypes.BOOLEAN },
164168
// },
@@ -183,9 +187,9 @@ Part.belongsToMany(Paper, { through: PaperPart });
183187
class Tid extends Model<InferAttributes<Tid>, InferCreationAttributes<Tid>> {
184188
declare id: CreationOptional<number>;
185189
declare max_fluence: number;
186-
declare energy: number;
187-
declare facility: string;
188-
declare environment: string;
190+
declare energy_levels: number;
191+
declare facility_name: string;
192+
declare environmental_conditions: string;
189193
declare terrestrial: boolean;
190194
declare flight: boolean;
191195
declare source:
@@ -201,6 +205,7 @@ class Tid extends Model<InferAttributes<Tid>, InferCreationAttributes<Tid>> {
201205
declare dose_to_failure: number;
202206
declare increased_power_usage: boolean;
203207
declare power_usage_description: string;
208+
declare failing_time: string;
204209
declare special_notes?: string;
205210

206211
// // Foreign Key
@@ -218,9 +223,9 @@ Tid.init(
218223
{
219224
id: { type: DataTypes.INTEGER, autoIncrement: true, primaryKey: true },
220225
max_fluence: { type: DataTypes.FLOAT },
221-
energy: { type: DataTypes.FLOAT },
222-
facility: { type: DataTypes.TEXT },
223-
environment: { type: DataTypes.TEXT },
226+
energy_levels: { type: DataTypes.FLOAT },
227+
facility_name: { type: DataTypes.TEXT },
228+
environmental_conditions: { type: DataTypes.TEXT },
224229
terrestrial: { type: DataTypes.BOOLEAN },
225230
flight: { type: DataTypes.BOOLEAN },
226231
source: {
@@ -230,6 +235,7 @@ Tid.init(
230235
"Electrons",
231236
"Heavy ions",
232237
"X-rays",
238+
"Pions",
233239
),
234240
},
235241
max_tid: { type: DataTypes.FLOAT },
@@ -238,6 +244,7 @@ Tid.init(
238244
dose_to_failure: { type: DataTypes.FLOAT },
239245
increased_power_usage: { type: DataTypes.BOOLEAN },
240246
power_usage_description: { type: DataTypes.TEXT },
247+
failing_time: { type: DataTypes.TEXT },
241248
special_notes: { type: DataTypes.TEXT },
242249
},
243250
{ sequelize, modelName: "tid" },
@@ -262,22 +269,26 @@ Tid.belongsTo(Part, {
262269
class See extends Model<InferAttributes<See>, InferCreationAttributes<See>> {
263270
declare id: CreationOptional<number>;
264271
declare max_fluence: number;
265-
declare energy: number;
266-
declare facility: string;
267-
declare environment: string;
272+
declare energy_levels: number;
273+
declare facility_name: string;
274+
declare environmental_conditions: string;
268275
declare terrestrial: boolean;
269276
declare flight: boolean;
270-
declare source: "Heavy ions" | "Protons" | "Laser" | "Neutron" | "Electron";
277+
declare source: "Heavy ions" | "Protons" | "Laser" | "Neutron" | "Electron" | "X-rays";
278+
declare type: string;
279+
/*
271280
declare type:
272281
| "Single Event Upset"
273282
| "Single Event Transient"
274283
| "Single Event Functional Interrupt"
275284
| "Single Event Latch-up"
276285
| "Single Event Burnout"
277286
| "Single Event Gate Rupture";
287+
*/
278288
declare amplitude: number;
279289
declare duration: number;
280-
declare cross_section: number;
290+
declare cross_section_saturation: number;
291+
declare cross_section_threshold: number;
281292
declare cross_section_type: string;
282293
declare special_notes?: string;
283294

@@ -295,9 +306,9 @@ See.init(
295306
{
296307
id: { type: DataTypes.INTEGER, autoIncrement: true, primaryKey: true },
297308
max_fluence: { type: DataTypes.FLOAT },
298-
energy: { type: DataTypes.FLOAT },
299-
facility: { type: DataTypes.TEXT },
300-
environment: { type: DataTypes.TEXT },
309+
energy_levels: { type: DataTypes.FLOAT },
310+
facility_name: { type: DataTypes.TEXT },
311+
environmental_conditions: { type: DataTypes.TEXT },
301312
terrestrial: { type: DataTypes.BOOLEAN },
302313
flight: { type: DataTypes.BOOLEAN },
303314
source: {
@@ -309,6 +320,8 @@ See.init(
309320
"Electron",
310321
),
311322
},
323+
type: { type: DataTypes.TEXT },
324+
/*
312325
type: {
313326
type: DataTypes.ENUM(
314327
"Single Event Upset",
@@ -319,9 +332,11 @@ See.init(
319332
"Single Event Gate Rupture",
320333
),
321334
},
335+
*/
322336
amplitude: { type: DataTypes.FLOAT },
323337
duration: { type: DataTypes.FLOAT },
324-
cross_section: { type: DataTypes.FLOAT },
338+
cross_section_saturation: { type: DataTypes.FLOAT },
339+
cross_section_threshold: { type: DataTypes.FLOAT },
325340
cross_section_type: { type: DataTypes.TEXT },
326341
special_notes: { type: DataTypes.TEXT },
327342
},
@@ -348,14 +363,14 @@ See.belongsTo(Part, {
348363
class Dd extends Model<InferAttributes<Dd>, InferCreationAttributes<Dd>> {
349364
declare id: CreationOptional<number>;
350365
declare max_fluence: number;
351-
declare energy: number;
352-
declare facility: string;
353-
declare environment: string;
366+
declare energy_levels: number;
367+
declare facility_name: string;
368+
declare environmental_conditions: string;
354369
declare terrestrial: boolean;
355370
declare flight: boolean;
356371
declare source: "Protons" | "Neutrons";
357372
declare damage_level: number;
358-
declare damage_level_description: string;
373+
declare damage_description: string;
359374
declare special_notes?: string;
360375

361376
// // Foreign key reference
@@ -373,14 +388,14 @@ Dd.init(
373388
{
374389
id: { type: DataTypes.INTEGER, autoIncrement: true, primaryKey: true },
375390
max_fluence: { type: DataTypes.FLOAT },
376-
energy: { type: DataTypes.FLOAT },
377-
facility: { type: DataTypes.TEXT },
378-
environment: { type: DataTypes.TEXT },
391+
energy_levels: { type: DataTypes.FLOAT },
392+
facility_name: { type: DataTypes.TEXT },
393+
environmental_conditions: { type: DataTypes.TEXT },
379394
terrestrial: { type: DataTypes.BOOLEAN },
380395
flight: { type: DataTypes.BOOLEAN },
381396
source: { type: DataTypes.ENUM("Protons", "Neutrons") },
382397
damage_level: { type: DataTypes.FLOAT },
383-
damage_level_description: { type: DataTypes.TEXT },
398+
damage_description: { type: DataTypes.TEXT },
384399
special_notes: { type: DataTypes.TEXT },
385400
},
386401
{ sequelize, modelName: "dd" },

0 commit comments

Comments
 (0)