write-language 0.1.3 → 0.1.5
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 +60 -10
- package/package.json +9 -7
- package/src/generate-response.ts +196 -196
- package/src/generation-types.ts +90 -90
- package/src/index.ts +44 -40
- package/src/language-model-registry.ts +1336 -1336
- package/src/llm-providers.png +0 -0
- package/src/prompt-templates.ts +651 -651
- package/src/prompts/index.ts +0 -0
- package/src/prompts/meta-search-types.ts +7 -0
- package/src/prompts/search-prompts.ts +168 -168
- package/src/provider-factory.ts +98 -98
- package/src/tools/qwksearch-api-tools.ts +327 -0
- package/src/utils/markdown-to-html.ts +53 -0
package/src/generation-types.ts
CHANGED
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
/**
|
|
3
|
-
* @module research/agents/generate-language-types
|
|
4
|
-
* @description Shared types for the generate-language module.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/** Supported LLM provider identifiers */
|
|
8
|
-
export type LLMProviderName =
|
|
9
|
-
| "nvidia"
|
|
10
|
-
| "openrouter"
|
|
11
|
-
| "anthropic"
|
|
12
|
-
| "google"
|
|
13
|
-
| "openai"
|
|
14
|
-
| "xai"
|
|
15
|
-
| "groq"
|
|
16
|
-
| "cloudflare"
|
|
17
|
-
| "perplexity"
|
|
18
|
-
| "amazon"
|
|
19
|
-
| "bedrock"
|
|
20
|
-
| "togetherai"
|
|
21
|
-
| (string & {}); // preserve autocomplete while allowing arbitrary strings
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Configuration options for {@link generateLanguageResponse}.
|
|
25
|
-
*/
|
|
26
|
-
export interface GenerateLanguageOptions {
|
|
27
|
-
/** LLM provider to use */
|
|
28
|
-
provider: LLMProviderName;
|
|
29
|
-
/**
|
|
30
|
-
* API key for the provider.
|
|
31
|
-
* For `cloudflare`, use the `"apiToken:accountId"` format.
|
|
32
|
-
* For `amazon`/`bedrock`, use bearer token or `"region:accessKeyId:secretAccessKey"` format.
|
|
33
|
-
*/
|
|
34
|
-
apiKey?: string;
|
|
35
|
-
/** Agent prompt template name (default: `"question"`) */
|
|
36
|
-
agent?: string;
|
|
37
|
-
/** Specific model ID. Falls back to the provider's registered default. */
|
|
38
|
-
model?: string;
|
|
39
|
-
/**
|
|
40
|
-
* Sampling temperature (0\u20132).
|
|
41
|
-
* Lower = more deterministic; higher = more creative. Default: `1`
|
|
42
|
-
*/
|
|
43
|
-
temperature?: number;
|
|
44
|
-
/** User query text */
|
|
45
|
-
query?: string;
|
|
46
|
-
/** Article or document text to process */
|
|
47
|
-
article?: string;
|
|
48
|
-
/** Prior conversation history for context-aware agents */
|
|
49
|
-
chat_history?: string;
|
|
50
|
-
/** Return `HTML` (`true`) or raw Markdown (`false`). Default: `true` */
|
|
51
|
-
html?: boolean;
|
|
52
|
-
/** Truncate the prompt to the model's context window length. Default: `true` */
|
|
53
|
-
applyContextLimit?: boolean;
|
|
54
|
-
/** Additional template variables forwarded to the agent prompt */
|
|
55
|
-
[key: string]: unknown;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/** Return value of {@link generateLanguageResponse} */
|
|
59
|
-
export interface GenerateLanguageResult {
|
|
60
|
-
/** Generated response in HTML or Markdown format */
|
|
61
|
-
content?: string;
|
|
62
|
-
/** Structured data extracted by the agent's `after` callback */
|
|
63
|
-
extract?: unknown;
|
|
64
|
-
/** Human-readable error message when generation fails */
|
|
65
|
-
error?: string;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/** Agent prompt template definition */
|
|
69
|
-
export interface AgentPrompt {
|
|
70
|
-
name: string;
|
|
71
|
-
/** Mustache-style template string with `{variableName}` placeholders */
|
|
72
|
-
template?: string;
|
|
73
|
-
prompt?: string;
|
|
74
|
-
/** Called before template substitution to pre-process the prompt */
|
|
75
|
-
before?: (
|
|
76
|
-
prompt: string | undefined,
|
|
77
|
-
options: GenerateLanguageOptions,
|
|
78
|
-
) => string;
|
|
79
|
-
/** Called after generation to extract structured data from the raw reply */
|
|
80
|
-
after?: (reply: string, options: GenerateLanguageOptions) => unknown;
|
|
81
|
-
/** Names of registered agent tools to attach to this agent */
|
|
82
|
-
tools?: string[];
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/** A registered agent tool with a name, schema, and async handler */
|
|
86
|
-
export interface AgentTool {
|
|
87
|
-
name: string;
|
|
88
|
-
func: (...args: unknown[]) => unknown | Promise<unknown>;
|
|
89
|
-
[key: string]: unknown;
|
|
90
|
-
}
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @module research/agents/generate-language-types
|
|
4
|
+
* @description Shared types for the generate-language module.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** Supported LLM provider identifiers */
|
|
8
|
+
export type LLMProviderName =
|
|
9
|
+
| "nvidia"
|
|
10
|
+
| "openrouter"
|
|
11
|
+
| "anthropic"
|
|
12
|
+
| "google"
|
|
13
|
+
| "openai"
|
|
14
|
+
| "xai"
|
|
15
|
+
| "groq"
|
|
16
|
+
| "cloudflare"
|
|
17
|
+
| "perplexity"
|
|
18
|
+
| "amazon"
|
|
19
|
+
| "bedrock"
|
|
20
|
+
| "togetherai"
|
|
21
|
+
| (string & {}); // preserve autocomplete while allowing arbitrary strings
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Configuration options for {@link generateLanguageResponse}.
|
|
25
|
+
*/
|
|
26
|
+
export interface GenerateLanguageOptions {
|
|
27
|
+
/** LLM provider to use */
|
|
28
|
+
provider: LLMProviderName;
|
|
29
|
+
/**
|
|
30
|
+
* API key for the provider.
|
|
31
|
+
* For `cloudflare`, use the `"apiToken:accountId"` format.
|
|
32
|
+
* For `amazon`/`bedrock`, use bearer token or `"region:accessKeyId:secretAccessKey"` format.
|
|
33
|
+
*/
|
|
34
|
+
apiKey?: string;
|
|
35
|
+
/** Agent prompt template name (default: `"question"`) */
|
|
36
|
+
agent?: string;
|
|
37
|
+
/** Specific model ID. Falls back to the provider's registered default. */
|
|
38
|
+
model?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Sampling temperature (0\u20132).
|
|
41
|
+
* Lower = more deterministic; higher = more creative. Default: `1`
|
|
42
|
+
*/
|
|
43
|
+
temperature?: number;
|
|
44
|
+
/** User query text */
|
|
45
|
+
query?: string;
|
|
46
|
+
/** Article or document text to process */
|
|
47
|
+
article?: string;
|
|
48
|
+
/** Prior conversation history for context-aware agents */
|
|
49
|
+
chat_history?: string;
|
|
50
|
+
/** Return `HTML` (`true`) or raw Markdown (`false`). Default: `true` */
|
|
51
|
+
html?: boolean;
|
|
52
|
+
/** Truncate the prompt to the model's context window length. Default: `true` */
|
|
53
|
+
applyContextLimit?: boolean;
|
|
54
|
+
/** Additional template variables forwarded to the agent prompt */
|
|
55
|
+
[key: string]: unknown;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Return value of {@link generateLanguageResponse} */
|
|
59
|
+
export interface GenerateLanguageResult {
|
|
60
|
+
/** Generated response in HTML or Markdown format */
|
|
61
|
+
content?: string;
|
|
62
|
+
/** Structured data extracted by the agent's `after` callback */
|
|
63
|
+
extract?: unknown;
|
|
64
|
+
/** Human-readable error message when generation fails */
|
|
65
|
+
error?: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Agent prompt template definition */
|
|
69
|
+
export interface AgentPrompt {
|
|
70
|
+
name: string;
|
|
71
|
+
/** Mustache-style template string with `{variableName}` placeholders */
|
|
72
|
+
template?: string;
|
|
73
|
+
prompt?: string;
|
|
74
|
+
/** Called before template substitution to pre-process the prompt */
|
|
75
|
+
before?: (
|
|
76
|
+
prompt: string | undefined,
|
|
77
|
+
options: GenerateLanguageOptions,
|
|
78
|
+
) => string;
|
|
79
|
+
/** Called after generation to extract structured data from the raw reply */
|
|
80
|
+
after?: (reply: string, options: GenerateLanguageOptions) => unknown;
|
|
81
|
+
/** Names of registered agent tools to attach to this agent */
|
|
82
|
+
tools?: string[];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** A registered agent tool with a name, schema, and async handler */
|
|
86
|
+
export interface AgentTool {
|
|
87
|
+
name: string;
|
|
88
|
+
func: (...args: unknown[]) => unknown | Promise<unknown>;
|
|
89
|
+
[key: string]: unknown;
|
|
90
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,40 +1,44 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Language Generation Module
|
|
3
|
-
*
|
|
4
|
-
* Centralized exports for AI language model response generation using Vercel AI SDK.
|
|
5
|
-
* Provides prompt templates, model registries, provider factories, and response
|
|
6
|
-
* generation functions for 10+ LLM providers.
|
|
7
|
-
*
|
|
8
|
-
* @module language-generation
|
|
9
|
-
* @author ai-research-agent contributors
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
generateLanguageResponse,
|
|
14
|
-
convertMarkdownToHTMLEscaped,
|
|
15
|
-
} from "./generate-response";
|
|
16
|
-
|
|
17
|
-
export type {
|
|
18
|
-
LLMProviderName,
|
|
19
|
-
GenerateLanguageOptions,
|
|
20
|
-
GenerateLanguageResult,
|
|
21
|
-
} from "./generate-response";
|
|
22
|
-
|
|
23
|
-
export type {
|
|
24
|
-
AgentPrompt,
|
|
25
|
-
AgentTool,
|
|
26
|
-
} from "./generation-types";
|
|
27
|
-
|
|
28
|
-
export { AGENT_PROMPTS, extractJSONFromLanguageReply } from "./prompt-templates";
|
|
29
|
-
export {
|
|
30
|
-
LANGUAGE_MODELS,
|
|
31
|
-
LANGUAGE_PROVIDERS,
|
|
32
|
-
getModelsByProvider,
|
|
33
|
-
getAllModels,
|
|
34
|
-
getModelsByCapability,
|
|
35
|
-
getTextOnlyModels,
|
|
36
|
-
getMultimodalModels,
|
|
37
|
-
} from "./language-model-registry";
|
|
38
|
-
export type { ModelCapability, ModelInfo } from "./language-model-registry";
|
|
39
|
-
export { createLLMProvider } from "./provider-factory";
|
|
40
|
-
export * from "./prompts";
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Language Generation Module
|
|
3
|
+
*
|
|
4
|
+
* Centralized exports for AI language model response generation using Vercel AI SDK.
|
|
5
|
+
* Provides prompt templates, model registries, provider factories, and response
|
|
6
|
+
* generation functions for 10+ LLM providers.
|
|
7
|
+
*
|
|
8
|
+
* @module language-generation
|
|
9
|
+
* @author ai-research-agent contributors
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
generateLanguageResponse,
|
|
14
|
+
convertMarkdownToHTMLEscaped,
|
|
15
|
+
} from "./generate-response";
|
|
16
|
+
|
|
17
|
+
export type {
|
|
18
|
+
LLMProviderName,
|
|
19
|
+
GenerateLanguageOptions,
|
|
20
|
+
GenerateLanguageResult,
|
|
21
|
+
} from "./generate-response";
|
|
22
|
+
|
|
23
|
+
export type {
|
|
24
|
+
AgentPrompt,
|
|
25
|
+
AgentTool,
|
|
26
|
+
} from "./generation-types";
|
|
27
|
+
|
|
28
|
+
export { AGENT_PROMPTS, extractJSONFromLanguageReply } from "./prompt-templates";
|
|
29
|
+
export {
|
|
30
|
+
LANGUAGE_MODELS,
|
|
31
|
+
LANGUAGE_PROVIDERS,
|
|
32
|
+
getModelsByProvider,
|
|
33
|
+
getAllModels,
|
|
34
|
+
getModelsByCapability,
|
|
35
|
+
getTextOnlyModels,
|
|
36
|
+
getMultimodalModels,
|
|
37
|
+
} from "./language-model-registry";
|
|
38
|
+
export type { ModelCapability, ModelInfo } from "./language-model-registry";
|
|
39
|
+
export { createLLMProvider } from "./provider-factory";
|
|
40
|
+
export * from "./prompts";
|
|
41
|
+
|
|
42
|
+
// Export tools and utilities for agent usage
|
|
43
|
+
export { AGENT_TOOLS } from "./tools/qwksearch-api-tools";
|
|
44
|
+
export { convertMarkdownToHTMLEscaped as markdownToHTML } from "./utils/markdown-to-html";
|