Skip to content

Commit

Permalink
Update package
Browse files Browse the repository at this point in the history
  • Loading branch information
vmanot committed Mar 17, 2024
1 parent 61211f9 commit 4223c35
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,42 @@ extension LLMRequestHandling {
)
}

public func complete(
prompt: AbstractLLM.ChatPrompt,
model: some _MLModelIdentifierConvertible
) async throws -> AbstractLLM.ChatCompletion {
var prompt = prompt

prompt.context = try withMutableScope(prompt.context) { context in
context.completionType = .chat
context.modelIdentifier = try .one(model.__conversion())
}

return try await complete(prompt: prompt)
}

public func complete(
_ messages: [AbstractLLM.ChatMessage],
model: some _MLModelIdentifierConvertible
) async throws -> AbstractLLM.ChatCompletion {
let prompt = AbstractLLM.ChatPrompt(
messages: messages,
context: try withMutableScope(PromptContextValues.current) { context in
context.completionType = .chat
context.modelIdentifier = try .one(model.__conversion())
}
)

return try await complete(prompt: prompt)
}

public func complete(
_ message: AbstractLLM.ChatMessage,
model: some _MLModelIdentifierConvertible
) async throws -> AbstractLLM.ChatCompletion {
try await complete([message], model: model)
}

public func complete(
prompt: AbstractLLM.ChatOrTextPrompt,
parameters: any AbstractLLM.CompletionParameters
Expand Down

0 comments on commit 4223c35

Please sign in to comment.