Skip to content

Commit 787b5e2

Browse files
Merge pull request #20 from ConnerWithAnE/gpt-controller-refactor
Gpt controller refactor
2 parents 13d123f + 31ebab8 commit 787b5e2

File tree

5 files changed

+142
-92
lines changed

5 files changed

+142
-92
lines changed

server/src/gpt-controller.ts

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class GPTController {
3434
"Imagine you are a radiation-effects specialist for electronic components. You are well versed in the lingo, and the methodologies for testing devices. Take the paper, parse it, and then return me the data I request in the format I provide. Return in a JSON format and do not include any extra explanations",
3535
model: "gpt-4o",
3636
tools: [{ type: "file_search" }],
37-
temperature: 0.15,
37+
temperature: 0.1,
3838
});
3939

4040
console.log(`Assistant created! Assistant ID: ${assistant.id}`);
@@ -190,7 +190,7 @@ export class GPTController {
190190
*
191191
* Adds a message to the ChatGPT thread and runs it.
192192
* This collects all of the paper metadata
193-
*
193+
*
194194
* Parameters are given in a named object form
195195
*
196196
* @param assistantId the id of the chatgpt assistant to use
@@ -223,7 +223,7 @@ export class GPTController {
223223
*
224224
* Gets the initia part data and returns it as a list of Partial<ai_part> objects.
225225
* These contain info like the part name, type and manufacturer
226-
*
226+
*
227227
* Parameters are given in a named object form
228228
*
229229
* @param assistantId the id of the chatgpt assistant to use
@@ -259,7 +259,7 @@ export class GPTController {
259259
/**
260260
*
261261
* Parameters are given in a named object form
262-
*
262+
*
263263
* @param assistantId the id of the chatgpt assistant to use
264264
* @param fileId the id of the file to search (file must have been already uploaded)
265265
* @param threadId the id of the thread to run (must already exist)
@@ -290,14 +290,13 @@ export class GPTController {
290290
`Getting Prelim data for part ${part.device_name} File ID: ${fileId} (Thread ID: ${threadId})`,
291291
);
292292
const partRun = await this.runThread(threadId, assistantId);
293+
console.log(partRun)
293294
partTests.push({
294295
...part,
295-
preliminary_test_data: partRun.map((data: PreliminaryTestData) => ({
296-
...data,
297-
seeData: data.seeData || [],
298-
tidData: data.tidData || [],
299-
ddData: data.ddData || [],
300-
})),
296+
preliminary_test_types: partRun.map((data: string) => data),
297+
seeData: [],
298+
tidData: [],
299+
ddData: []
301300
} as ai_part);
302301
}
303302
console.log(
@@ -310,7 +309,7 @@ export class GPTController {
310309
*
311310
* Get the test results related to specific tests
312311
* i.e. SEE, TID, or DD
313-
*
312+
*
314313
*
315314
* Parameters are given in a named object form
316315
*
@@ -332,8 +331,8 @@ export class GPTController {
332331
parts: ai_part[];
333332
}): Promise<ai_part[]> {
334333
for (const part of parts) {
335-
for (const test of part.preliminary_test_data) {
336-
if (test.testing_type === "SEE") {
334+
for (const test of part.preliminary_test_types) {
335+
if (test === "SEE") {
337336
await this.addMessage(
338337
threadId,
339338
fileId,
@@ -342,23 +341,23 @@ export class GPTController {
342341
console.log(
343342
`Getting Specifc Data for Part ${part.device_name} File ID: ${fileId} (Thread ID: ${threadId})`,
344343
);
345-
test.seeData.push(await this.runThread(threadId, assistantId));
346-
} else if (test.testing_type === "TID") {
344+
part.seeData.push(await this.runThread(threadId, assistantId));
345+
} else if (test === "TID") {
347346
await this.addMessage(
348347
threadId,
349348
fileId,
350349
`You are to only look for data related to this part ${part.device_name}, ${questions.tidData.prompt}`,
351350
);
352-
test.tidData.push(await this.runThread(threadId, assistantId));
353-
} else if (test.testing_type === "DD") {
351+
part.tidData.push(await this.runThread(threadId, assistantId));
352+
} else if (test === "DD") {
354353
await this.addMessage(
355354
threadId,
356355
fileId,
357356
`You are to only look for data related to this part ${part.device_name}, ${questions.ddData.prompt}`,
358357
);
359-
test.ddData.push(await this.runThread(threadId, assistantId));
358+
part.ddData.push(await this.runThread(threadId, assistantId));
360359
} else {
361-
console.log("Passing", test.testing_type);
360+
console.log("Passing", test);
362361
}
363362
}
364363
}

server/src/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,8 @@ 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
109-
const pdfFile =
110-
"./test/Single-Event_Effects_Measurements_on_COTS_Electronic_Devices_for_Use_on_NASA_Mars_Missions.pdf";
108+
const pdfFile = "./test/SEE_in-flight_data_for_two_static_32KB_memories_on_high_earth_orbit.pdf"; // Replace with actual file path
109+
//const pdfFile = "./test/Single-Event_Effects_Measurements_on_COTS_Electronic_Devices_for_Use_on_NASA_Mars_Missions.pdf";
111110
//const pdfFile = "./test/Review_of_TID_Effects_Reported_in_ProASIC3_and_ProASIC3L_FPGAs_for_3D_PLUS_Camera_Heads.pdf";
112111
const pdfFiles = [
113112
"./test/Radiation_effects_predicted_observed_and_compared_for_spacecraft_systems.pdf",
@@ -120,7 +119,7 @@ async function initializeSystem(): Promise<{
120119
const results = await gptController.processRadiationPapers(pdfFiles);
121120

122121
fs.writeFileSync(
123-
"./test/4-paper-output.json",
122+
"./test/1-paper-output.json",
124123
JSON.stringify(results, null, 4),
125124
);
126125

server/src/refined-prompts.data.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,18 @@ export const questions = {
9393
},
9494
testingConditions: {
9595
prompt: `Describe the type of radiation testing that was conducted.:
96-
- Type of testing performed (ONLY ONE OF [ TID, SEE, DD])
96+
97+
This testing will be either TID SEE(General) OR DD
98+
You may ONLY return types TID, SEE or DD for this step
9799
98-
There might be more than one test for the given part, if that is the case return a list of tests pertaining to the part
100+
There might be more than one test for the given part, return a list of different test types, if two tests of the same type are found create two entries, for one each
99101
100102
Return the response as a **valid JSON object** with the following structure:
101103
102-
{
103-
"testing_type": "TID | SEE | DD",
104+
[
105+
"TID | SEE | DD"
104106
105-
}
107+
]
106108
107109
Return only valid JSON with no extra text.`,
108110
schenma: {

server/src/types.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,14 @@ export type ai_part = {
9797
component_type: string;
9898
manufacturer: string;
9999
other_details: string;
100-
preliminary_test_data: PreliminaryTestData[];
100+
preliminary_test_types: PreliminaryTestType[];
101+
tidData: TIDDataType[];
102+
seeData: SEEDataType[];
103+
ddData: DDDataType[];
101104
};
102105

106+
export type PreliminaryTestType = "SEE" | "TID" | "DD" | string;
107+
103108
export type PreliminaryTestData = {
104109
testing_type: "SEE" | "TID" | "DD" | null;
105110
tidData: TIDDataType[];
Lines changed: 108 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,121 @@
11
{
2+
"paper": {
3+
"paper_name": "SEE In-Flight Data for Two Static 32KB Memories on High Earth Orbit",
4+
"year": 2002,
5+
"authors": [
6+
{
7+
"name": "S. Duzellier"
8+
},
9+
{
10+
"name": "S. Bourdarie"
11+
},
12+
{
13+
"name": "R. Velazco"
14+
},
15+
{
16+
"name": "B. Nicolescu"
17+
},
18+
{
19+
"name": "R. Ecoffet"
20+
}
21+
],
22+
"objective": "The main objective of the paper is to present the detailed analysis of in-flight data obtained from two 32KB SRAMs in the MPTB orbit, focusing on the performance, reliability, and survivability of these devices in the space radiation environment over a four-year period."
23+
},
224
"parts": [
325
{
426
"device_name": "HM62256",
527
"component_type": "SRAM",
628
"manufacturer": "Hitachi",
7-
"other_details": "32KB memory used for SEE detection, entire device operated for SEE detection, tested using Ram Static Test method"
29+
"other_details": "Entirely tested using Ram Static Test method. Exhibited stuck bits during solar events.",
30+
"preliminary_test_types": [
31+
"SEE",
32+
"TID"
33+
],
34+
"seeData": [
35+
{
36+
"max_fluence": 0.0000025,
37+
"energy_levels": "Proton Threshold: 10 MeV, Heavy Ion Threshold: 1.7 MeV/mg.cm²",
38+
"facility_name": "MPTB orbit",
39+
"environmental_conditions": "High latitude and altitude, during solar events",
40+
"terrestrial": false,
41+
"in_flight": true,
42+
"source": "Protons",
43+
"see_type": "SEU",
44+
"amplitude": 60,
45+
"duration": 1,
46+
"cross_section_saturation": 5.4e-13,
47+
"cross_section_threshold": 1.7,
48+
"cross_section_type": "cm²/bit",
49+
"special_notes": "Stuck bits correlated to solar events indicating heavy ions presence"
50+
}
51+
],
52+
"tidData": [
53+
{
54+
"max_fluence": 0.0000025,
55+
"energy_levels": "Proton Threshold: 10 MeV, Heavy Ion Threshold: 1.7 MeV/mg.cm²",
56+
"facility_name": "MPTB orbit",
57+
"environmental_conditions": "High latitude and altitude, during solar events",
58+
"terrestrial": false,
59+
"in_flight": true,
60+
"source": "Protons",
61+
"max_tid": 0.0000048,
62+
"dose_rate": 0.0000016,
63+
"eldrs_observed": false,
64+
"dose_to_failure": 365,
65+
"increased_power_usage": true,
66+
"power_usage_description": "Increased during solar events",
67+
"current_leakage": 0.0001,
68+
"failing_time": "Few hours to almost a month",
69+
"special_notes": "Stuck bits correlated to solar events indicating heavy ions presence"
70+
}
71+
],
72+
"ddData": []
873
},
974
{
1075
"device_name": "HM65756",
1176
"component_type": "SRAM",
1277
"manufacturer": "Matra-MHS",
13-
"other_details": "32KB memory used for storage of T225 process workspaces and data, partly tested using CRC and RST methods"
78+
"other_details": "Partly tested using both Cyclic Redundancy Checksum and Ram Static Test methods. Used for storage of T225 process workspaces and data.",
79+
"preliminary_test_types": [
80+
"SEE",
81+
"SEE"
82+
],
83+
"seeData": [
84+
{
85+
"max_fluence": 0.0000028,
86+
"energy_levels": "Proton Threshold: 5 MeV, Heavy Ion Threshold: 0.1 MeV/mg.cm²",
87+
"facility_name": "MPTB orbit",
88+
"environmental_conditions": "High latitude and altitude, during solar events",
89+
"terrestrial": false,
90+
"in_flight": true,
91+
"source": "Protons",
92+
"see_type": "SEU",
93+
"amplitude": 60,
94+
"duration": 1,
95+
"cross_section_saturation": 1.2e-12,
96+
"cross_section_threshold": 0.1,
97+
"cross_section_type": "cm²/bit",
98+
"special_notes": "SEU rate increases during solar events, indicating heavy ion presence"
99+
},
100+
{
101+
"max_fluence": 0.0000028,
102+
"energy_levels": "Proton Threshold: 5 MeV, Heavy Ion Threshold: 0.1 MeV/mg.cm²",
103+
"facility_name": "MPTB orbit",
104+
"environmental_conditions": "High latitude and altitude, during solar events",
105+
"terrestrial": false,
106+
"in_flight": true,
107+
"source": "Protons",
108+
"see_type": "SEU",
109+
"amplitude": 60,
110+
"duration": 1,
111+
"cross_section_saturation": 1.2e-12,
112+
"cross_section_threshold": 0.1,
113+
"cross_section_type": "cm²/bit",
114+
"special_notes": "SEU rate increases during solar events, indicating heavy ion presence"
115+
}
116+
],
117+
"tidData": [],
118+
"ddData": []
14119
}
15-
],
16-
"part_tests": [
17-
{
18-
"device_name": "HM62256",
19-
"testing_type": "SEE",
20-
"max_fluence": 10000000,
21-
"energy_levels": "Proton: 10 MeV, Heavy Ion: 1.7 MeV/mg.cm²",
22-
"facility_name": "MPTB (Microelectronics and Photonics Test Bed)",
23-
"environmental_conditions": "High Earth Orbit, solar maximum condition",
24-
"terrestrial": false,
25-
"in_flight": true
26-
},
27-
{
28-
"device_name": "HM65756",
29-
"testing_type": "SEE",
30-
"max_fluence": 10000000,
31-
"energy_levels": "Proton: 5 MeV, Heavy Ion: 0.1 MeV/mg.cm²",
32-
"facility_name": "MPTB (Microelectronics and Photonics Test Bed)",
33-
"environmental_conditions": "High Earth Orbit, solar maximum condition",
34-
"terrestrial": false,
35-
"in_flight": true
36-
}
37-
],
38-
"part_specific": {
39-
"SEE": [
40-
{
41-
"max_fluence": 10000000,
42-
"energy_levels": "Proton: 10 MeV, Heavy Ion: 1.7 MeV/mg.cm²",
43-
"facility_name": "MPTB (Microelectronics and Photonics Test Bed)",
44-
"environmental_conditions": "High Earth Orbit, solar maximum condition",
45-
"terrestrial": false,
46-
"in_flight": true,
47-
"source": "Protons",
48-
"see_type": "SEU",
49-
"amplitude": 60,
50-
"duration": 1,
51-
"cross_section_saturation": 0.0000025,
52-
"cross_section_threshold": 1.7,
53-
"cross_section_type": "cm²/bit",
54-
"special_notes": "Stuck bits observed during solar events, indicating presence of heavy ions"
55-
},
56-
{
57-
"max_fluence": 10000000,
58-
"energy_levels": "Proton: 5 MeV, Heavy Ion: 0.1 MeV/mg.cm²",
59-
"facility_name": "MPTB (Microelectronics and Photonics Test Bed)",
60-
"environmental_conditions": "High Earth Orbit, solar maximum condition",
61-
"terrestrial": false,
62-
"in_flight": true,
63-
"source": "Protons",
64-
"see_type": "SEU",
65-
"amplitude": 47,
66-
"duration": 1,
67-
"cross_section_saturation": 0.0000028,
68-
"cross_section_threshold": 0.1,
69-
"cross_section_type": "cm²/bit",
70-
"special_notes": "SEU rate increase observed during solar events, particularly severe during the November 2001 event"
71-
}
72-
],
73-
"TID": [],
74-
"DD": []
75-
}
120+
]
76121
}

0 commit comments

Comments
 (0)