@j-o-r/hello-dave 0.0.0
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/LICENSE +73 -0
- package/README.md +207 -0
- package/bin/hdAsk.js +103 -0
- package/bin/hdClear.js +13 -0
- package/bin/hdCode.js +110 -0
- package/bin/hdConnect.js +230 -0
- package/bin/hdInspect.js +28 -0
- package/bin/hdNpm.js +114 -0
- package/bin/hdPrompt.js +108 -0
- package/examples/claude-test.js +89 -0
- package/examples/claude.js +143 -0
- package/examples/gpt.js +127 -0
- package/examples/gpt_code.js +125 -0
- package/examples/gpt_note_keeping.js +117 -0
- package/examples/grok.js +119 -0
- package/examples/grok_code.js +114 -0
- package/examples/grok_note_keeping.js +111 -0
- package/lib/API/anthropic.com/text.js +402 -0
- package/lib/API/brave.com/search.js +239 -0
- package/lib/API/openai.com/README.md +1 -0
- package/lib/API/openai.com/reponses/MESSAGES.md +69 -0
- package/lib/API/openai.com/reponses/text.js +416 -0
- package/lib/API/x.ai/text.js +415 -0
- package/lib/AgentClient.js +197 -0
- package/lib/AgentManager.js +144 -0
- package/lib/AgentServer.js +336 -0
- package/lib/Cli.js +256 -0
- package/lib/Prompt.js +728 -0
- package/lib/Session.js +231 -0
- package/lib/ToolSet.js +186 -0
- package/lib/fafs.js +93 -0
- package/lib/genericToolset.js +170 -0
- package/lib/index.js +34 -0
- package/lib/promptHelpers.js +132 -0
- package/lib/testToolset.js +42 -0
- package/module.md +189 -0
- package/package.json +49 -0
- package/types/API/anthropic.com/text.d.ts +207 -0
- package/types/API/brave.com/search.d.ts +156 -0
- package/types/API/openai.com/reponses/text.d.ts +225 -0
- package/types/API/x.ai/text.d.ts +286 -0
- package/types/AgentClient.d.ts +70 -0
- package/types/AgentManager.d.ts +112 -0
- package/types/AgentServer.d.ts +38 -0
- package/types/Cli.d.ts +52 -0
- package/types/Prompt.d.ts +298 -0
- package/types/Session.d.ts +31 -0
- package/types/ToolSet.d.ts +95 -0
- package/types/fafs.d.ts +47 -0
- package/types/genericToolset.d.ts +3 -0
- package/types/index.d.ts +23 -0
- package/types/promptHelpers.d.ts +1 -0
- package/types/testToolset.d.ts +3 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
export type ToolSet = import("../../ToolSet.js").default;
|
|
2
|
+
export type BraveRequest = {
|
|
3
|
+
headers: BRSearchAPIHeaders;
|
|
4
|
+
url: string;
|
|
5
|
+
};
|
|
6
|
+
export type BRSearchOptions = {
|
|
7
|
+
/**
|
|
8
|
+
* - question
|
|
9
|
+
*/
|
|
10
|
+
q?: string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* - Country Code
|
|
13
|
+
*/
|
|
14
|
+
country?: string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* - The 2 or more character language code for which the search results are provided.
|
|
17
|
+
*/
|
|
18
|
+
search_lang?: string | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* - Usually of the format <language_code>-<country_code> RFC 9110
|
|
21
|
+
*/
|
|
22
|
+
ui_lang?: string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* - The number of search results returned in response. The maximum is 20
|
|
25
|
+
*/
|
|
26
|
+
count?: number | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* - The zero based offset that indicates number of search results per page (count) to skip before returning the result.
|
|
29
|
+
*/
|
|
30
|
+
offset?: number | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* - off, moderate, strict
|
|
33
|
+
*/
|
|
34
|
+
safesearch?: string | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* - pd (24 h) pw (1 week) pm (1 month) py (1 year) , YYYY-MM-DDtoYYYY-MM-DD (range 2022-04-01to2022-07-30)
|
|
37
|
+
*/
|
|
38
|
+
freshness?: string | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* - Whether display strings (e.g. result snippets) should include decoration markers (e.g. highlighting characters).
|
|
41
|
+
*/
|
|
42
|
+
text_decoration?: boolean | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* - Whether to spellcheck provided query.
|
|
45
|
+
*/
|
|
46
|
+
spellcheck?: boolean | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* - discussions,faq,infobox,news,query,summarizer,videos,web
|
|
49
|
+
*/
|
|
50
|
+
result_filter?: string | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* - Goggles act as a custom re-ranking on top of Brave’s search index
|
|
53
|
+
*/
|
|
54
|
+
goggles_id?: string | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* - metric , imperial
|
|
57
|
+
*/
|
|
58
|
+
units?: string | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* - (only pro plan) A snippet is an excerpt from a page you get as a result of the query
|
|
61
|
+
*/
|
|
62
|
+
extra_snippets?: boolean | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* - 1 | 0 (only pro plan) This parameter enables summary key generation in web search results.
|
|
65
|
+
*/
|
|
66
|
+
summary?: number | undefined;
|
|
67
|
+
};
|
|
68
|
+
export type BRSearchAPIHeaders = {
|
|
69
|
+
/**
|
|
70
|
+
* - The default supported media type is application/json.
|
|
71
|
+
*/
|
|
72
|
+
Accept?: string | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* - The supported compression type is gzip.
|
|
75
|
+
*/
|
|
76
|
+
AcceptEncoding?: string | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* -
|
|
79
|
+
*/
|
|
80
|
+
ContentType?: string | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* - The Brave Web Search API version to use, denoted by the format YYYY-MM-DD. The latest version is used by default.
|
|
83
|
+
*/
|
|
84
|
+
ApiVersion?: string | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* - Search will return cached web search results by default. To prevent caching, set the Cache-Control header to no-cache.
|
|
87
|
+
*/
|
|
88
|
+
CacheControl?: string | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* - The user agent of the client sending the request. Search can utilize the user agent to provide a different experience depending on the client.
|
|
91
|
+
*/
|
|
92
|
+
UserAgent?: string | undefined;
|
|
93
|
+
/**
|
|
94
|
+
* - The latitude of the client's geographical location in degrees, to provide relevant local results. Must be >= -90.0 and <= +90.0 degrees.
|
|
95
|
+
*/
|
|
96
|
+
XLocLat?: number | undefined;
|
|
97
|
+
/**
|
|
98
|
+
* - The longitude of the client's geographical location in degrees, to provide relevant local results. Must be >= -180.0 and <= +180.0 degrees.
|
|
99
|
+
*/
|
|
100
|
+
XLocLong?: number | undefined;
|
|
101
|
+
/**
|
|
102
|
+
* - The IANA timezone for the client's device.
|
|
103
|
+
*/
|
|
104
|
+
XLocTimezone?: string | undefined;
|
|
105
|
+
/**
|
|
106
|
+
* - The generic name of the client city.
|
|
107
|
+
*/
|
|
108
|
+
XLocCity?: string | undefined;
|
|
109
|
+
/**
|
|
110
|
+
* - The code representing the client’s state/region, can be up to 3 characters long.
|
|
111
|
+
*/
|
|
112
|
+
XLocState?: string | undefined;
|
|
113
|
+
/**
|
|
114
|
+
* - The name of the client's state/region.
|
|
115
|
+
*/
|
|
116
|
+
XLocStateName?: string | undefined;
|
|
117
|
+
/**
|
|
118
|
+
* - The two-letter code for the client's country.
|
|
119
|
+
*/
|
|
120
|
+
XLocCountry?: string | undefined;
|
|
121
|
+
/**
|
|
122
|
+
* - The client's postal code.
|
|
123
|
+
*/
|
|
124
|
+
XLocPostalCode?: string | undefined;
|
|
125
|
+
/**
|
|
126
|
+
* - The secret token for the subscribed plan to authenticate the request. Can be obtained from API Keys.
|
|
127
|
+
*/
|
|
128
|
+
XSubscriptionToken?: string | undefined;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Create an brave search request
|
|
132
|
+
* It will use the last message as the search query to stay compatible with the prompt/records logic
|
|
133
|
+
* @param {string} query
|
|
134
|
+
* @param {BRSearchOptions} [opts] overwrite default request settings
|
|
135
|
+
* @param {BRSearchAPIHeaders} [hdrs] - optional headers to pass
|
|
136
|
+
* @returns {BraveRequest}
|
|
137
|
+
* @throws {Error}
|
|
138
|
+
*/
|
|
139
|
+
export function generateRequest(query: string, opts?: BRSearchOptions, hdrs?: BRSearchAPIHeaders): BraveRequest;
|
|
140
|
+
/**
|
|
141
|
+
* Process an openai response
|
|
142
|
+
* @param {object} response
|
|
143
|
+
* @returns {string}
|
|
144
|
+
* @throws {Error}
|
|
145
|
+
*/
|
|
146
|
+
export function parseResponse(response: object): string;
|
|
147
|
+
/**
|
|
148
|
+
* Create an brave search request
|
|
149
|
+
* It will use the last message as the search query to stay compatible with the prompt/records logic
|
|
150
|
+
* @param {string} query
|
|
151
|
+
* @param {BRSearchOptions} [opts] overwrite default request settings
|
|
152
|
+
* @param {BRSearchAPIHeaders} [hdrs] - optional headers to pass
|
|
153
|
+
* @throws {Error}
|
|
154
|
+
* @returns {Promise<import('../../ToolSet.js').TSCallResponse>}
|
|
155
|
+
*/
|
|
156
|
+
export function request(query: string, opts?: BRSearchOptions, hdrs?: BRSearchAPIHeaders): Promise<import("../../ToolSet.js").TSCallResponse>;
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
export type Prompt = import("../../../Prompt.js").default;
|
|
2
|
+
export type ToolSet = import("../../../ToolSet.js").default;
|
|
3
|
+
export type Includes = "code_interpreter_call.outputs" | "computer_call_output.output.image_url" | "file_search_call.results" | "message.input_image.image_url" | "message.output_text.logprobs" | "reasoning.encrypted_conten";
|
|
4
|
+
export type OAOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* - Whether to run in the background.
|
|
7
|
+
*/
|
|
8
|
+
background?: boolean | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* - Optional include parameter.
|
|
11
|
+
*/
|
|
12
|
+
include?: string | null | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* - Array of input objects.
|
|
15
|
+
*/
|
|
16
|
+
input?: OAInput[] | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* - Instructions for the model.
|
|
19
|
+
*/
|
|
20
|
+
instructions?: string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* - Maximum number of output tokens.
|
|
23
|
+
*/
|
|
24
|
+
max_output_tokens?: number | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* - Maximum number of tool calls allowed.
|
|
27
|
+
*/
|
|
28
|
+
max_tool_calls?: number | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* - Optional metadata object.
|
|
31
|
+
*/
|
|
32
|
+
metadata?: Object | null | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* - Model version to use.
|
|
35
|
+
*/
|
|
36
|
+
model?: "gpt-4.1" | "GPT-4o" | "o3" | "o3-mini" | "o4-mini" | "o1" | "o3-pro" | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* - Reusable prompt string.
|
|
39
|
+
*/
|
|
40
|
+
prompt?: string | null | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* - Reasoning configuration.
|
|
43
|
+
*/
|
|
44
|
+
reasoning?: {
|
|
45
|
+
/**
|
|
46
|
+
* - Effort level for reasoning.
|
|
47
|
+
*/
|
|
48
|
+
effort: "low" | "medium" | "high" | null;
|
|
49
|
+
/**
|
|
50
|
+
* - Summary type for reasoning.
|
|
51
|
+
*/
|
|
52
|
+
summary: "auto" | "concise" | "detailed";
|
|
53
|
+
} | undefined;
|
|
54
|
+
search?: "low" | "high" | "medium" | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* - Service tier option, default is auto-selected.
|
|
57
|
+
*/
|
|
58
|
+
service_tier?: "auto" | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* - Whether to store the response or not.
|
|
61
|
+
*/
|
|
62
|
+
store?: boolean | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* - Whether to stream the response or not.
|
|
65
|
+
*/
|
|
66
|
+
stream?: boolean | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* - Sampling temperature between 0 and 2.
|
|
69
|
+
*/
|
|
70
|
+
temperature?: number | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* - text format
|
|
73
|
+
*/
|
|
74
|
+
text?: {
|
|
75
|
+
/**
|
|
76
|
+
* - Summary type for reasoning.
|
|
77
|
+
*/
|
|
78
|
+
format: "text" | "json_schema";
|
|
79
|
+
} | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* - Allow parallel tool calls if true.
|
|
82
|
+
*/
|
|
83
|
+
parallel_tool_calls?: boolean | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* - Tool choice setting, default is auto-selected.
|
|
86
|
+
*/
|
|
87
|
+
tool_choice?: "auto" | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* =[] Array of tool call objects.
|
|
90
|
+
*/
|
|
91
|
+
tools: OAToolCall[];
|
|
92
|
+
/**
|
|
93
|
+
* =null An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability.
|
|
94
|
+
*/
|
|
95
|
+
top_logprobs: number | null;
|
|
96
|
+
/**
|
|
97
|
+
* =1 Top-p sampling value between 0 and 1.
|
|
98
|
+
*/
|
|
99
|
+
top_p: number | null;
|
|
100
|
+
/**
|
|
101
|
+
* - Needed reponse_id to validate tool calls on the next request
|
|
102
|
+
*/
|
|
103
|
+
previous_response_id?: string | null | undefined;
|
|
104
|
+
};
|
|
105
|
+
export type OAToolCall = {
|
|
106
|
+
/**
|
|
107
|
+
* - The type of the tool call, e.g., "function".
|
|
108
|
+
*/
|
|
109
|
+
type: string;
|
|
110
|
+
/**
|
|
111
|
+
* - The name of the function.
|
|
112
|
+
*/
|
|
113
|
+
name: string;
|
|
114
|
+
/**
|
|
115
|
+
* - A brief description of what the function does.
|
|
116
|
+
*/
|
|
117
|
+
description: string;
|
|
118
|
+
/**
|
|
119
|
+
* - The parameters required by the function.
|
|
120
|
+
*/
|
|
121
|
+
parameters: {
|
|
122
|
+
type: string;
|
|
123
|
+
properties: {
|
|
124
|
+
[x: string]: OAParameterProperty;
|
|
125
|
+
};
|
|
126
|
+
required?: string[] | undefined;
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
export type OAParameterProperty = {
|
|
130
|
+
/**
|
|
131
|
+
* - The data type of the parameter, e.g., "string".
|
|
132
|
+
*/
|
|
133
|
+
type: string;
|
|
134
|
+
/**
|
|
135
|
+
* - A brief description of the parameter.
|
|
136
|
+
*/
|
|
137
|
+
description: string;
|
|
138
|
+
};
|
|
139
|
+
export type OAMessage = {
|
|
140
|
+
/**
|
|
141
|
+
* - The role of the participant (e.g., "assistant", "user").
|
|
142
|
+
*/
|
|
143
|
+
role: "assistant" | "user";
|
|
144
|
+
/**
|
|
145
|
+
* - The content of the message.
|
|
146
|
+
*/
|
|
147
|
+
content: Array<OAContent>;
|
|
148
|
+
};
|
|
149
|
+
export type OAContent = {
|
|
150
|
+
/**
|
|
151
|
+
* - The type of content (e.g., "output_text", "input_text").
|
|
152
|
+
*/
|
|
153
|
+
type: "output_text" | "input_text";
|
|
154
|
+
/**
|
|
155
|
+
* - The text content.
|
|
156
|
+
*/
|
|
157
|
+
text: string;
|
|
158
|
+
};
|
|
159
|
+
export type OAFunctionCall = {
|
|
160
|
+
/**
|
|
161
|
+
* - Unique identifier for the function call.
|
|
162
|
+
*/
|
|
163
|
+
id: string;
|
|
164
|
+
/**
|
|
165
|
+
* - Indicates this is a function call (e.g., "function_call").
|
|
166
|
+
*/
|
|
167
|
+
type: "function_call";
|
|
168
|
+
/**
|
|
169
|
+
* - Unique identifier for the specific function call instance.
|
|
170
|
+
*/
|
|
171
|
+
call_id: string;
|
|
172
|
+
/**
|
|
173
|
+
* - The name of the function being called.
|
|
174
|
+
*/
|
|
175
|
+
name: string;
|
|
176
|
+
/**
|
|
177
|
+
* - JSON string representing arguments passed to the function.
|
|
178
|
+
*/
|
|
179
|
+
arguments: string;
|
|
180
|
+
};
|
|
181
|
+
export type OAFunctionCallOutput = {
|
|
182
|
+
/**
|
|
183
|
+
* - Indicates this is a function call output (e.g., "function_call_output").
|
|
184
|
+
*/
|
|
185
|
+
type: "function_call_output";
|
|
186
|
+
/**
|
|
187
|
+
* - Identifier linking to the related function call.
|
|
188
|
+
*/
|
|
189
|
+
call_id: string;
|
|
190
|
+
/**
|
|
191
|
+
* - JSON string representing the output from the function call.
|
|
192
|
+
*/
|
|
193
|
+
output: string;
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* Represents an OpenAI API response request INPUT structure.
|
|
197
|
+
*/
|
|
198
|
+
export type OAInput = (OAMessage | OAFunctionCall | OAFunctionCallOutput);
|
|
199
|
+
/**
|
|
200
|
+
* @param {Prompt} prompt
|
|
201
|
+
* @param {ToolSet} [toolset]
|
|
202
|
+
* @param {OAOptions} [options]
|
|
203
|
+
*/
|
|
204
|
+
export function generateRequest(prompt: Prompt, toolset?: ToolSet, options?: OAOptions): {
|
|
205
|
+
url: string;
|
|
206
|
+
headers: object;
|
|
207
|
+
body: OAOptions;
|
|
208
|
+
};
|
|
209
|
+
/**
|
|
210
|
+
* Parse a response
|
|
211
|
+
* @param {number} duration - Fetch time in MS
|
|
212
|
+
* @param {Prompt} prompt
|
|
213
|
+
* @param {import('../../../request.js').FetchResponse} res
|
|
214
|
+
* @param {import('../../../ToolSet.js').default} [toolset]
|
|
215
|
+
*/
|
|
216
|
+
export function parseResponse(duration: number, prompt: Prompt, res: any, toolset?: import("../../../ToolSet.js").default): Promise<void>;
|
|
217
|
+
/**
|
|
218
|
+
* Do a request
|
|
219
|
+
* @param {Prompt} prompt
|
|
220
|
+
* @param {ToolSet|null} toolset
|
|
221
|
+
* @param {OAOptions} [options]:
|
|
222
|
+
* @param {number} [counter] - leave empty this counts the number of requests when doing recursive request calls
|
|
223
|
+
* @return {Promise<import('../../../Session.js').Message>}
|
|
224
|
+
*/
|
|
225
|
+
export function request(prompt: Prompt, toolset?: ToolSet | null, options?: OAOptions, counter?: number): Promise<import("../../../Session.js").Message>;
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
export type Prompt = import("../../Prompt.js").default;
|
|
2
|
+
export type ToolSet = import("../../ToolSet.js").default;
|
|
3
|
+
export type grokModels = "grok-4" | "grok-3" | "grok-3-mini" | "grok-3-fast" | "grok-3-mini-fast";
|
|
4
|
+
export type grokReason = "low" | "high";
|
|
5
|
+
export type SearchParameters = {
|
|
6
|
+
mode: "on" | "auto";
|
|
7
|
+
/**
|
|
8
|
+
* ISO-8601 date (YYYY-MM-DD)
|
|
9
|
+
*/
|
|
10
|
+
from_date?: string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* ISO-8601 date (YYYY-MM-DD)
|
|
13
|
+
*/
|
|
14
|
+
to_date?: string | undefined;
|
|
15
|
+
sources?: (RssSource | WebSource | NewsSource | XSource)[] | undefined;
|
|
16
|
+
};
|
|
17
|
+
export type RssSource = {
|
|
18
|
+
type: "rss";
|
|
19
|
+
links: string[];
|
|
20
|
+
};
|
|
21
|
+
export type WebSource = {
|
|
22
|
+
type: "web";
|
|
23
|
+
/**
|
|
24
|
+
* ISO-3166-1 alpha-2
|
|
25
|
+
*/
|
|
26
|
+
country?: string | undefined;
|
|
27
|
+
safe_search?: boolean | undefined;
|
|
28
|
+
allowed_websites?: string[] | undefined;
|
|
29
|
+
excluded_websites?: string[] | undefined;
|
|
30
|
+
};
|
|
31
|
+
export type NewsSource = {
|
|
32
|
+
type: "news";
|
|
33
|
+
country?: string | undefined;
|
|
34
|
+
safe_search?: boolean | undefined;
|
|
35
|
+
allowed_websites?: string[] | undefined;
|
|
36
|
+
excluded_websites?: string[] | undefined;
|
|
37
|
+
};
|
|
38
|
+
export type XSource = {
|
|
39
|
+
type: "x";
|
|
40
|
+
};
|
|
41
|
+
export type XRequest = {
|
|
42
|
+
body: XOptions;
|
|
43
|
+
headers: Headers;
|
|
44
|
+
/**
|
|
45
|
+
* -
|
|
46
|
+
*/
|
|
47
|
+
url: string;
|
|
48
|
+
};
|
|
49
|
+
export type XFunctionCall = {
|
|
50
|
+
/**
|
|
51
|
+
* - The name of the function to call.
|
|
52
|
+
*/
|
|
53
|
+
name: string;
|
|
54
|
+
/**
|
|
55
|
+
* - The arguments for the function call in JSON string format.
|
|
56
|
+
*/
|
|
57
|
+
arguments: string;
|
|
58
|
+
};
|
|
59
|
+
export type XToolCall = {
|
|
60
|
+
/**
|
|
61
|
+
* - The unique identifier for the tool call.
|
|
62
|
+
*/
|
|
63
|
+
id: string;
|
|
64
|
+
/**
|
|
65
|
+
* - The type of the tool call, e.g., "function".
|
|
66
|
+
*/
|
|
67
|
+
type: string;
|
|
68
|
+
/**
|
|
69
|
+
* - The function call details.
|
|
70
|
+
*/
|
|
71
|
+
function: XFunctionCall;
|
|
72
|
+
};
|
|
73
|
+
export type XFunctionResponse = {
|
|
74
|
+
/**
|
|
75
|
+
* - must be 'tool'
|
|
76
|
+
*/
|
|
77
|
+
role: string;
|
|
78
|
+
/**
|
|
79
|
+
* - The arguments for the function call in JSON string format.
|
|
80
|
+
*/
|
|
81
|
+
content: string;
|
|
82
|
+
/**
|
|
83
|
+
* - The unique identifier for the tool call.
|
|
84
|
+
*/
|
|
85
|
+
tool_call_id: string;
|
|
86
|
+
};
|
|
87
|
+
export type XMessageResponse = {
|
|
88
|
+
/**
|
|
89
|
+
* - The index of the message.
|
|
90
|
+
*/
|
|
91
|
+
index: number;
|
|
92
|
+
/**
|
|
93
|
+
* - The message details.
|
|
94
|
+
*/
|
|
95
|
+
message: {
|
|
96
|
+
role: string;
|
|
97
|
+
content: string;
|
|
98
|
+
reasoning_content?: string | undefined;
|
|
99
|
+
refusal: string | null;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* - The reason for finishing (e.g., "stop").
|
|
103
|
+
*/
|
|
104
|
+
finish_reason: string;
|
|
105
|
+
/**
|
|
106
|
+
* - The reason for finishing (e.g., "stop").
|
|
107
|
+
*/
|
|
108
|
+
tools_calls: XToolCall[];
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* https://docs.x.ai/api/endpoints#chat-completions
|
|
112
|
+
*/
|
|
113
|
+
export type XOptions = {
|
|
114
|
+
/**
|
|
115
|
+
* - What model to use
|
|
116
|
+
*/
|
|
117
|
+
model?: grokModels | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* - the actual prompt
|
|
120
|
+
*/
|
|
121
|
+
messages?: any[] | undefined;
|
|
122
|
+
/**
|
|
123
|
+
* , callable functions
|
|
124
|
+
*/
|
|
125
|
+
tools?: XToolCall[] | undefined;
|
|
126
|
+
/**
|
|
127
|
+
* - Default 'none' when no function, 'auto' when present, or required
|
|
128
|
+
*/
|
|
129
|
+
tool_choice?: string | undefined;
|
|
130
|
+
/**
|
|
131
|
+
* - Response format
|
|
132
|
+
*/
|
|
133
|
+
response_format?: {
|
|
134
|
+
/**
|
|
135
|
+
* - The role of the sender (e.g., "assistant").
|
|
136
|
+
*/
|
|
137
|
+
type?: string | undefined;
|
|
138
|
+
} | undefined;
|
|
139
|
+
/**
|
|
140
|
+
* - What sampling temperature to use, between 0 and 2.
|
|
141
|
+
*/
|
|
142
|
+
temperature?: number | undefined;
|
|
143
|
+
/**
|
|
144
|
+
* - The maximum number of tokens allowed for the generated answer.
|
|
145
|
+
*/
|
|
146
|
+
max_completion_tokens?: number | undefined;
|
|
147
|
+
/**
|
|
148
|
+
* - Number between -2.0 and 2.0.
|
|
149
|
+
*/
|
|
150
|
+
presence_penalty?: number | undefined;
|
|
151
|
+
/**
|
|
152
|
+
* - Number between -2.0 and 2.0.
|
|
153
|
+
*/
|
|
154
|
+
frequency_penalty?: number | undefined;
|
|
155
|
+
/**
|
|
156
|
+
* - Number between -2.0 and 2.0.
|
|
157
|
+
*/
|
|
158
|
+
top_p?: number | undefined;
|
|
159
|
+
/**
|
|
160
|
+
* - How many chat completion choices to generate for each input message. default 1
|
|
161
|
+
*/
|
|
162
|
+
n?: number | undefined;
|
|
163
|
+
/**
|
|
164
|
+
* - Chunk/stream request default null
|
|
165
|
+
*/
|
|
166
|
+
stream?: boolean | undefined;
|
|
167
|
+
/**
|
|
168
|
+
* - Multiple calls at once
|
|
169
|
+
*/
|
|
170
|
+
parallel_tool_calls?: boolean | undefined;
|
|
171
|
+
/**
|
|
172
|
+
* - Who i am
|
|
173
|
+
*/
|
|
174
|
+
reasoning_effort?: grokReason | undefined;
|
|
175
|
+
/**
|
|
176
|
+
* - Who i am
|
|
177
|
+
*/
|
|
178
|
+
user?: string | undefined;
|
|
179
|
+
/**
|
|
180
|
+
* - see options
|
|
181
|
+
*/
|
|
182
|
+
seed?: number | undefined;
|
|
183
|
+
/**
|
|
184
|
+
* - live search
|
|
185
|
+
*/
|
|
186
|
+
search_parameters?: SearchParameters | undefined;
|
|
187
|
+
/**
|
|
188
|
+
* - Up to 4 sequences where the API will stop generating further tokens.
|
|
189
|
+
*/
|
|
190
|
+
stop?: string[] | undefined;
|
|
191
|
+
};
|
|
192
|
+
export type XResponse = {
|
|
193
|
+
/**
|
|
194
|
+
* - The unique identifier for the response.
|
|
195
|
+
*/
|
|
196
|
+
id: string;
|
|
197
|
+
/**
|
|
198
|
+
* - The type of object returned, typically "chat.completion".
|
|
199
|
+
*/
|
|
200
|
+
object: string;
|
|
201
|
+
/**
|
|
202
|
+
* - The timestamp of when the response was created.
|
|
203
|
+
*/
|
|
204
|
+
created: number;
|
|
205
|
+
/**
|
|
206
|
+
* - The model used to generate the response.
|
|
207
|
+
*/
|
|
208
|
+
model: string;
|
|
209
|
+
/**
|
|
210
|
+
* - An array of choice objects containing the response details.
|
|
211
|
+
*/
|
|
212
|
+
choices: Array<XChoice>;
|
|
213
|
+
/**
|
|
214
|
+
* - An object containing token usage information.
|
|
215
|
+
*/
|
|
216
|
+
usage: XUsage;
|
|
217
|
+
/**
|
|
218
|
+
* - The system fingerprint for the response.
|
|
219
|
+
*/
|
|
220
|
+
system_fingerprint: string;
|
|
221
|
+
/**
|
|
222
|
+
* - HTTP headers associated with the response.
|
|
223
|
+
*/
|
|
224
|
+
http_headers: Object;
|
|
225
|
+
};
|
|
226
|
+
export type XChoice = {
|
|
227
|
+
/**
|
|
228
|
+
* - The index of the choice in the response.
|
|
229
|
+
*/
|
|
230
|
+
index: number;
|
|
231
|
+
/**
|
|
232
|
+
* - The message object containing the role and content.
|
|
233
|
+
*/
|
|
234
|
+
message: XMessageResponse;
|
|
235
|
+
/**
|
|
236
|
+
* - Log probabilities, typically null.
|
|
237
|
+
*/
|
|
238
|
+
logprobs: null;
|
|
239
|
+
/**
|
|
240
|
+
* - The reason why the response finished.
|
|
241
|
+
*/
|
|
242
|
+
finish_reason: string;
|
|
243
|
+
};
|
|
244
|
+
export type XUsage = {
|
|
245
|
+
/**
|
|
246
|
+
* - The number of tokens in the prompt.
|
|
247
|
+
*/
|
|
248
|
+
prompt_tokens: number;
|
|
249
|
+
/**
|
|
250
|
+
* - The number of tokens in the completion.
|
|
251
|
+
*/
|
|
252
|
+
completion_tokens: number;
|
|
253
|
+
/**
|
|
254
|
+
* - The total number of tokens used.
|
|
255
|
+
*/
|
|
256
|
+
total_tokens: number;
|
|
257
|
+
};
|
|
258
|
+
/**
|
|
259
|
+
* Create an anthropic request
|
|
260
|
+
* @param {Prompt} prompt
|
|
261
|
+
* @param {ToolSet|void} [tools]
|
|
262
|
+
* @param {XOptions} [opts] overwrite default request settings
|
|
263
|
+
* @param {object} [hdrs] - optional headers to pass
|
|
264
|
+
* @returns {XRequest}
|
|
265
|
+
* @throws {Error}
|
|
266
|
+
*/
|
|
267
|
+
export function generateRequest(prompt: Prompt, tools?: void | import("../../ToolSet.js").default | undefined, opts?: XOptions, hdrs?: object): XRequest;
|
|
268
|
+
/**
|
|
269
|
+
* Process an openai response
|
|
270
|
+
* @param {number} duration - the time is MS before and after the request
|
|
271
|
+
* @param {import('lib/request.js').FetchResponse} res
|
|
272
|
+
* @param {Prompt} prompt
|
|
273
|
+
* @param {ToolSet} [toolset]
|
|
274
|
+
* @returns {Promise<void>}
|
|
275
|
+
* @throws {Error}
|
|
276
|
+
*/
|
|
277
|
+
export function parseResponse(duration: number, prompt: Prompt, res: any, toolset?: ToolSet): Promise<void>;
|
|
278
|
+
/**
|
|
279
|
+
* Do a request
|
|
280
|
+
* @param {Prompt} prompt
|
|
281
|
+
* @param {ToolSet|null} toolset
|
|
282
|
+
* @param {XOptions} [options]:
|
|
283
|
+
* @param {number} [counter] - leave empty this counts the number of requests when doing recursive request calls
|
|
284
|
+
* @return {Promise<import('../../Session.js').Message>}
|
|
285
|
+
*/
|
|
286
|
+
export function request(prompt: Prompt, toolset?: ToolSet | null, options?: XOptions, counter?: number): Promise<import("../../Session.js").Message>;
|