Skip to content

Commit 32ca3f0

Browse files
committed
Adjust web search function
1 parent 04109d5 commit 32ca3f0

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

Core/Sources/ChatContextCollectors/WebChatContextCollector/WebChatContextCollector.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,14 @@ public final class WebChatContextCollector: ChatContextCollector {
2828

2929
extension WebChatContextCollector {
3030
static func detectLinks(from messages: [ChatMessage]) -> [String] {
31-
return messages.lazy.compactMap(\.content).map(detectLinks(from:)).flatMap { $0 }
31+
return messages.lazy
32+
.compactMap {
33+
$0.content ?? $0.functionCall?.arguments
34+
}
35+
.map(detectLinks(from:))
36+
.flatMap { $0 }
3237
}
33-
38+
3439
static func detectLinks(from content: String) -> [String] {
3540
var links = [String]()
3641
let detector = try? NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue)

Tool/Sources/LangChain/Chains/RetrievalQA.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public final class RetrievalQAChain: Chain {
2727
let embeddedQuestion = try await embedding.embed(query: input)
2828
let documents = try await vectorStore.searchWithDistance(
2929
embeddings: embeddedQuestion,
30-
count: 10
30+
count: 5
3131
)
3232
let refinementChain = RefineDocumentChain(chatModelFactory: chatModelFactory)
3333
let answer = try await refinementChain.run(

Tool/Sources/OpenAIService/Models.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public struct ChatMessage: Equatable, Codable {
1616
}
1717

1818
public struct FunctionCall: Codable, Equatable {
19-
var name: String
20-
var arguments: String
19+
public var name: String
20+
public var arguments: String
2121
}
2222

2323
/// The role of a message.

0 commit comments

Comments
 (0)