Skip to content

Commit 413b235

Browse files
committed
Remove unused Python import
1 parent d1d205e commit 413b235

3 files changed

Lines changed: 2 additions & 16 deletions

File tree

Tool/Sources/LangChain/Embedding/OpenAIEmbedding.swift

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import Foundation
22
import OpenAIService
3-
import PythonHelper
4-
import PythonKit
53
import TokenEncoder
64

75
public struct OpenAIEmbedding: Embeddings {
@@ -159,19 +157,9 @@ extension OpenAIEmbedding {
159157
} else if embeddings.isEmpty {
160158
results.append(.init(document: document, embeddings: []))
161159
} else if shouldAverageLongEmbeddings {
162-
// untested
160+
// unimplemented
163161
do {
164-
guard let averagedEmbeddings = try await runPython({
165-
let numpy = try Python.attemptImportOnPythonThread("numpy")
166-
let average = numpy.average(
167-
embeddings,
168-
axis: 0,
169-
weights: embeddings.map(\.count)
170-
)
171-
let normalized = average / numpy.linalg.norm(average)
172-
return [Float](normalized.tolist())
173-
}) else { throw CancellationError() }
174-
results.append(.init(document: document, embeddings: averagedEmbeddings))
162+
// average
175163
} catch {
176164
if let first = embeddings.first {
177165
results.append(.init(document: document, embeddings: first))

Tool/Tests/LangChainTests/TextSplitterTests/RecursiveCharacterTextSplitterTests.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import PythonHelper
21
import XCTest
32

43
@testable import LangChain

Tool/Tests/LangChainTests/TextSplitterTests/TextSplitterTests.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import PythonHelper
21
import XCTest
32

43
@testable import LangChain

0 commit comments

Comments
 (0)