Skip to content

Commit ad096aa

Browse files
committed
Improved parameter extraction & extraction of other infos
1 parent 0ca5a41 commit ad096aa

2 files changed

Lines changed: 20 additions & 13 deletions

File tree

src/Services/InfoProviderSystem/DTOJsonSchemaConverter.php

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,19 @@ public function getJSONSchema(): array
6363
'type' => 'object',
6464
'properties' => [
6565
'name' => ['type' => 'string'],
66-
'value' => ['type' => 'string'],
67-
'unit' => ['type' => ['string', 'null']],
66+
'symbol' => ['type' => ['string', 'null'], 'description' => 'An optional quantity symbol for the parameter in latex code, like R_1'],
67+
'value_typical' => ['type' => ['number', 'null'], 'description' => 'The typical value of the parameter. For example, for a resistor this could be 100 for a 100 Ohm resistor. Also used if only one numeric value is given. If used an unit should be given'],
68+
'value_min' => ['type' => ['number', 'null'], 'description' => 'If a range is given for the parameter, this is the minimum value. Null if no range is given.'],
69+
'value_max' => ['type' => ['number', 'null'], 'description' => 'If a range is given for the parameter, this is the maximum value. Null if not a range.'],
70+
'value_text' => ['type' => ['string', 'null'], 'description' => 'When a value is not numeric it can be put here as text. Only use if it does not fit in value_min, value_typical or value_max. E.g. "Yes", "Red", etc.'],
71+
'group' => ['type' => ['string', 'null'], 'description' => 'An optional group name for the parameter, e.g. "Electrical parameters", "Mechanical parameters" etc.'],
72+
'unit' => ['type' => ['string', 'null'], 'description' => 'The unit of the parameter values, e.g. kg, Ohm, V, etc.'],
6873
],
69-
'required' => ['name', 'value'],
74+
'required' => ['name', 'value_typical', 'value_min', 'value_max', 'value_text']
7075
],
7176
],
7277
'datasheets' => [
78+
'description' => 'A list of datasheets, manuals, or other technical documents related to the product. Not images, but actual documents, preferably PDFs.',
7379
'type' => 'array',
7480
'items' => [
7581
'type' => 'object',
@@ -145,13 +151,15 @@ public function jsonToDTO(array $data, string $providerKey, string $providerId,
145151
$parameters = [];
146152
foreach ($data['parameters'] as $p) {
147153
if (!empty($p['name'])) {
148-
$value = $p['value'] ?? '';
149-
$unit = $p['unit'] ?? null;
150-
// Combine value and unit for parsing
151-
$valueWithUnit = $unit ? $value . ' ' . $unit : $value;
152-
$parameters[] = ParameterDTO::parseValueField(
154+
$parameters[] = new ParameterDTO(
153155
name: $p['name'],
154-
value: $valueWithUnit
156+
value_text: $p['value_text'] ?? null,
157+
value_typ: isset($p['value_typical']) && is_numeric($p['value_typical']) ? (float) $p['value_typical'] : null,
158+
value_min: isset($p['value_min']) && is_numeric($p['value_min']) ? (float) $p['value_min'] : null,
159+
value_max: isset($p['value_max']) && is_numeric($p['value_max']) ? (float) $p['value_max'] : null,
160+
unit: $p['unit'] ?? null,
161+
symbol: $p['symbol'] ?? null,
162+
group: $p['group'] ?? null,
155163
);
156164
}
157165
}

src/Services/InfoProviderSystem/Providers/AIInfoExtractor.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,12 @@ private function buildSystemPrompt(): string
217217
218218
Rules:
219219
- manufacturing_status: Use "active", "obsolete", "nrfnd" (not recommended for new designs), "discontinued", or null
220-
- parameters: Extract technical specs like voltage, current, temperature, etc.
220+
- parameters: Extract technical specs like voltage, current, temperature, etc. and put them into the fields according to the JSON schema. Include units if available.
221221
- prices: Extract pricing tiers with minimum_quantity, price, and currency code
222222
- URLs must be absolute (include https://...)
223223
- If information is not found, use null
224-
- Return ONLY the JSON, no explanation text
225-
226-
For parameters, combine name, value, and unit. The unit should be separate if possible.
224+
- Try to avoid duplicating parameters, if the same parameter is mentioned multiple times, or if it is already used in another field.
225+
- Include only the 1 to 3 most relevant images, such as the main product image or important diagrams. Ignore decorative images, logos, or icons.
227226
PROMPT;
228227

229228
if ($this->settings->outputLanguage === null) {

0 commit comments

Comments
 (0)