Foundation Model Framework

Hey everyone,

Is it possible to generate XML using the “Generable” macro of the Foundation Model Framework?

Answered by DTS Engineer in 857697022

Yeah, the Foundation Models framework doesn't provide an XML representation for a Generable type. (It does provide a JSON representation via rawContent and jsonString, if that matters.) You are free to provide your own implementation though, as shown below:

@Generable
struct YourGenerableType {
    ...
}

extension YourGenerableType.PartiallyGenerated {
    var xmlString: String {
       ...
    }
}

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Hello,

This seems unlikely for an LLM like AFM i.e. AFM doesn't "speak" XML.

Nonetheless, that's interesting feature request to consider.

Yeah, the Foundation Models framework doesn't provide an XML representation for a Generable type. (It does provide a JSON representation via rawContent and jsonString, if that matters.) You are free to provide your own implementation though, as shown below:

@Generable
struct YourGenerableType {
    ...
}

extension YourGenerableType.PartiallyGenerated {
    var xmlString: String {
       ...
    }
}

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Foundation Model Framework
 
 
Q