Changesets · Branches · Tags · Compare
| Changeset | 0bc8a18563fc1dd61b7d50e0e4f02af68b7947b86a1e71a378bea9b45e6f2837 |
|---|---|
| Author | uinstinct <61635505+uinstinct@users.noreply.github.com> · 2025-05-23 11:40 +05:30 |
| Committer | uinstinct <61635505+uinstinct@users.noreply.github.com> · 2025-05-23 11:40 +05:30 |
| Parents | ed46f5b1432f |
1 file changed
modified core/data/log.test.ts +27 −0
| @@ -18,6 +18,18 @@ | ||
| 18 | 18 | provider: "openai", |
| 19 | 19 | }, |
| 20 | 20 | }; |
| 21 | + | |
| 22 | +const TEST_AGENT_INTERACTION_EVENT: DevDataLogEvent = { | |
| 23 | + name: 'agentInteraction', | |
| 24 | + data: { | |
| 25 | + prompt: "Hello, world!", | |
| 26 | + completion: "Hello, world!", | |
| 27 | + modelProvider: "openai", | |
| 28 | + modelTitle: "gpt-4", | |
| 29 | + sessionId: "1234", | |
| 30 | + }, | |
| 31 | +} | |
| 32 | + | |
| 21 | 33 | const SCHEMA = "0.2.0"; |
| 22 | 34 | |
| 23 | 35 | describe("DataLogger", () => { |
| @@ -157,6 +169,21 @@ | ||
| 157 | 169 | expect(fileContent).toContain('"model":"gpt-4"'); |
| 158 | 170 | expect(fileContent).toContain('"eventName":"tokensGenerated"'); |
| 159 | 171 | }); |
| 172 | + | |
| 173 | + it('should write agent interaction data to local file', async () => { | |
| 174 | + // Call the method to log data locally | |
| 175 | + await dataLogger.logLocalData(TEST_AGENT_INTERACTION_EVENT); | |
| 176 | + | |
| 177 | + // Verify the file was created | |
| 178 | + const filepath = getDevDataFilePath(TEST_AGENT_INTERACTION_EVENT.name, SCHEMA); | |
| 179 | + expect(fs.existsSync(filepath)).toBe(true); | |
| 180 | + | |
| 181 | + // Read file contents and verify | |
| 182 | + const fileContent = fs.readFileSync(filepath, "utf8"); | |
| 183 | + expect(fileContent).toContain('"eventName":"agentInteraction"'); | |
| 184 | + expect(fileContent).toContain('"prompt":"Hello, world!"'); | |
| 185 | + expect(fileContent).toContain('"completion":"Hello, world!"'); | |
| 186 | + }) | |
| 160 | 187 | }); |
| 161 | 188 | |
| 162 | 189 | describe("logDevData", () => { |