File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ public final class QAInformationRetrievalChain: Chain {
1111 public struct Output {
1212 public var information : String
1313 public var sourceDocuments : [ Document ]
14+ public var distance : [ Float ]
1415 }
1516
1617 public init (
@@ -79,7 +80,11 @@ public final class QAInformationRetrievalChain: Chain {
7980 callbackManagers: callbackManagers
8081 )
8182
82- return . init( information: relevantInformation, sourceDocuments: documents. map ( \. document) )
83+ return . init(
84+ information: relevantInformation,
85+ sourceDocuments: documents. map ( \. document) ,
86+ distance: documents. map ( \. distance)
87+ )
8388 }
8489
8590 public func parseOutput( _ output: Output ) -> String {
Original file line number Diff line number Diff line change @@ -36,9 +36,6 @@ public struct WebLoader: DocumentLoader {
3636 for url in urls {
3737 let strategy : LoadWebPageMainContentStrategy = {
3838 switch url {
39- case let url
40- where url. absoluteString. contains ( " developer.apple.com/documentation " ) :
41- return Developer_Apple_Documentation_LoadContentStrategy ( )
4239 default :
4340 return DefaultLoadContentStrategy ( )
4441 }
@@ -210,30 +207,5 @@ extension WebLoader {
210207 return true
211208 }
212209 }
213-
214- /// https://developer.apple.com/documentation
215- struct Developer_Apple_Documentation_LoadContentStrategy : LoadWebPageMainContentStrategy {
216- func load(
217- _ document: SwiftSoup . Document ,
218- metadata: Document . Metadata
219- ) throws -> [ Document ] {
220- if let mainContent = try ? {
221- if let main = text ( inFirstTag: " main " , from: document) { return main }
222- let body = try document. body ( ) ? . text ( )
223- return body
224- } ( ) {
225- return [ . init( pageContent: mainContent, metadata: metadata) ]
226- }
227- return [ ]
228- }
229-
230- func validate( _ document: SwiftSoup . Document ) -> Bool {
231- do {
232- return !( try document. getElementsByTag ( " main " ) . isEmpty ( ) )
233- } catch {
234- return false
235- }
236- }
237- }
238210}
239211
You can’t perform that action at this time.
0 commit comments