gaunt-sloth-assistant 0.1.5 → 0.3.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/{.gsloth.preamble.review.md → .gsloth.guidelines.md} +0 -8
- package/.gsloth.review.md +7 -0
- package/.prettierrc.json +9 -0
- package/README.md +177 -158
- package/ROADMAP.md +1 -1
- package/dist/commands/askCommand.d.ts +6 -0
- package/dist/commands/askCommand.js +27 -0
- package/dist/commands/askCommand.js.map +1 -0
- package/dist/commands/initCommand.d.ts +6 -0
- package/dist/commands/initCommand.js +16 -0
- package/dist/commands/initCommand.js.map +1 -0
- package/dist/commands/reviewCommand.d.ts +3 -0
- package/dist/commands/reviewCommand.js +142 -0
- package/dist/commands/reviewCommand.js.map +1 -0
- package/dist/config.d.ts +84 -0
- package/dist/config.js +180 -0
- package/dist/config.js.map +1 -0
- package/dist/configs/anthropic.d.ts +4 -0
- package/{src → dist}/configs/anthropic.js +45 -48
- package/dist/configs/anthropic.js.map +1 -0
- package/dist/configs/fake.d.ts +3 -0
- package/{src → dist}/configs/fake.js +11 -14
- package/dist/configs/fake.js.map +1 -0
- package/dist/configs/groq.d.ts +4 -0
- package/{src → dist}/configs/groq.js +10 -13
- package/dist/configs/groq.js.map +1 -0
- package/dist/configs/types.d.ts +14 -0
- package/dist/configs/types.js +2 -0
- package/dist/configs/types.js.map +1 -0
- package/dist/configs/vertexai.d.ts +4 -0
- package/{src → dist}/configs/vertexai.js +44 -47
- package/dist/configs/vertexai.js.map +1 -0
- package/dist/consoleUtils.d.ts +6 -0
- package/{src → dist}/consoleUtils.js +10 -15
- package/dist/consoleUtils.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/llmUtils.d.ts +4 -0
- package/dist/llmUtils.js +39 -0
- package/dist/llmUtils.js.map +1 -0
- package/dist/modules/questionAnsweringModule.d.ts +7 -0
- package/dist/modules/questionAnsweringModule.js +33 -0
- package/dist/modules/questionAnsweringModule.js.map +1 -0
- package/dist/modules/reviewModule.d.ts +1 -0
- package/dist/modules/reviewModule.js +29 -0
- package/dist/modules/reviewModule.js.map +1 -0
- package/dist/modules/types.d.ts +18 -0
- package/dist/modules/types.js +2 -0
- package/dist/modules/types.js.map +1 -0
- package/dist/prompt.d.ts +8 -0
- package/dist/prompt.js +45 -0
- package/dist/prompt.js.map +1 -0
- package/dist/providers/file.d.ts +8 -0
- package/dist/providers/file.js +20 -0
- package/dist/providers/file.js.map +1 -0
- package/dist/providers/ghPrDiffProvider.d.ts +8 -0
- package/dist/providers/ghPrDiffProvider.js +16 -0
- package/dist/providers/ghPrDiffProvider.js.map +1 -0
- package/dist/providers/jiraIssueLegacyAccessTokenProvider.d.ts +8 -0
- package/dist/providers/jiraIssueLegacyAccessTokenProvider.js +62 -0
- package/dist/providers/jiraIssueLegacyAccessTokenProvider.js.map +1 -0
- package/dist/providers/jiraIssueLegacyProvider.d.ts +8 -0
- package/dist/providers/jiraIssueLegacyProvider.js +74 -0
- package/dist/providers/jiraIssueLegacyProvider.js.map +1 -0
- package/dist/providers/jiraIssueProvider.d.ts +11 -0
- package/dist/providers/jiraIssueProvider.js +96 -0
- package/dist/providers/jiraIssueProvider.js.map +1 -0
- package/dist/providers/text.d.ts +8 -0
- package/dist/providers/text.js +10 -0
- package/dist/providers/text.js.map +1 -0
- package/dist/providers/types.d.ts +21 -0
- package/dist/providers/types.js +2 -0
- package/dist/providers/types.js.map +1 -0
- package/dist/systemUtils.d.ts +32 -0
- package/dist/systemUtils.js +70 -0
- package/dist/systemUtils.js.map +1 -0
- package/dist/utils.d.ts +49 -0
- package/dist/utils.js +192 -0
- package/dist/utils.js.map +1 -0
- package/docs/CONFIGURATION.md +99 -10
- package/docs/RELEASE-HOWTO.md +7 -1
- package/eslint.config.js +99 -21
- package/gth-ASK-2025-05-16T14-11-39.md +3 -0
- package/gth-ASK-2025-05-16T14-18-27.md +3 -0
- package/gth-ASK-2025-05-16T14-18-56.md +1 -0
- package/gth-ASK-2025-05-16T14-41-20.md +3 -0
- package/gth-ASK-2025-05-16T14-43-31.md +51 -0
- package/gth-ASK-2025-05-16T16-05-52.md +62 -0
- package/gth-DIFF-review-2025-05-16T16-07-53.md +56 -0
- package/gth-DIFF-review-2025-05-16T16-18-55.md +292 -0
- package/index.js +10 -27
- package/package.json +26 -15
- package/src/commands/askCommand.ts +35 -0
- package/src/commands/initCommand.ts +19 -0
- package/src/commands/reviewCommand.ts +223 -0
- package/src/config.ts +269 -0
- package/src/configs/anthropic.ts +57 -0
- package/src/configs/fake.ts +15 -0
- package/src/configs/groq.ts +54 -0
- package/src/configs/vertexai.ts +53 -0
- package/src/consoleUtils.ts +33 -0
- package/src/index.ts +30 -0
- package/src/llmUtils.ts +54 -0
- package/src/modules/questionAnsweringModule.ts +44 -0
- package/src/modules/reviewModule.ts +31 -0
- package/src/modules/types.ts +23 -0
- package/src/prompt.ts +54 -0
- package/src/providers/file.ts +24 -0
- package/src/providers/ghPrDiffProvider.ts +20 -0
- package/src/providers/jiraIssueLegacyProvider.ts +103 -0
- package/src/providers/jiraIssueProvider.ts +133 -0
- package/src/providers/text.ts +14 -0
- package/src/providers/types.ts +24 -0
- package/src/systemUtils.ts +90 -0
- package/src/utils.ts +232 -0
- package/tsconfig.json +24 -0
- package/vitest.config.ts +13 -0
- package/.eslint.config.mjs +0 -72
- package/.github/dependabot.yml +0 -11
- package/.github/workflows/ci.yml +0 -33
- package/spec/.gsloth.config.js +0 -22
- package/spec/.gsloth.config.json +0 -25
- package/spec/askCommand.spec.js +0 -92
- package/spec/config.spec.js +0 -421
- package/spec/initCommand.spec.js +0 -55
- package/spec/predefinedConfigs.spec.js +0 -100
- package/spec/questionAnsweringModule.spec.js +0 -137
- package/spec/reviewCommand.spec.js +0 -222
- package/spec/reviewModule.spec.js +0 -28
- package/spec/support/jasmine.mjs +0 -14
- package/src/commands/askCommand.js +0 -27
- package/src/commands/initCommand.js +0 -17
- package/src/commands/reviewCommand.js +0 -154
- package/src/config.js +0 -177
- package/src/modules/questionAnsweringModule.js +0 -82
- package/src/modules/reviewModule.js +0 -70
- package/src/prompt.js +0 -34
- package/src/providers/file.js +0 -19
- package/src/providers/ghPrDiffProvider.js +0 -11
- package/src/providers/jiraIssueLegacyAccessTokenProvider.js +0 -84
- package/src/providers/text.js +0 -6
- package/src/systemUtils.js +0 -32
- package/src/utils.js +0 -173
- /package/{.gsloth.preamble.internal.md → .gsloth.backstory.md} +0 -0
package/dist/config.d.ts
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
import type { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
2
|
+
export interface SlothConfig extends BaseSlothConfig {
|
3
|
+
llm: BaseChatModel;
|
4
|
+
contentProvider: string;
|
5
|
+
requirementsProvider: string;
|
6
|
+
projectGuidelines: string;
|
7
|
+
projectReviewInstructions: string;
|
8
|
+
commands: {
|
9
|
+
pr: {
|
10
|
+
contentProvider: string;
|
11
|
+
};
|
12
|
+
};
|
13
|
+
}
|
14
|
+
/**
|
15
|
+
* Raw, unprocessed sloth config
|
16
|
+
*/
|
17
|
+
export interface RawSlothConfig extends BaseSlothConfig {
|
18
|
+
llm: LLMConfig;
|
19
|
+
}
|
20
|
+
/**
|
21
|
+
* Do not export this one
|
22
|
+
*/
|
23
|
+
interface BaseSlothConfig {
|
24
|
+
llm: unknown;
|
25
|
+
contentProvider?: string;
|
26
|
+
requirementsProvider?: string;
|
27
|
+
projectGuidelines?: string;
|
28
|
+
projectReviewInstructions?: string;
|
29
|
+
commands?: {
|
30
|
+
pr: {
|
31
|
+
contentProvider: string;
|
32
|
+
};
|
33
|
+
};
|
34
|
+
review?: {
|
35
|
+
requirementsProvider?: string;
|
36
|
+
contentProvider?: string;
|
37
|
+
};
|
38
|
+
pr?: {
|
39
|
+
requirementsProvider?: string;
|
40
|
+
};
|
41
|
+
requirementsProviderConfig?: Record<string, unknown>;
|
42
|
+
contentProviderConfig?: Record<string, unknown>;
|
43
|
+
}
|
44
|
+
/**
|
45
|
+
* @deprecated
|
46
|
+
* this object has blurred responsibility lines and bad name.
|
47
|
+
*/
|
48
|
+
export interface SlothContext {
|
49
|
+
config: SlothConfig;
|
50
|
+
session: {
|
51
|
+
configurable: {
|
52
|
+
thread_id: string;
|
53
|
+
};
|
54
|
+
};
|
55
|
+
}
|
56
|
+
export interface LLMConfig extends Record<string, unknown> {
|
57
|
+
type: string;
|
58
|
+
model: string;
|
59
|
+
}
|
60
|
+
export declare const USER_PROJECT_CONFIG_JS = ".gsloth.config.js";
|
61
|
+
export declare const USER_PROJECT_CONFIG_JSON = ".gsloth.config.json";
|
62
|
+
export declare const USER_PROJECT_CONFIG_MJS = ".gsloth.config.mjs";
|
63
|
+
export declare const GSLOTH_BACKSTORY = ".gsloth.backstory.md";
|
64
|
+
export declare const PROJECT_GUIDELINES = ".gsloth.guidelines.md";
|
65
|
+
export declare const PROJECT_REVIEW_INSTRUCTIONS = ".gsloth.review.md";
|
66
|
+
export declare const availableDefaultConfigs: readonly ["vertexai", "anthropic", "groq"];
|
67
|
+
export type ConfigType = (typeof availableDefaultConfigs)[number];
|
68
|
+
export declare const DEFAULT_CONFIG: Partial<SlothConfig>;
|
69
|
+
/**
|
70
|
+
* @deprecated
|
71
|
+
* this object has blurred responsibility lines and bad name.
|
72
|
+
* TODO this should be reworked to something more robust
|
73
|
+
*/
|
74
|
+
export declare const slothContext: SlothContext;
|
75
|
+
export declare function initConfig(): Promise<void>;
|
76
|
+
export declare function tryJsonConfig(jsonConfig: RawSlothConfig): Promise<void>;
|
77
|
+
export declare function createProjectConfig(configType: string): Promise<void>;
|
78
|
+
export declare function writeProjectReviewPreamble(): void;
|
79
|
+
/**
|
80
|
+
* @deprecated test only
|
81
|
+
* TODO should be gone together with slothContext itself
|
82
|
+
*/
|
83
|
+
export declare function reset(): void;
|
84
|
+
export {};
|
package/dist/config.js
ADDED
@@ -0,0 +1,180 @@
|
|
1
|
+
import path from 'node:path/posix';
|
2
|
+
import { v4 as uuidv4 } from 'uuid';
|
3
|
+
import { displayDebug, displayError, displayInfo, displayWarning } from '#src/consoleUtils.js';
|
4
|
+
import { importExternalFile, writeFileIfNotExistsWithMessages } from '#src/utils.js';
|
5
|
+
import { existsSync, readFileSync } from 'node:fs';
|
6
|
+
import { error, exit, getCurrentDir } from '#src/systemUtils.js';
|
7
|
+
export const USER_PROJECT_CONFIG_JS = '.gsloth.config.js';
|
8
|
+
export const USER_PROJECT_CONFIG_JSON = '.gsloth.config.json';
|
9
|
+
export const USER_PROJECT_CONFIG_MJS = '.gsloth.config.mjs';
|
10
|
+
export const GSLOTH_BACKSTORY = '.gsloth.backstory.md';
|
11
|
+
export const PROJECT_GUIDELINES = '.gsloth.guidelines.md';
|
12
|
+
export const PROJECT_REVIEW_INSTRUCTIONS = '.gsloth.review.md';
|
13
|
+
export const availableDefaultConfigs = ['vertexai', 'anthropic', 'groq'];
|
14
|
+
export const DEFAULT_CONFIG = {
|
15
|
+
llm: undefined,
|
16
|
+
contentProvider: 'file',
|
17
|
+
requirementsProvider: 'file',
|
18
|
+
projectGuidelines: PROJECT_GUIDELINES,
|
19
|
+
projectReviewInstructions: PROJECT_REVIEW_INSTRUCTIONS,
|
20
|
+
commands: {
|
21
|
+
pr: {
|
22
|
+
contentProvider: 'gh',
|
23
|
+
},
|
24
|
+
},
|
25
|
+
};
|
26
|
+
/**
|
27
|
+
* @deprecated
|
28
|
+
* this object has blurred responsibility lines and bad name.
|
29
|
+
* TODO this should be reworked to something more robust
|
30
|
+
*/
|
31
|
+
export const slothContext = {
|
32
|
+
config: DEFAULT_CONFIG,
|
33
|
+
stdin: '',
|
34
|
+
session: { configurable: { thread_id: uuidv4() } },
|
35
|
+
};
|
36
|
+
export async function initConfig() {
|
37
|
+
const currentDir = getCurrentDir();
|
38
|
+
const jsonConfigPath = path.join(currentDir, USER_PROJECT_CONFIG_JSON);
|
39
|
+
const jsConfigPath = path.join(currentDir, USER_PROJECT_CONFIG_JS);
|
40
|
+
const mjsConfigPath = path.join(currentDir, USER_PROJECT_CONFIG_MJS);
|
41
|
+
// Try loading JSON config file first
|
42
|
+
if (existsSync(jsonConfigPath)) {
|
43
|
+
try {
|
44
|
+
const jsonConfig = JSON.parse(readFileSync(jsonConfigPath, 'utf8'));
|
45
|
+
// If the config has an LLM with a type, create the appropriate LLM instance
|
46
|
+
if (jsonConfig.llm && typeof jsonConfig.llm === 'object' && 'type' in jsonConfig.llm) {
|
47
|
+
await tryJsonConfig(jsonConfig);
|
48
|
+
}
|
49
|
+
else {
|
50
|
+
error(`${jsonConfigPath} is not in valid format. Should at least define llm.type`);
|
51
|
+
exit(1);
|
52
|
+
}
|
53
|
+
}
|
54
|
+
catch (e) {
|
55
|
+
displayDebug(e instanceof Error ? e : String(e));
|
56
|
+
displayError(`Failed to read config from ${USER_PROJECT_CONFIG_JSON}, will try other formats.`);
|
57
|
+
// Continue to try other formats
|
58
|
+
return tryJsConfig();
|
59
|
+
}
|
60
|
+
}
|
61
|
+
else {
|
62
|
+
// JSON config not found, try JS
|
63
|
+
return tryJsConfig();
|
64
|
+
}
|
65
|
+
// Helper function to try loading JS config
|
66
|
+
async function tryJsConfig() {
|
67
|
+
if (existsSync(jsConfigPath)) {
|
68
|
+
return importExternalFile(jsConfigPath)
|
69
|
+
.then((i) => i.configure(jsConfigPath))
|
70
|
+
.then((config) => {
|
71
|
+
slothContext.config = { ...slothContext.config, ...config };
|
72
|
+
})
|
73
|
+
.catch((e) => {
|
74
|
+
displayDebug(e instanceof Error ? e : String(e));
|
75
|
+
displayError(`Failed to read config from ${USER_PROJECT_CONFIG_JS}, will try other formats.`);
|
76
|
+
// Continue to try other formats
|
77
|
+
return tryMjsConfig();
|
78
|
+
});
|
79
|
+
}
|
80
|
+
else {
|
81
|
+
// JS config not found, try MJS
|
82
|
+
return tryMjsConfig();
|
83
|
+
}
|
84
|
+
}
|
85
|
+
// Helper function to try loading MJS config
|
86
|
+
async function tryMjsConfig() {
|
87
|
+
if (existsSync(mjsConfigPath)) {
|
88
|
+
return importExternalFile(mjsConfigPath)
|
89
|
+
.then((i) => i.configure(mjsConfigPath))
|
90
|
+
.then((config) => {
|
91
|
+
slothContext.config = { ...slothContext.config, ...config };
|
92
|
+
})
|
93
|
+
.catch((e) => {
|
94
|
+
displayDebug(e instanceof Error ? e : String(e));
|
95
|
+
displayError(`Failed to read config from ${USER_PROJECT_CONFIG_MJS}.`);
|
96
|
+
displayError(`No valid configuration found. Please create a valid configuration file.`);
|
97
|
+
exit();
|
98
|
+
});
|
99
|
+
}
|
100
|
+
else {
|
101
|
+
// No config files found
|
102
|
+
displayError('No configuration file found. Please create one of: ' +
|
103
|
+
`${USER_PROJECT_CONFIG_JSON}, ${USER_PROJECT_CONFIG_JS}, or ${USER_PROJECT_CONFIG_MJS} ` +
|
104
|
+
'in your project directory.');
|
105
|
+
exit();
|
106
|
+
}
|
107
|
+
}
|
108
|
+
}
|
109
|
+
// Process JSON LLM config by creating the appropriate LLM instance
|
110
|
+
export async function tryJsonConfig(jsonConfig) {
|
111
|
+
const llmConfig = jsonConfig?.llm;
|
112
|
+
const llmType = llmConfig?.type?.toLowerCase();
|
113
|
+
// Check if the LLM type is in availableDefaultConfigs
|
114
|
+
if (!llmType || !availableDefaultConfigs.includes(llmType)) {
|
115
|
+
displayError(`Unsupported LLM type: ${llmType}. Available types are: ${availableDefaultConfigs.join(', ')}`);
|
116
|
+
exit(1);
|
117
|
+
return;
|
118
|
+
}
|
119
|
+
try {
|
120
|
+
// Import the appropriate config module based on the LLM type
|
121
|
+
try {
|
122
|
+
const configModule = await import(`./configs/${llmType}.js`);
|
123
|
+
if (configModule.processJsonConfig) {
|
124
|
+
const llm = (await configModule.processJsonConfig(llmConfig));
|
125
|
+
slothContext.config = { ...slothContext.config, ...jsonConfig, llm };
|
126
|
+
}
|
127
|
+
else {
|
128
|
+
displayWarning(`Config module for ${llmType} does not have processJsonConfig function.`);
|
129
|
+
exit(1);
|
130
|
+
}
|
131
|
+
}
|
132
|
+
catch (importError) {
|
133
|
+
displayDebug(importError instanceof Error ? importError : String(importError));
|
134
|
+
displayWarning(`Could not import config module for ${llmType}.`);
|
135
|
+
exit(1);
|
136
|
+
}
|
137
|
+
}
|
138
|
+
catch (error) {
|
139
|
+
displayDebug(error instanceof Error ? error : String(error));
|
140
|
+
displayError(`Error creating LLM instance for type ${llmType}.`);
|
141
|
+
exit(1);
|
142
|
+
}
|
143
|
+
}
|
144
|
+
export async function createProjectConfig(configType) {
|
145
|
+
displayInfo(`Setting up your project\n`);
|
146
|
+
writeProjectReviewPreamble();
|
147
|
+
displayWarning(`Make sure you add as much detail as possible to your ${PROJECT_GUIDELINES}.\n`);
|
148
|
+
// Check if the config type is in availableDefaultConfigs
|
149
|
+
if (!availableDefaultConfigs.includes(configType)) {
|
150
|
+
displayError(`Unsupported config type: ${configType}. Available types are: ${availableDefaultConfigs.join(', ')}`);
|
151
|
+
exit(1);
|
152
|
+
return;
|
153
|
+
}
|
154
|
+
displayInfo(`Creating project config for ${configType}`);
|
155
|
+
const vendorConfig = await import(`./configs/${configType}.js`);
|
156
|
+
vendorConfig.init(USER_PROJECT_CONFIG_JSON, slothContext);
|
157
|
+
}
|
158
|
+
export function writeProjectReviewPreamble() {
|
159
|
+
const currentDir = getCurrentDir();
|
160
|
+
const reviewPreamblePath = path.join(currentDir, PROJECT_GUIDELINES);
|
161
|
+
writeFileIfNotExistsWithMessages(reviewPreamblePath, 'You are doing generic code review.\n' +
|
162
|
+
' Important! Please remind user to prepare proper AI preamble in' +
|
163
|
+
PROJECT_GUIDELINES +
|
164
|
+
' for this project. Use decent amount of ⚠️ to highlight lack of config.' +
|
165
|
+
' Explicitly mention `' +
|
166
|
+
PROJECT_GUIDELINES +
|
167
|
+
'`.');
|
168
|
+
}
|
169
|
+
/**
|
170
|
+
* @deprecated test only
|
171
|
+
* TODO should be gone together with slothContext itself
|
172
|
+
*/
|
173
|
+
export function reset() {
|
174
|
+
Object.keys(slothContext).forEach((key) => {
|
175
|
+
delete slothContext[key];
|
176
|
+
});
|
177
|
+
slothContext.config = DEFAULT_CONFIG;
|
178
|
+
slothContext.session = { configurable: { thread_id: uuidv4() } };
|
179
|
+
}
|
180
|
+
//# sourceMappingURL=config.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,iBAAiB,CAAC;AACnC,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC/F,OAAO,EAAE,kBAAkB,EAAE,gCAAgC,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAkEjE,MAAM,CAAC,MAAM,sBAAsB,GAAG,mBAAmB,CAAC;AAC1D,MAAM,CAAC,MAAM,wBAAwB,GAAG,qBAAqB,CAAC;AAC9D,MAAM,CAAC,MAAM,uBAAuB,GAAG,oBAAoB,CAAC;AAC5D,MAAM,CAAC,MAAM,gBAAgB,GAAG,sBAAsB,CAAC;AACvD,MAAM,CAAC,MAAM,kBAAkB,GAAG,uBAAuB,CAAC;AAC1D,MAAM,CAAC,MAAM,2BAA2B,GAAG,mBAAmB,CAAC;AAE/D,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,UAAU,EAAE,WAAW,EAAE,MAAM,CAAU,CAAC;AAGlF,MAAM,CAAC,MAAM,cAAc,GAAyB;IAClD,GAAG,EAAE,SAAS;IACd,eAAe,EAAE,MAAM;IACvB,oBAAoB,EAAE,MAAM;IAC5B,iBAAiB,EAAE,kBAAkB;IACrC,yBAAyB,EAAE,2BAA2B;IACtD,QAAQ,EAAE;QACR,EAAE,EAAE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,MAAM,CAAC,aAAa,UAAU,KAAK,CAAC,CAAC;IAChE,YAAY,CAAC,IAAI,CAAC,wBAAwB,EAAE,YAAY,CAAC,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,0BAA0B;IACxC,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;IACnC,MAAM,kBAAkB,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAC;IACrE,gCAAgC,CAC9B,kBAAkB,EAClB,sCAAsC;QACpC,iEAAiE;QACjE,kBAAkB;QAClB,yEAAyE;QACzE,uBAAuB;QACvB,kBAAkB;QAClB,IAAI,CACP,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,KAAK;IACnB,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QACxC,OAAQ,YAAmD,CAAC,GAAG,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;IACH,YAAY,CAAC,MAAM,GAAG,cAA6B,CAAC;IACpD,YAAY,CAAC,OAAO,GAAG,EAAE,YAAY,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;AACnE,CAAC"}
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import type { AnthropicInput } from '@langchain/anthropic';
|
2
|
+
import type { BaseChatModel, BaseChatModelParams } from '@langchain/core/language_models/chat_models';
|
3
|
+
export declare function processJsonConfig(llmConfig: AnthropicInput & BaseChatModelParams): Promise<BaseChatModel>;
|
4
|
+
export declare function init(configFileName: string): void;
|
@@ -1,48 +1,45 @@
|
|
1
|
-
import
|
2
|
-
import
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
apiKey: anthropicApiKey,
|
13
|
-
model: llmConfig.model ||
|
14
|
-
});
|
15
|
-
}
|
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
|
-
writeFileIfNotExistsWithMessages(configFileName, content);
|
47
|
-
displayWarning(`You need to update your ${configFileName} to add your Anthropic API key.`);
|
48
|
-
}
|
1
|
+
import path from 'node:path';
|
2
|
+
import { displayWarning } from '#src/consoleUtils.js';
|
3
|
+
import { env, getCurrentDir } from '#src/systemUtils.js';
|
4
|
+
import { writeFileIfNotExistsWithMessages } from '#src/utils.js';
|
5
|
+
// Function to process JSON config and create Anthropic LLM instance
|
6
|
+
export async function processJsonConfig(llmConfig) {
|
7
|
+
const anthropic = await import('@langchain/anthropic');
|
8
|
+
// Use environment variable if available, otherwise use the config value
|
9
|
+
const anthropicApiKey = env.ANTHROPIC_API_KEY || llmConfig.apiKey;
|
10
|
+
return new anthropic.ChatAnthropic({
|
11
|
+
...llmConfig,
|
12
|
+
apiKey: anthropicApiKey,
|
13
|
+
model: llmConfig.model || 'claude-3-7-sonnet-20250219',
|
14
|
+
});
|
15
|
+
}
|
16
|
+
const jsContent = `/* eslint-disable */
|
17
|
+
export async function configure(importFunction, global) {
|
18
|
+
// this is going to be imported from sloth dependencies,
|
19
|
+
// but can potentially be pulled from global node modules or from this project
|
20
|
+
// At a moment only google-vertexai and anthropic packaged with Sloth, but you can install support for any other langchain llms
|
21
|
+
const anthropic = await importFunction('@langchain/anthropic');
|
22
|
+
return {
|
23
|
+
llm: new anthropic.ChatAnthropic({
|
24
|
+
apiKey: process.env.ANTHROPIC_API_KEY, // Default value, but you can provide the key in many different ways, even as literal
|
25
|
+
model: "claude-3-7-sonnet-20250219" // Don't forget to check new models availability.
|
26
|
+
})
|
27
|
+
};
|
28
|
+
}
|
29
|
+
`;
|
30
|
+
const jsonContent = `{
|
31
|
+
"llm": {
|
32
|
+
"type": "anthropic",
|
33
|
+
"apiKey": "your-api-key-here",
|
34
|
+
"model": "claude-3-7-sonnet-20250219"
|
35
|
+
}
|
36
|
+
}`;
|
37
|
+
export function init(configFileName) {
|
38
|
+
const currentDir = getCurrentDir();
|
39
|
+
path.join(currentDir, configFileName);
|
40
|
+
// Determine which content to use based on file extension
|
41
|
+
const content = configFileName.endsWith('.json') ? jsonContent : jsContent;
|
42
|
+
writeFileIfNotExistsWithMessages(configFileName, content);
|
43
|
+
displayWarning(`You need to update your ${configFileName} to add your Anthropic API key.`);
|
44
|
+
}
|
45
|
+
//# sourceMappingURL=anthropic.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../src/configs/anthropic.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,gCAAgC,EAAE,MAAM,eAAe,CAAC;AAOjE,oEAAoE;AACpE,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,SAA+C;IAE/C,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,sBAAsB,CAAC,CAAC;IACvD,wEAAwE;IACxE,MAAM,eAAe,GAAG,GAAG,CAAC,iBAAiB,IAAI,SAAS,CAAC,MAAM,CAAC;IAClE,OAAO,IAAI,SAAS,CAAC,aAAa,CAAC;QACjC,GAAG,SAAS;QACZ,MAAM,EAAE,eAAe;QACvB,KAAK,EAAE,SAAS,CAAC,KAAK,IAAI,4BAA4B;KACvD,CAAC,CAAC;AACL,CAAC;AAED,MAAM,SAAS,GAAG;;;;;;;;;;;;;CAajB,CAAC;AAEF,MAAM,WAAW,GAAG;;;;;;EAMlB,CAAC;AAEH,MAAM,UAAU,IAAI,CAAC,cAAsB;IACzC,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;IACnC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IAEtC,yDAAyD;IACzD,MAAM,OAAO,GAAG,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;IAE3E,gCAAgC,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAC1D,cAAc,CAAC,2BAA2B,cAAc,iCAAiC,CAAC,CAAC;AAC7F,CAAC"}
|
@@ -1,15 +1,12 @@
|
|
1
|
-
import {displayWarning} from
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
displayWarning("Fake LLM requires 'responses' array in config");
|
12
|
-
return null;
|
13
|
-
}
|
14
|
-
|
1
|
+
import { displayWarning } from '#src/consoleUtils.js';
|
2
|
+
// Function to process JSON config and create Fake LLM instance for testing
|
3
|
+
export async function processJsonConfig(llmConfig) {
|
4
|
+
if (llmConfig.responses) {
|
5
|
+
const test = await import('@langchain/core/utils/testing');
|
6
|
+
return new test.FakeListChatModel(llmConfig);
|
7
|
+
}
|
8
|
+
displayWarning("Fake LLM requires 'responses' array in config");
|
9
|
+
return null;
|
10
|
+
}
|
15
11
|
// No init function needed for fake LLM as it's only used for testing
|
12
|
+
//# sourceMappingURL=fake.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"fake.js","sourceRoot":"","sources":["../../src/configs/fake.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,2EAA2E;AAC3E,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,SAAwB;IAC9D,IAAI,SAAS,CAAC,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,+BAA+B,CAAC,CAAC;QAC3D,OAAO,IAAI,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAC/C,CAAC;IACD,cAAc,CAAC,+CAA+C,CAAC,CAAC;IAChE,OAAO,IAAI,CAAC;AACd,CAAC;AAED,qEAAqE"}
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
2
|
+
import { ChatGroqInput } from '@langchain/groq';
|
3
|
+
export declare function processJsonConfig(llmConfig: ChatGroqInput): Promise<BaseChatModel>;
|
4
|
+
export declare function init(configFileName: string): void;
|
@@ -1,19 +1,18 @@
|
|
1
|
-
import
|
2
|
-
import
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
|
1
|
+
import path from 'node:path';
|
2
|
+
import { displayInfo, displayWarning } from '#src/consoleUtils.js';
|
3
|
+
import { env, getCurrentDir } from '#src/systemUtils.js';
|
4
|
+
import { writeFileIfNotExistsWithMessages } from '#src/utils.js';
|
6
5
|
// Function to process JSON config and create Groq LLM instance
|
7
6
|
export async function processJsonConfig(llmConfig) {
|
8
7
|
const groq = await import('@langchain/groq');
|
9
8
|
// Use environment variable if available, otherwise use the config value
|
10
9
|
const groqApiKey = env.GROQ_API_KEY || llmConfig.apiKey;
|
11
10
|
return new groq.ChatGroq({
|
11
|
+
...llmConfig,
|
12
12
|
apiKey: groqApiKey,
|
13
|
-
model: llmConfig.model ||
|
13
|
+
model: llmConfig.model || 'deepseek-r1-distill-llama-70b',
|
14
14
|
});
|
15
15
|
}
|
16
|
-
|
17
16
|
const jsContent = `/* eslint-disable */
|
18
17
|
export async function configure(importFunction, global) {
|
19
18
|
// this is going to be imported from sloth dependencies,
|
@@ -27,7 +26,6 @@ export async function configure(importFunction, global) {
|
|
27
26
|
};
|
28
27
|
}
|
29
28
|
`;
|
30
|
-
|
31
29
|
const jsonContent = `{
|
32
30
|
"llm": {
|
33
31
|
"type": "groq",
|
@@ -35,14 +33,13 @@ const jsonContent = `{
|
|
35
33
|
"apiKey": "your-api-key-here"
|
36
34
|
}
|
37
35
|
}`;
|
38
|
-
|
39
|
-
|
40
|
-
path.join(
|
41
|
-
|
36
|
+
export function init(configFileName) {
|
37
|
+
const currentDir = getCurrentDir();
|
38
|
+
path.join(currentDir, configFileName);
|
42
39
|
// Determine which content to use based on file extension
|
43
40
|
const content = configFileName.endsWith('.json') ? jsonContent : jsContent;
|
44
|
-
|
45
41
|
writeFileIfNotExistsWithMessages(configFileName, content);
|
46
42
|
displayInfo(`You can define GROQ_API_KEY environment variable with your Groq API key and it will work with default model.`);
|
47
43
|
displayWarning(`You need to edit your ${configFileName} to configure model.`);
|
48
44
|
}
|
45
|
+
//# sourceMappingURL=groq.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"groq.js","sourceRoot":"","sources":["../../src/configs/groq.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,gCAAgC,EAAE,MAAM,eAAe,CAAC;AAIjE,+DAA+D;AAC/D,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,SAAwB;IAC9D,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC,CAAC;IAC7C,wEAAwE;IACxE,MAAM,UAAU,GAAG,GAAG,CAAC,YAAY,IAAI,SAAS,CAAC,MAAM,CAAC;IACxD,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC;QACvB,GAAG,SAAS;QACZ,MAAM,EAAE,UAAU;QAClB,KAAK,EAAE,SAAS,CAAC,KAAK,IAAI,+BAA+B;KAC1D,CAAC,CAAC;AACL,CAAC;AAED,MAAM,SAAS,GAAG;;;;;;;;;;;;CAYjB,CAAC;AAEF,MAAM,WAAW,GAAG;;;;;;EAMlB,CAAC;AAEH,MAAM,UAAU,IAAI,CAAC,cAAsB;IACzC,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;IACnC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IAEtC,yDAAyD;IACzD,MAAM,OAAO,GAAG,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;IAE3E,gCAAgC,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAC1D,WAAW,CACT,8GAA8G,CAC/G,CAAC;IACF,cAAc,CAAC,yBAAyB,cAAc,sBAAsB,CAAC,CAAC;AAChF,CAAC"}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import type { SlothContext } from '#src/config.js';
|
2
|
+
import { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
3
|
+
export interface LLMConfig {
|
4
|
+
type: string;
|
5
|
+
model?: string;
|
6
|
+
apiKey?: string;
|
7
|
+
temperature?: number;
|
8
|
+
responses?: string[];
|
9
|
+
[key: string]: unknown;
|
10
|
+
}
|
11
|
+
export interface ConfigModule {
|
12
|
+
init: (configFileName: string, context: SlothContext) => void;
|
13
|
+
processJsonConfig: (llmConfig: LLMConfig) => Promise<BaseChatModel | null>;
|
14
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/configs/types.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { ChatVertexAIInput } from '@langchain/google-vertexai';
|
2
|
+
import type { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
3
|
+
export declare function init(configFileName: string): void;
|
4
|
+
export declare function processJsonConfig(llmConfig: ChatVertexAIInput): Promise<BaseChatModel>;
|
@@ -1,47 +1,44 @@
|
|
1
|
-
import
|
2
|
-
import
|
3
|
-
import {
|
4
|
-
|
5
|
-
const jsContent = `/* eslint-disable */
|
6
|
-
export async function configure(importFunction, global) {
|
7
|
-
// this is going to be imported from sloth dependencies,
|
8
|
-
// but can potentially be pulled from global node modules or from this project
|
9
|
-
const vertexAi = await importFunction('@langchain/google-vertexai');
|
10
|
-
return {
|
11
|
-
llm: new vertexAi.ChatVertexAI({
|
12
|
-
model: "gemini-2.5-pro-
|
13
|
-
// temperature: 0,
|
14
|
-
// Other parameters might be relevant depending on Vertex AI API updates
|
15
|
-
// The project is not in the interface, but it is in documentation
|
16
|
-
// project: 'your-cool-gcloud-project'
|
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
|
-
model: llmConfig.model || "gemini-pro"
|
46
|
-
});
|
47
|
-
}
|
1
|
+
import path from 'node:path';
|
2
|
+
import { displayWarning } from '#src/consoleUtils.js';
|
3
|
+
import { getCurrentDir } from '#src/systemUtils.js';
|
4
|
+
import { writeFileIfNotExistsWithMessages } from '#src/utils.js';
|
5
|
+
const jsContent = `/* eslint-disable */
|
6
|
+
export async function configure(importFunction, global) {
|
7
|
+
// this is going to be imported from sloth dependencies,
|
8
|
+
// but can potentially be pulled from global node modules or from this project
|
9
|
+
const vertexAi = await importFunction('@langchain/google-vertexai');
|
10
|
+
return {
|
11
|
+
llm: new vertexAi.ChatVertexAI({
|
12
|
+
model: "gemini-2.5-pro-preview-05-06", // Consider checking for latest recommended model versions
|
13
|
+
// temperature: 0,
|
14
|
+
// Other parameters might be relevant depending on Vertex AI API updates
|
15
|
+
// The project is not in the interface, but it is in documentation
|
16
|
+
// project: 'your-cool-gcloud-project'
|
17
|
+
})
|
18
|
+
}
|
19
|
+
}
|
20
|
+
`;
|
21
|
+
const jsonContent = `{
|
22
|
+
"llm": {
|
23
|
+
"type": "vertexai",
|
24
|
+
"model": "gemini-2.5-pro-preview-05-06",
|
25
|
+
"temperature": 0
|
26
|
+
}
|
27
|
+
}`;
|
28
|
+
export function init(configFileName) {
|
29
|
+
const currentDir = getCurrentDir();
|
30
|
+
path.join(currentDir, configFileName);
|
31
|
+
// Determine which content to use based on file extension
|
32
|
+
const content = configFileName.endsWith('.json') ? jsonContent : jsContent;
|
33
|
+
writeFileIfNotExistsWithMessages(configFileName, content);
|
34
|
+
displayWarning('For Google VertexAI you likely to need to do `gcloud auth login` and `gcloud auth application-default login`.');
|
35
|
+
}
|
36
|
+
// Function to process JSON config and create VertexAI LLM instance
|
37
|
+
export async function processJsonConfig(llmConfig) {
|
38
|
+
const vertexAi = await import('@langchain/google-vertexai');
|
39
|
+
return new vertexAi.ChatVertexAI({
|
40
|
+
...llmConfig,
|
41
|
+
model: llmConfig.model || 'gemini-2.5-pro-preview-05-06',
|
42
|
+
});
|
43
|
+
}
|
44
|
+
//# sourceMappingURL=vertexai.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"vertexai.js","sourceRoot":"","sources":["../../src/configs/vertexai.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,gCAAgC,EAAE,MAAM,eAAe,CAAC;AAIjE,MAAM,SAAS,GAAG;;;;;;;;;;;;;;;CAejB,CAAC;AAEF,MAAM,WAAW,GAAG;;;;;;EAMlB,CAAC;AAEH,MAAM,UAAU,IAAI,CAAC,cAAsB;IACzC,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;IACnC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IAEtC,yDAAyD;IACzD,MAAM,OAAO,GAAG,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;IAE3E,gCAAgC,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAC1D,cAAc,CACZ,+GAA+G,CAChH,CAAC;AACJ,CAAC;AAED,mEAAmE;AACnE,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,SAA4B;IAClE,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,4BAA4B,CAAC,CAAC;IAC5D,OAAO,IAAI,QAAQ,CAAC,YAAY,CAAC;QAC/B,GAAG,SAAS;QACZ,KAAK,EAAE,SAAS,CAAC,KAAK,IAAI,8BAA8B;KACzD,CAAC,CAAC;AACL,CAAC"}
|
@@ -0,0 +1,6 @@
|
|
1
|
+
export declare function displayError(message: string): void;
|
2
|
+
export declare function displayWarning(message: string): void;
|
3
|
+
export declare function displaySuccess(message: string): void;
|
4
|
+
export declare function displayInfo(message: string): void;
|
5
|
+
export declare function display(message: string): void;
|
6
|
+
export declare function displayDebug(message: string | Error | undefined): void;
|