Skip to content

Wrapper Method for Structured Output for Generable #2

Description

@rudrankriyam

Foundation Models has a simple method like:

// Generate a response using a custom type.
let response = try await session.respond(
    to: "Generate a cute rescue cat",
    generating: CatProfile.self
)

After its release, MLX Swift added a wrapper over their API:

let model = try await loadModel(id: "mlx-community/Qwen3-4B-4bit")
let session = ChatSession(model)
let response = try await session.respond(to: "What are two things to see in San Francisco?")

What do you think of something similar?

let model = try await loadModel(id: "mlx-community/Qwen3-4B-4bit")
let session = ChatSession(model)
let response = try await session.respond(to: "What are two things to see in San Francisco?", generating: Attractions.self)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions