Skip to content

Releases: yukiny0811/OpenAIStructure

v1.2.0

06 May 23:39

Choose a tag to compare

New Feature

  • request to return String

v1.1.1

05 May 06:20

Choose a tag to compare

Fix

  • access modifier for OpenAIModel

v1.1.0

04 May 12:28

Choose a tag to compare

New Feature

  • image input support

v1.0.1

03 May 15:00

Choose a tag to compare

Fix

  • Sendable OpenAIModel

v1.0.0 OpenAIStructure

02 May 15:54
0ef7f77

Choose a tag to compare

Swift Macro for OpenAI API Structured Outputs.

@OpenAIStructure(name: "talk_theme")
struct TalkTheme {

    @Field("Theme title")
    var title: String

    @Field("Theme overview")
    var overview: String

    @Field("Question blocks")
    var questionBlocks: [QuestionBlock]
}

@OpenAIStructure(name: "question_block")
struct QuestionBlock {

    @Field("Block label")
    var label: String

    @Field("List of questions")
    var questions: [String]
}
let result: TalkThemePack = try await OpenAIRequest.request(
    input: "Talk theme related to food.",
    instructions: "Provide some talk themes.",
    model: .o4_mini(reasoningEffort: .low),
    object: TalkTheme.self,
    apiKey: "<your_api_key>"
)