Skip to content

hardware

enrich_processor(processor, router=None)

Enriches a Processor object with detailed information using the AI router.

Source code in wintermute/ai/utils/hardware.py
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
def enrich_processor(processor: Processor, router: Router | None = None) -> Processor:
    """Enriches a Processor object with detailed information using the AI router."""

    if router is None:
        router = init_router()
        logger.debug("Router not defined, initializing inside enrich_processor")

    try:
        answer = simple_chat(
            router,
            f"Provide me with the processor name as processor, core, instruction set, number of cpu_cores, key features, processor family, \
            description, manufacturer, model, architecture, endianness and overall capabilities of the {processor.processor} processor, in the \
            architecture field encompass the core, instruction_set, cpu_cores and key_features. Respond with only the json format with each \
            capability and characteristics, including the general pinout, boot pinout, JTAG pinout, UART pinout as pinout in the json",
            task_tag="ProcessorEnrichment",
        )
    except Exception as e:
        logger.error(f"Error during processor enrichment: {e}")
        return processor

    try:
        answer_json = json.loads(answer)
        _processor = Processor.from_dict(answer_json)
    except json.JSONDecodeError as e:
        logger.error(f"JSON decoding error: {e}")
        return processor
    except TypeError as e:
        logger.error(f"Type error during Processor parsing: {e}")
        return processor
    except Exception as e:
        logger.error(f"Error parsing AI response: {e}")
        return processor
    return _processor