forked from intitni/CopilotForXcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmbeddingAPIDefinitions.swift
More file actions
40 lines (32 loc) · 1.06 KB
/
Copy pathEmbeddingAPIDefinitions.swift
File metadata and controls
40 lines (32 loc) · 1.06 KB
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
35
36
37
38
import AIModel
import Foundation
import Preferences
import CodableWrappers
protocol EmbeddingAPI {
func embed(text: String) async throws -> EmbeddingResponse
func embed(texts: [String]) async throws -> EmbeddingResponse
func embed(tokens: [[Int]]) async throws -> EmbeddingResponse
}
public struct EmbeddingResponse: Decodable {
public struct Object: Decodable {
public var embedding: [Float]
public var index: Int
@FallbackDecoding<EmptyString>
public var object: String
}
@FallbackDecoding<EmptyArray>
public var data: [Object]
@FallbackDecoding<EmptyString>
public var model: String
public struct Usage: Decodable {
@FallbackDecoding<EmptyInt>
public var prompt_tokens: Int
@FallbackDecoding<EmptyInt>
public var total_tokens: Int
public struct Fallback: FallbackValueProvider {
public static var defaultValue: Usage { Usage(prompt_tokens: 0, total_tokens: 0) }
}
}
@FallbackDecoding<Usage.Fallback>
public var usage: Usage
}