Skip to content

Commit bdd9d6f

Browse files
committed
Fix typo
1 parent b42cc2e commit bdd9d6f

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

Tool/Sources/LangChain/Embedding/OpenAIEmbedding.swift

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ extension OpenAIEmbedding {
5656
do {
5757
let embeddings = try await service.embed(text: document.pageContent)
5858
.data
59-
.map(\.embeddings).first ?? []
59+
.map(\.embedding).first ?? []
6060
return (document, embeddings)
6161
} catch {
6262
retryCount -= 1
@@ -114,15 +114,15 @@ extension OpenAIEmbedding {
114114
text.document,
115115
try await service.embed(text: text.document.pageContent)
116116
.data
117-
.map(\.embeddings)
117+
.map(\.embedding)
118118
)
119119
}
120120
if shouldAverageLongEmbeddings {
121121
return (
122122
text.document,
123123
try await service.embed(tokens: text.chunkedTokens)
124124
.data
125-
.map(\.embeddings)
125+
.map(\.embedding)
126126
)
127127
}
128128
// if `shouldAverageLongEmbeddings` is false,
@@ -131,7 +131,7 @@ extension OpenAIEmbedding {
131131
text.document,
132132
try await service.embed(tokens: [text.chunkedTokens.first ?? []])
133133
.data
134-
.map(\.embeddings)
134+
.map(\.embedding)
135135
)
136136
} catch {
137137
retryCount -= 1
@@ -158,12 +158,8 @@ extension OpenAIEmbedding {
158158
results.append(.init(document: document, embeddings: []))
159159
} else if shouldAverageLongEmbeddings {
160160
// unimplemented
161-
do {
162-
// average
163-
} catch {
164-
if let first = embeddings.first {
165-
results.append(.init(document: document, embeddings: first))
166-
}
161+
if let first = embeddings.first {
162+
results.append(.init(document: document, embeddings: first))
167163
}
168164
} else if let first = embeddings.first {
169165
results.append(.init(document: document, embeddings: first))

0 commit comments

Comments
 (0)