ForgeEmbed
Swift ForgeEmbed library product.
Swift ForgeEmbed library product.
Package contract
| Field | Value |
|---|---|
| Language | swift |
| Source version | Swift package source snapshot |
| Manifest | forge-swift/Package.swift |
| Source files | 4 |
| Evidence | Source reference; registry publication and runtime conformance are separate checks |
Import boundary
import ForgeEmbedUse a source checkout or your verified private registry. Manifest coordinates identify the package; they do not establish that a public registry release exists.
Source reference
Download package reference JSON. Each original source file and generated declaration artifact has its own SHA-256 digest. Function bodies and constant values are omitted from downloads. These are source declaration inventories, not compiler-resolved rustdoc, TypeDoc, DocC, or Dokka output. Private modules can contain public declarations that are not reachable through the package boundary; consult the entry point before importing.
Chunking.swift
Read declaration text · 15 declaration entries
public struct TextChunk: Sendable
public let content: String
/// The zero-based index of this chunk.
public let index: Int
/// The character offset in the original text.
public let offset: Int
public init(content: String, index: Int, offset: Int)
public let index: Int
/// The character offset in the original text.
public let offset: Int
public init(content: String, index: Int, offset: Int)
public let offset: Int
public init(content: String, index: Int, offset: Int)
public init(content: String, index: Int, offset: Int)
public protocol ChunkingStrategy: Sendable
public struct FixedSizeChunker: ChunkingStrategy, Sendable
public let chunkSize: Int
/// The number of characters to overlap between adjacent chunks.
public let overlap: Int
/// Creates a fixed-size chunker.
///
/// - Parameters:
/// - chunkSize: Maximum characters per chunk.
/// - overlap: Character overlap between chunks.
public init(chunkSize: Int;
public let overlap: Int
/// Creates a fixed-size chunker.
///
/// - Parameters:
/// - chunkSize: Maximum characters per chunk.
/// - overlap: Character overlap between chunks.
public init(chunkSize: Int;
public init(chunkSize: Int;
public func chunk(_ text: String) -> [TextChunk]
public struct ParagraphChunker: ChunkingStrategy, Sendable
public let maxChunkSize: Int
/// Creates a paragraph chunker.
///
/// - Parameter maxChunkSize: Maximum characters per chunk.
public init(maxChunkSize: Int;
public init(maxChunkSize: Int;
public func chunk(_ text: String) -> [TextChunk]Provider.swift
Read declaration text · 7 declaration entries
public struct EmbeddingResult: Sendable
public let embedding: [Float]
/// The input text that was embedded.
public let input: String
/// Token usage for this embedding call.
public let usage: Usage
public init(embedding: [Float], input: String, usage: Usage)
public let input: String
/// Token usage for this embedding call.
public let usage: Usage
public init(embedding: [Float], input: String, usage: Usage)
public let usage: Usage
public init(embedding: [Float], input: String, usage: Usage)
public init(embedding: [Float], input: String, usage: Usage)
public protocol EmbeddingProvider: Sendable
public func embedBatch(texts: [String], options: EmbedOptions) async throws -> [EmbeddingResult]Similarity.swift
Read declaration text · 5 declaration entries
public enum DistanceMetric: String, Codable, Sendable
public func computeSimilarity(
_ a: [Float],
_ b: [Float],
metric: DistanceMetric
) -> Float
public func cosineSimilarity(_ a: [Float], _ b: [Float]) -> Float
public func euclideanDistance(_ a: [Float], _ b: [Float]) -> Float
public func dotProduct(_ a: [Float], _ b: [Float]) -> FloatVectorStore.swift
Read declaration text · 17 declaration entries
public struct VectorDocument: Sendable
public let id: String
/// The original text content.
public let content: String
/// The embedding vector.
public let embedding: [Float]
/// Optional metadata.
public let metadata: [String: JSONValue]
public init(id: String, content: String, embedding: [Float], metadata: [String: JSONValue];
public let content: String
/// The embedding vector.
public let embedding: [Float]
/// Optional metadata.
public let metadata: [String: JSONValue]
public init(id: String, content: String, embedding: [Float], metadata: [String: JSONValue];
public let embedding: [Float]
/// Optional metadata.
public let metadata: [String: JSONValue]
public init(id: String, content: String, embedding: [Float], metadata: [String: JSONValue];
public let metadata: [String: JSONValue]
public init(id: String, content: String, embedding: [Float], metadata: [String: JSONValue];
public init(id: String, content: String, embedding: [Float], metadata: [String: JSONValue];
public struct SearchResult: Sendable
public let document: VectorDocument
/// The similarity score.
public let score: Float
public init(document: VectorDocument, score: Float)
public let score: Float
public init(document: VectorDocument, score: Float)
public init(document: VectorDocument, score: Float)
public final class InMemoryVectorStore: @unchecked Sendable
public init(metric: DistanceMetric;
public func add(_ document: VectorDocument)
public func addBatch(_ documents: [VectorDocument])
public func search(query: [Float], topK: Int;
public func remove(_ id: String) -> VectorDocument?
public var count: Int