chat-agent-toolkit 1.2.379 → 1.2.381
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/chat-agent-toolkit/src/tools/qwksearch-api-tools.d.ts +1 -1
- package/dist/chat-agent-toolkit/src/tools/search/doc-utils.d.ts +33 -2
- package/dist/chat-agent-toolkit/src/tools/search/index.d.ts +2 -2
- package/dist/chat-agent-toolkit/src/tools/search/meta-search-types.d.ts +14 -1
- package/dist/chat-agent-toolkit/src/tools/search/metaSearchAgent.d.ts +1 -1
- package/dist/research-agent.cjs.js +1 -1
- package/dist/research-agent.cjs.js.map +1 -1
- package/dist/research-agent.es.js +1 -1
- package/dist/research-agent.es.js.map +1 -1
- package/package.json +2 -2
- package/src/tools/search/doc-utils.d.ts +16 -2
- package/src/tools/search/doc-utils.ts +246 -204
- package/src/tools/search/index.d.ts +2 -2
- package/src/tools/search/index.ts +14 -14
- package/src/tools/search/meta-search-types.d.ts +7 -1
- package/src/tools/search/meta-search-types.ts +78 -64
- package/src/tools/search/metaSearchAgent.d.ts +3 -4
- package/src/tools/search/metaSearchAgent.ts +518 -493
|
@@ -1,64 +1,78 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module research/search/meta-search-types
|
|
3
|
-
* @description Shared types for the MetaSearchAgent.
|
|
4
|
-
*/
|
|
5
|
-
import type { LanguageModel } from "ai";
|
|
6
|
-
import type EventEmitter from "events";
|
|
7
|
-
|
|
8
|
-
/** A single conversation turn, matching the Vercel AI SDK message shape. */
|
|
9
|
-
export interface ChatTurnMessage {
|
|
10
|
-
role: "user" | "assistant" | "system";
|
|
11
|
-
content: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/** A `[role, content]` tuple used for few-shot prompt examples. */
|
|
15
|
-
export type FewShotExample = [role: "user" | "assistant", content: string];
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @module research/search/meta-search-types
|
|
3
|
+
* @description Shared types for the MetaSearchAgent.
|
|
4
|
+
*/
|
|
5
|
+
import type { LanguageModel } from "ai";
|
|
6
|
+
import type EventEmitter from "events";
|
|
7
|
+
|
|
8
|
+
/** A single conversation turn, matching the Vercel AI SDK message shape. */
|
|
9
|
+
export interface ChatTurnMessage {
|
|
10
|
+
role: "user" | "assistant" | "system";
|
|
11
|
+
content: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** A `[role, content]` tuple used for few-shot prompt examples. */
|
|
15
|
+
export type FewShotExample = [role: "user" | "assistant", content: string];
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The pipeline's event emitter, plus the hook a consumer uses to push back.
|
|
19
|
+
*
|
|
20
|
+
* `emit()` is synchronous, so the answer loop would otherwise pull the entire
|
|
21
|
+
* model stream into memory at the model's pace while the consumer writes it
|
|
22
|
+
* out at the client's pace. A consumer that can be slow (an HTTP response
|
|
23
|
+
* stream, say) assigns `waitForDrain`; the loop awaits it between chunks and
|
|
24
|
+
* so advances no faster than the consumer does. Leaving it unset keeps the
|
|
25
|
+
* unthrottled behaviour, which is what an in-process consumer wants.
|
|
26
|
+
*/
|
|
27
|
+
export interface DrainableEmitter extends EventEmitter {
|
|
28
|
+
waitForDrain?: () => Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface MetaSearchAgentType {
|
|
32
|
+
searchAndAnswer: (
|
|
33
|
+
message: string,
|
|
34
|
+
history: ChatTurnMessage[],
|
|
35
|
+
llm: LanguageModel,
|
|
36
|
+
optimizationMode: "speed" | "balanced" | "quality",
|
|
37
|
+
fileIds: string[],
|
|
38
|
+
systemInstructions: string,
|
|
39
|
+
category?: string,
|
|
40
|
+
sourceExtractionEnabled?: boolean,
|
|
41
|
+
thinkingTimeLimit?: number,
|
|
42
|
+
/** User-authored replacement for the focus mode's query-expansion prompt. */
|
|
43
|
+
queryExpansionPrompt?: string,
|
|
44
|
+
) => Promise<DrainableEmitter>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Emitted on the EventEmitter data channel to report live search progress. */
|
|
48
|
+
export interface SearchingEvent {
|
|
49
|
+
query: string;
|
|
50
|
+
/** Display label shown in the UI (e.g. "Academic · max 10"). */
|
|
51
|
+
category?: string;
|
|
52
|
+
status: "running" | "done";
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface Config {
|
|
56
|
+
searchWeb: boolean;
|
|
57
|
+
rerank: boolean;
|
|
58
|
+
rerankThreshold: number;
|
|
59
|
+
queryGeneratorPrompt: string;
|
|
60
|
+
queryGeneratorFewShots: FewShotExample[];
|
|
61
|
+
responsePrompt: string;
|
|
62
|
+
activeEngines: string[];
|
|
63
|
+
/** Optional: Function to fetch documents from URLs */
|
|
64
|
+
getDocumentsFromLinks?: (options: { links: string[] }) => Promise<any[]>;
|
|
65
|
+
/** Optional: Function to search via SearXNG */
|
|
66
|
+
searchSearxng?: (query: string, options: any) => Promise<{ results: any[]; suggestions: string[] }>;
|
|
67
|
+
/** Optional: Function to search via Tavily */
|
|
68
|
+
searchTavily?: (query: string, options: any) => Promise<{ results: any[]; suggestions: string[] }>;
|
|
69
|
+
/** Optional: Function to check if Tavily is configured */
|
|
70
|
+
isTavilyConfigured?: () => boolean;
|
|
71
|
+
/** Optional: Function to scrape a URL */
|
|
72
|
+
scrapeURL?: (url: string, options: any) => Promise<string>;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export type BasicChainInput = {
|
|
76
|
+
chat_history: ChatTurnMessage[];
|
|
77
|
+
query: string;
|
|
78
|
+
};
|
|
@@ -4,9 +4,8 @@
|
|
|
4
4
|
* LLMs through the Vercel AI SDK (generateText/streamText).
|
|
5
5
|
*/
|
|
6
6
|
import { type LanguageModel } from "ai";
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
export type { MetaSearchAgentType, Config } from "./meta-search-types";
|
|
7
|
+
import type { Config, ChatTurnMessage, DrainableEmitter, MetaSearchAgentType } from "./meta-search-types";
|
|
8
|
+
export type { MetaSearchAgentType, Config, DrainableEmitter } from "./meta-search-types";
|
|
10
9
|
declare class MetaSearchAgent implements MetaSearchAgentType {
|
|
11
10
|
private config;
|
|
12
11
|
constructor(config: Config);
|
|
@@ -21,6 +20,6 @@ declare class MetaSearchAgent implements MetaSearchAgentType {
|
|
|
21
20
|
* "response", "searching", "end", and "error" events on the emitter.
|
|
22
21
|
*/
|
|
23
22
|
private runPipeline;
|
|
24
|
-
searchAndAnswer(message: string, history: ChatTurnMessage[], llm: LanguageModel, optimizationMode: "speed" | "balanced" | "quality", fileIds: string[], systemInstructions: string, category?: string, sourceExtractionEnabled?: boolean, thinkingTimeLimit?: number, queryExpansionPrompt?: string): Promise<
|
|
23
|
+
searchAndAnswer(message: string, history: ChatTurnMessage[], llm: LanguageModel, optimizationMode: "speed" | "balanced" | "quality", fileIds: string[], systemInstructions: string, category?: string, sourceExtractionEnabled?: boolean, thinkingTimeLimit?: number, queryExpansionPrompt?: string): Promise<DrainableEmitter>;
|
|
25
24
|
}
|
|
26
25
|
export default MetaSearchAgent;
|