mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-05-10 15:12:12 +00:00
Improved parameter extraction & extraction of other infos
This commit is contained in:
parent
0ca5a41298
commit
ad096aa6ff
2 changed files with 20 additions and 13 deletions
|
|
@ -63,13 +63,19 @@ final class DTOJsonSchemaConverter
|
|||
'type' => 'object',
|
||||
'properties' => [
|
||||
'name' => ['type' => 'string'],
|
||||
'value' => ['type' => 'string'],
|
||||
'unit' => ['type' => ['string', 'null']],
|
||||
'symbol' => ['type' => ['string', 'null'], 'description' => 'An optional quantity symbol for the parameter in latex code, like R_1'],
|
||||
'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'],
|
||||
'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.'],
|
||||
'value_max' => ['type' => ['number', 'null'], 'description' => 'If a range is given for the parameter, this is the maximum value. Null if not a range.'],
|
||||
'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.'],
|
||||
'group' => ['type' => ['string', 'null'], 'description' => 'An optional group name for the parameter, e.g. "Electrical parameters", "Mechanical parameters" etc.'],
|
||||
'unit' => ['type' => ['string', 'null'], 'description' => 'The unit of the parameter values, e.g. kg, Ohm, V, etc.'],
|
||||
],
|
||||
'required' => ['name', 'value'],
|
||||
'required' => ['name', 'value_typical', 'value_min', 'value_max', 'value_text']
|
||||
],
|
||||
],
|
||||
'datasheets' => [
|
||||
'description' => 'A list of datasheets, manuals, or other technical documents related to the product. Not images, but actual documents, preferably PDFs.',
|
||||
'type' => 'array',
|
||||
'items' => [
|
||||
'type' => 'object',
|
||||
|
|
@ -145,13 +151,15 @@ final class DTOJsonSchemaConverter
|
|||
$parameters = [];
|
||||
foreach ($data['parameters'] as $p) {
|
||||
if (!empty($p['name'])) {
|
||||
$value = $p['value'] ?? '';
|
||||
$unit = $p['unit'] ?? null;
|
||||
// Combine value and unit for parsing
|
||||
$valueWithUnit = $unit ? $value . ' ' . $unit : $value;
|
||||
$parameters[] = ParameterDTO::parseValueField(
|
||||
$parameters[] = new ParameterDTO(
|
||||
name: $p['name'],
|
||||
value: $valueWithUnit
|
||||
value_text: $p['value_text'] ?? null,
|
||||
value_typ: isset($p['value_typical']) && is_numeric($p['value_typical']) ? (float) $p['value_typical'] : null,
|
||||
value_min: isset($p['value_min']) && is_numeric($p['value_min']) ? (float) $p['value_min'] : null,
|
||||
value_max: isset($p['value_max']) && is_numeric($p['value_max']) ? (float) $p['value_max'] : null,
|
||||
unit: $p['unit'] ?? null,
|
||||
symbol: $p['symbol'] ?? null,
|
||||
group: $p['group'] ?? null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -217,13 +217,12 @@ Focus on the main content of the page, such as product descriptions, specificati
|
|||
|
||||
Rules:
|
||||
- manufacturing_status: Use "active", "obsolete", "nrfnd" (not recommended for new designs), "discontinued", or null
|
||||
- parameters: Extract technical specs like voltage, current, temperature, etc.
|
||||
- parameters: Extract technical specs like voltage, current, temperature, etc. and put them into the fields according to the JSON schema. Include units if available.
|
||||
- prices: Extract pricing tiers with minimum_quantity, price, and currency code
|
||||
- URLs must be absolute (include https://...)
|
||||
- If information is not found, use null
|
||||
- Return ONLY the JSON, no explanation text
|
||||
|
||||
For parameters, combine name, value, and unit. The unit should be separate if possible.
|
||||
- Try to avoid duplicating parameters, if the same parameter is mentioned multiple times, or if it is already used in another field.
|
||||
- Include only the 1 to 3 most relevant images, such as the main product image or important diagrams. Ignore decorative images, logos, or icons.
|
||||
PROMPT;
|
||||
|
||||
if ($this->settings->outputLanguage === null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue