evals 1.0.5 → 1.0.7
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 +4 -57
- package/dist/index.js +4 -2
- package/package.json +1 -1
- package/src/index.js +4 -2
package/README.md
CHANGED
|
@@ -39,12 +39,12 @@ To save the file, press `Ctrl + X`, then `Y`, then `Enter`. Then, run `source ~/
|
|
|
39
39
|
## Example usage
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
|
-
|
|
42
|
+
npx evals@latest fetch-evals
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
npx evals@latest run-evals
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
## Example BaseModel
|
|
47
|
+
## Example Prompt BaseModel
|
|
48
48
|
|
|
49
49
|
```typescript
|
|
50
50
|
export interface ModelSettings {
|
|
@@ -84,66 +84,13 @@ class BaseModel {
|
|
|
84
84
|
* @returns Promise<{ response: string, prompts: Prompt[] }>
|
|
85
85
|
*/
|
|
86
86
|
async callModel(userMessage: string = ''): Promise<{ response: string; prompts: Prompt[] }> {
|
|
87
|
-
throw new Error('callModel method needs to be implemented
|
|
87
|
+
throw new Error('callModel method needs to be implemented');
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
export default BaseModel;
|
|
92
92
|
```
|
|
93
93
|
|
|
94
|
-
## Example Prompt (OpenAI API)
|
|
95
|
-
|
|
96
|
-
```typescript
|
|
97
|
-
import BaseModel from './BaseModel';
|
|
98
|
-
import OpenAI from 'openai';
|
|
99
|
-
|
|
100
|
-
class ChevySalesCopilotPrompt extends BaseModel {
|
|
101
|
-
constructor() {
|
|
102
|
-
const config = {
|
|
103
|
-
promptName: 'Chevy Sales Copilot',
|
|
104
|
-
modelName: 'gpt-4',
|
|
105
|
-
modelSettings: { temperature: 0.2 },
|
|
106
|
-
environment: 'development'
|
|
107
|
-
};
|
|
108
|
-
super(config);
|
|
109
|
-
|
|
110
|
-
this.openai = new OpenAI(); // Assumes OPENAI_API_KEY is set in environment
|
|
111
|
-
this.messages = [
|
|
112
|
-
{ role: 'system', content: 'You are a Chevy Sales Copilot assistant. You can only help with topics related to sales at Chevrolet. If asked your name your name is "Sales Copilot".' }
|
|
113
|
-
];
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
async callModel(userMessage) {
|
|
117
|
-
try {
|
|
118
|
-
// Update messages with user input
|
|
119
|
-
const updatedMessages = [...this.messages, { role: 'user', content: userMessage }];
|
|
120
|
-
|
|
121
|
-
const modelResponse = await this.openai.chat.completions.create({
|
|
122
|
-
model: this.modelName,
|
|
123
|
-
messages: updatedMessages,
|
|
124
|
-
temperature: this.modelSettings.temperature,
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
const response = modelResponse.choices[0].message.content;
|
|
128
|
-
|
|
129
|
-
const prompts = updatedMessages.map(message => ({
|
|
130
|
-
prompt_type: message.role,
|
|
131
|
-
prompt_text: message.content,
|
|
132
|
-
}));
|
|
133
|
-
|
|
134
|
-
return { response, prompts };
|
|
135
|
-
} catch (error) {
|
|
136
|
-
console.error('Error:', error);
|
|
137
|
-
throw error;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const prompt = new ChevySalesCopilotPrompt();
|
|
143
|
-
|
|
144
|
-
export default prompt;
|
|
145
|
-
|
|
146
|
-
```
|
|
147
94
|
|
|
148
95
|
## LICENSE
|
|
149
96
|
|
package/dist/index.js
CHANGED
|
@@ -15266,7 +15266,8 @@ program.command("fetch-evals").description("Fetch the latest evals for the proje
|
|
|
15266
15266
|
}
|
|
15267
15267
|
};
|
|
15268
15268
|
try {
|
|
15269
|
-
const
|
|
15269
|
+
const currentWorkingDir = process.cwd();
|
|
15270
|
+
const promptsDir = `${currentWorkingDir}/prompts/`;
|
|
15270
15271
|
const promptFiles = fs2.readdirSync(promptsDir).filter((file) => file.endsWith(".prompt.js"));
|
|
15271
15272
|
const processingPromises = promptFiles.map(processPromptFile);
|
|
15272
15273
|
await Promise.all(processingPromises);
|
|
@@ -15280,7 +15281,8 @@ program.command("run-evals").description("Run evals in the current directory and
|
|
|
15280
15281
|
throw new Error("OPENAI_API_KEY is not set in the environment variables.");
|
|
15281
15282
|
}
|
|
15282
15283
|
const openai = new openai_default;
|
|
15283
|
-
const
|
|
15284
|
+
const currentWorkingDir = process.cwd();
|
|
15285
|
+
const promptsDir = `${currentWorkingDir}/prompts/`;
|
|
15284
15286
|
const model = "gpt-4-1106-preview";
|
|
15285
15287
|
const temperature = 0;
|
|
15286
15288
|
const processMarkdownFile = async (evalsFolder, evalFile, promptInstance) => {
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -59,7 +59,8 @@ program
|
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
try {
|
|
62
|
-
const
|
|
62
|
+
const currentWorkingDir = process.cwd(); // Get the current working directory
|
|
63
|
+
const promptsDir = `${currentWorkingDir}/prompts/`; // Use it as the base for your prompts directory
|
|
63
64
|
const promptFiles = fs.readdirSync(promptsDir).filter(file => file.endsWith('.prompt.js'));
|
|
64
65
|
|
|
65
66
|
const processingPromises = promptFiles.map(processPromptFile);
|
|
@@ -80,7 +81,8 @@ program
|
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
const openai = new OpenAI(); // Assumes OPENAI_API_KEY is set in environment
|
|
83
|
-
const
|
|
84
|
+
const currentWorkingDir = process.cwd(); // Get the current working directory
|
|
85
|
+
const promptsDir = `${currentWorkingDir}/prompts/`; // Use it as the base for your prompts directory
|
|
84
86
|
const model = 'gpt-4-1106-preview';
|
|
85
87
|
const temperature = 0;
|
|
86
88
|
|