init()

in HuggingChat-Mac/Models/Assistant.swift [38:66]


    init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)
        self.id = try container.decode(String.self, forKey: .id)
        if let creatorID = try? container.decode(String.self, forKey: .creatorID) {
            self.creatorID = creatorID
            self.createdByMe = nil
        } else if let createdByMe = try? container.decode(Bool.self, forKey: .createdByMe) {
            self.creatorID = nil
            self.createdByMe = createdByMe
        } else {
            throw HFError.decodeError(HFError.unknown)
        }
        self.creatorName = try container.decode(String.self, forKey: .creatorName)
        self.name = try container.decode(String.self, forKey: .name)
        self.modelID = try container.decode(String.self, forKey: .modelID)
        self.avatarID = try container.decodeIfPresent(String.self, forKey: .avatarID)
        self.preprompt = try container.decode(String.self, forKey: .preprompt)
        self.description = try container.decode(String.self, forKey: .description)
        if let inputs = try? container.decode([String].self, forKey: .exampleInputs) {
            self.promptExamples = inputs.map { PromptExample(title: $0, prompt: $0) }
        } else {
            self.promptExamples = []
        }
        self.createdAt = try container.decode(Date.self, forKey: .createdAt)
        self.updatedAt = try container.decode(Date.self, forKey: .updatedAt)
        self.userCount = try container.decode(Int.self, forKey: .userCount)
        self.featured = try container.decode(Bool.self, forKey: .featured)
        self.searchTokens = try container.decode([String].self, forKey: .searchTokens)
    }