Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/PreternaturalAI/AI into ENG…
Browse files Browse the repository at this point in the history
…-1700
  • Loading branch information
pmanot committed Jan 10, 2025
2 parents 7f8022a + ce8a069 commit 5f90137
Show file tree
Hide file tree
Showing 60 changed files with 3,411 additions and 141 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Run Preternatural Build (Xcode 16)
uses: PreternaturalAI/github-action/preternatural-build@main
with:
reuse_derived_data: false
xcode-version: '16'
platforms: 'macOS'
configurations: '["debug"]'
fuck-swift-syntax: true
10 changes: 5 additions & 5 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"originHash" : "83853ba40d0163bfd6b0d04a734383c75479cd9c8a0fc3cc071250b3e5259dc4",
"originHash" : "094840915419b625ed8a43083bdf164ab8d3f6bbb7fda2dcec07cb5e55a2b736",
"pins" : [
{
"identity" : "corepersistence",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vmanot/CorePersistence.git",
"state" : {
"branch" : "main",
"revision" : "302f6123b17047b5ea8f91b06b7440370ff13d9f"
"revision" : "3fc10b8e55c3be60ca4695200cecfc046c0ba29a"
}
},
{
Expand All @@ -16,7 +16,7 @@
"location" : "https://github.com/vmanot/Merge.git",
"state" : {
"branch" : "master",
"revision" : "e06fe31d67b5b2addb49d896437aade25323ef69"
"revision" : "4bc71ce650b79b3dbe1a26acf7e54b29d750e0b6"
}
},
{
Expand All @@ -34,7 +34,7 @@
"location" : "https://github.com/vmanot/Swallow.git",
"state" : {
"branch" : "master",
"revision" : "e1831bd9e9f9392be901c6fffee8e236a91ba044"
"revision" : "4c05166cf644846199fb734bbc47d74f87610945"
}
},
{
Expand Down Expand Up @@ -70,7 +70,7 @@
"location" : "https://github.com/SwiftUIX/SwiftUIX.git",
"state" : {
"branch" : "master",
"revision" : "a68663989c8aaae013c4104c6a4aa2f35afe1000"
"revision" : "50e2aacd7b124ffb5d06b4bfa5a4f255052a559b"
}
}
],
Expand Down
68 changes: 55 additions & 13 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,39 @@ let package = Package(
"Anthropic",
"Cohere",
"ElevenLabs",
"_Gemini",
"Groq",
"HuggingFace",
"Jina",
"Mistral",
"Ollama",
"OpenAI",
"Perplexity",
"TogetherAI",
"VoyageAI",
"AI",
]
),
.library(
name: "_Gemini",
targets: [
"_Gemini"
]
),
.library(
name: "Anthropic",
targets: [
"Anthropic"
]
),
.library(
name: "HumeAI",
targets: [
"HumeAI"
]
),
.library(
name: "NeetsAI",
targets: [
"NeetsAI"
]
),
.library(
name: "OpenAI",
targets: [
Expand All @@ -50,7 +64,31 @@ let package = Package(
targets: [
"Perplexity"
]
)
),
.library(
name: "PlayHT",
targets: [
"PlayHT"
]
),
.library(
name: "Rime",
targets: [
"Rime"
]
),
.library(
name: "TogetherAI",
targets: [
"TogetherAI"
]
),
.library(
name: "VoyageAI",
targets: [
"VoyageAI"
]
),
],
dependencies: [
.package(url: "https://github.com/vmanot/CorePersistence.git", branch: "main"),
Expand Down Expand Up @@ -340,30 +378,34 @@ let package = Package(
dependencies: [
"CoreMI",
"LargeLanguageModels",
"_Gemini",
"Anthropic",
"Cohere",
"ElevenLabs",
"Groq",
"HuggingFace",
"HumeAI",
"Jina",
"NeetsAI",
"Mistral",
"Ollama",
"OpenAI",
"Perplexity",
"PlayHT",
"Rime",
"Swallow",
"TogetherAI",
"VoyageAI",
],
path: "Sources/AI",
swiftSettings: [
.enableExperimentalFeature("AccessLevelOnImport")
]
),
.testTarget(
name: "_GeminiTests",
dependencies: [
"AI",
"Swallow",
"_Gemini"
],
path: "Tests/_Gemini",
swiftSettings: [
.enableExperimentalFeature("AccessLevelOnImport")
]
),
.testTarget(
name: "LargeLanguageModelsTests",
dependencies: [
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Swallow

extension AbstractLLM {
public protocol Completion: Codable, CustomDebugStringConvertible, Hashable, Sendable {
static var _completionType: AbstractLLM.CompletionType? { get }
static var knownCompletionType: AbstractLLM.CompletionType? { get }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ extension AbstractLLM {
associatedtype CompletionParameters: AbstractLLM.CompletionParameters
associatedtype Completion: Partializable

static var completionType: AbstractLLM.CompletionType? { get }
static var knownCompletionType: AbstractLLM.CompletionType? { get }

var context: PromptContextValues { get set }
}
}

extension AbstractLLM {
public enum ChatOrTextPrompt: Prompt {
public typealias CompletionParameters = AbstractLLM.ChatOrTextCompletionParameters
public typealias CompletionParameters = ChatOrTextCompletionParameters
public typealias Completion = AbstractLLM.ChatOrTextCompletion

public static var completionType: AbstractLLM.CompletionType? {
public static var knownCompletionType: AbstractLLM.CompletionType? {
nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Swallow

extension AbstractLLM {
public struct ChatCompletion: Completion {
public static var _completionType: AbstractLLM.CompletionType? {
public static var knownCompletionType: AbstractLLM.CompletionType? {
.chat
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extension AbstractLLM {
public typealias CompletionParameters = AbstractLLM.ChatCompletionParameters
public typealias Completion = AbstractLLM.ChatCompletion

public static var completionType: AbstractLLM.CompletionType? {
public static var knownCompletionType: AbstractLLM.CompletionType? {
.chat
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import Diagnostics
import Foundation
import Swallow
import CreateMLComponents

public protocol __AbstractLLM_ChatRole_Initiable {
init(from role: AbstractLLM.ChatRole) throws
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Swallow

extension AbstractLLM {
public struct TextCompletion: Completion {
public static var _completionType: AbstractLLM.CompletionType? {
public static var knownCompletionType: AbstractLLM.CompletionType? {
.text
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extension AbstractLLM {
public typealias CompletionParameters = AbstractLLM.TextCompletionParameters
public typealias Completion = AbstractLLM.TextCompletion

public static var completionType: AbstractLLM.CompletionType? {
public static var knownCompletionType: AbstractLLM.CompletionType? {
.text
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,49 @@ import LargeLanguageModels
import Swallow

extension OpenAI {
public struct ToolName: Codable, Hashable, RawRepresentable, Sendable {
public let rawValue: String

public init(rawValue: String) {
self.rawValue = rawValue
}

public init(from decoder: any Decoder) throws {
rawValue = try String(from: decoder)
}

public func encode(to encoder: any Encoder) throws {
try rawValue.encode(to: encoder)
}
}

public struct ChatFunctionDefinition: Codable, Hashable, Sendable {
public let name: String
public let name: OpenAI.ToolName
public let description: String
public let parameters: JSONSchema

public init(
name: String,
name: OpenAI.ToolName,
description: String,
parameters: JSONSchema
) {
self.name = name
self.description = description
self.parameters = parameters
}

public init(
name: String,
description: String,
parameters: JSONSchema
) {
self.init(
name: OpenAI.ToolName(
rawValue: name
),
description: description,
parameters: parameters
)
}
}
}
19 changes: 10 additions & 9 deletions Sources/OpenAI/Intramodular/Models/OpenAI.ToolChoice.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import NetworkKit
import Swift

extension OpenAI {
/// https://platform.openai.com/docs/api-reference/runs/createRun#runs-createrun-tool_choice
public enum ToolChoice: Codable {
case none
case auto
Expand All @@ -20,15 +21,7 @@ extension OpenAI {
}

public enum ToolValue: Codable {
case function(String)

public struct FunctionDetails: Codable {
var name: String

public init(name: String) {
self.name = name
}
}
case function(ToolName)
}
}
}
Expand Down Expand Up @@ -83,6 +76,14 @@ extension OpenAI.ToolChoice.ToolValue {
case function
}

private struct FunctionDetails: Codable {
var name: OpenAI.ToolName

public init(name: OpenAI.ToolName) {
self.name = name
}
}

public init(
from decoder: Decoder
) throws {
Expand Down
Loading

0 comments on commit 5f90137

Please sign in to comment.