Cannot find type ToolOutput in scope

My sample app has been working with the following code:


   func call(arguments: Arguments) async throws -> ToolOutput {
        var temp:Int
        
        switch arguments.city {
            case .singapore: temp = Int.random(in: 30..<40)
            case .china: temp = Int.random(in: 10..<30)
        }
        
        let content = GeneratedContent(temp)
        let output = ToolOutput(content)
        return output
    }

However in 26 beta 5, ToolOutput no longer available, please advice what has changed.

Answered by MB-Researcher in 852397022

That's correct! We deprecated ToolOutput in beta 5, and replaced it with either String or GeneratedContent tool output.

For more, see the Tool's doc: https://developer.apple.com/documentation/foundationmodels/tool

Accepted Answer

I found that I can change to:

func call(arguments: Arguments) async throws -> GeneratedContent {
        var temp:Int
        
        switch arguments.city {
            case .singapore: temp = Int.random(in: 30..<40)
            case .china: temp = Int.random(in: 10..<30)
        }
        
        return GeneratedContent(temp)
    }

But not sure if this is correct.

That's correct! We deprecated ToolOutput in beta 5, and replaced it with either String or GeneratedContent tool output.

For more, see the Tool's doc: https://developer.apple.com/documentation/foundationmodels/tool

Will the Landmarks example project from WWDC 25 be updated? It makes use of ToolOutput and thus doesn't work anymore ootb.

Cannot find type ToolOutput in scope
 
 
Q