api-swift / Sources / IrdAPI / Flows / Jobs+Builders.swift
170 words
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import Foundation

/// Convenience builders mirroring the sibling clients, one per job type.
public extension JobSpec {
    static func domainAvailabilityBulk(domains: [String]) -> JobSpec {
        .domainAvailabilityBulk(DomainAvailabilityBulkJob(domains: domains))
    }

    static func embedding(input: String, model: String? = nil) -> JobSpec {
        .embedding(EmbeddingJob(input: input, model: model))
    }

    static func llmChat(messages: [ChatMessage], model: String? = nil, maxTokens: Int? = nil, temperature: Double? = nil) -> JobSpec {
        .llmChat(LlmChatJob(messages: messages, model: model, maxTokens: maxTokens, temperature: temperature))
    }

    static func llmRawCompletion(prompt: String, model: String? = nil, maxTokens: Int? = nil, temperature: Double? = nil) -> JobSpec {
        .llmRawCompletion(LlmRawCompletionJob(prompt: prompt, model: model, maxTokens: maxTokens, temperature: temperature))
    }

    static func nlpAnalyze(input: String, language: NlpAnalyzeJobLanguage? = nil) -> JobSpec {
        .nlpAnalyze(NlpAnalyzeJob(input: input, language: language))
    }

    static func nlpDetectLanguage(input: String) -> JobSpec {
        .nlpDetectLanguage(NlpDetectLanguageJob(input: input))
    }
}

public extension ChatMessage {
    static func system(_ content: String) -> ChatMessage { ChatMessage(role: .system, content: content) }
    static func user(_ content: String) -> ChatMessage { ChatMessage(role: .user, content: content) }
    static func assistant(_ content: String) -> ChatMessage { ChatMessage(role: .assistant, content: content) }
}

static mirror of HEAD · about · clone: git clone https://ird.cod-sursa.ro/api-swift.git