Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENG-1726 #48

Merged
merged 36 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
05c030f
initial
Archetapp Dec 11, 2024
2139944
Request/Response bodies setup.
Archetapp Dec 11, 2024
a97e698
Client + Tests
Archetapp Dec 11, 2024
99cdef6
Tests + Model updates
Archetapp Dec 12, 2024
e26b80a
Upload file testing
Archetapp Dec 12, 2024
b1a34e7
Further testing
Archetapp Dec 12, 2024
cfd1b3b
update
Archetapp Dec 12, 2024
2751dad
removed API keys
Archetapp Dec 12, 2024
1169f77
added get file test
Archetapp Dec 12, 2024
1da79d3
upload video and upload audio working
Archetapp Dec 12, 2024
1edef27
Fixed file loading
Archetapp Dec 12, 2024
68b9fde
Cleaned up tests
Archetapp Dec 12, 2024
a1fdad7
Added image test
Archetapp Dec 12, 2024
9912970
Added url test endpoint
Archetapp Dec 12, 2024
29168fd
Cleanup
Archetapp Dec 12, 2024
a1ee4bb
cleanup
Archetapp Dec 12, 2024
492c1f8
cleanup
Archetapp Dec 12, 2024
dfa83bc
update function call tests
Archetapp Dec 12, 2024
c3fc2d2
added role
Archetapp Dec 13, 2024
88974de
Added function calling + tests
Archetapp Dec 13, 2024
07fac45
CodeFunction initial
Archetapp Dec 13, 2024
ce5aca1
Testing fixes
Archetapp Dec 13, 2024
738c180
removed key
Archetapp Dec 13, 2024
1fea31e
Grounding initial setup
Archetapp Dec 13, 2024
b2009e1
Fixed endpoints
Archetapp Dec 18, 2024
d6a6b37
Structured Output
Archetapp Dec 18, 2024
5a478e1
removed key
Archetapp Dec 18, 2024
52dbf38
Fine Tuning
Archetapp Dec 18, 2024
ef3cfdf
Embeddings
Archetapp Dec 18, 2024
16520f5
refactor
Archetapp Dec 18, 2024
1ef4a63
Fixed embeddings
Archetapp Dec 18, 2024
04f0f30
removed resources. Fixed tests.
Archetapp Dec 20, 2024
46a03b8
removed key
Archetapp Dec 20, 2024
bcdb64c
Refactor
vmanot Dec 20, 2024
61ff2c2
Update package
vmanot Dec 20, 2024
043cd68
Merge branch 'main' of https://github.com/PreternaturalAI/AI into ENG…
vmanot Dec 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "c84aa4446fdd21cbb193bc4ba0b1cdc79c7ec1f15c14460832a38ff9323b7098",
"originHash" : "094840915419b625ed8a43083bdf164ab8d3f6bbb7fda2dcec07cb5e55a2b736",
"pins" : [
{
"identity" : "corepersistence",
Expand All @@ -16,7 +16,7 @@
"location" : "https://github.com/vmanot/Merge.git",
"state" : {
"branch" : "master",
"revision" : "aca0b0c7a48d91934b098bab9b5c4a9f343369f2"
"revision" : "4bc71ce650b79b3dbe1a26acf7e54b29d750e0b6"
}
},
{
Expand All @@ -34,7 +34,7 @@
"location" : "https://github.com/vmanot/Swallow.git",
"state" : {
"branch" : "master",
"revision" : "890a767eacad123a5310cdcc8074d16378c18cbe"
"revision" : "4c05166cf644846199fb734bbc47d74f87610945"
}
},
{
Expand All @@ -49,9 +49,9 @@
{
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
"location" : "https://github.com/swift-precompiled/swift-syntax",
"location" : "https://github.com/apple/swift-syntax.git",
"state" : {
"revision" : "85ba62b876bb023acdd828d738703f1c08eaa058",
"revision" : "0687f71944021d616d34d922343dcef086855920",
"version" : "600.0.1"
}
},
Expand Down
67 changes: 54 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,33 @@ 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"
],
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