Merge pull request #5812 from uinstinct/agent-dev-data
feat: add `tools` in chatInteraction dev data
This commit is contained in:
commit
3d18bf7f49
4 changed files with 35 additions and 0 deletions
|
|
@ -18,6 +18,19 @@ const TEST_EVENT: DevDataLogEvent = {
|
|||
provider: "openai",
|
||||
},
|
||||
};
|
||||
|
||||
const TEST_AGENT_INTERACTION_EVENT: DevDataLogEvent = {
|
||||
name: 'chatInteraction',
|
||||
data: {
|
||||
prompt: "Hello, world!",
|
||||
completion: "Hello, world!",
|
||||
modelProvider: "openai",
|
||||
modelTitle: "gpt-4",
|
||||
sessionId: "1234",
|
||||
tools: ['test-tool1']
|
||||
},
|
||||
}
|
||||
|
||||
const SCHEMA = "0.2.0";
|
||||
|
||||
describe("DataLogger", () => {
|
||||
|
|
@ -157,6 +170,23 @@ describe("DataLogger", () => {
|
|||
expect(fileContent).toContain('"model":"gpt-4"');
|
||||
expect(fileContent).toContain('"eventName":"tokensGenerated"');
|
||||
});
|
||||
|
||||
it('should write agent interaction data to local file', async () => {
|
||||
// Call the method to log data locally
|
||||
await dataLogger.logLocalData(TEST_AGENT_INTERACTION_EVENT);
|
||||
|
||||
// Verify the file was created
|
||||
const filepath = getDevDataFilePath(TEST_AGENT_INTERACTION_EVENT.name, SCHEMA);
|
||||
expect(fs.existsSync(filepath)).toBe(true);
|
||||
|
||||
// Read file contents and verify
|
||||
const fileContent = fs.readFileSync(filepath, "utf8");
|
||||
console.log('debug1 filecontent', fileContent)
|
||||
expect(fileContent).toContain('"eventName":"chatInteraction"');
|
||||
expect(fileContent).toContain('"prompt":"Hello, world!"');
|
||||
expect(fileContent).toContain('"completion":"Hello, world!"');
|
||||
expect(fileContent).toContain('"tools":["test-tool1"]');
|
||||
})
|
||||
});
|
||||
|
||||
describe("logDevData", () => {
|
||||
|
|
|
|||
|
|
@ -82,6 +82,9 @@ export const streamNormalInput = createAsyncThunk<
|
|||
modelProvider: selectedChatModel.underlyingProviderName,
|
||||
modelTitle: selectedChatModel.title,
|
||||
sessionId: state.session.id,
|
||||
...(state.session.mode === 'agent' && {
|
||||
tools: activeTools.map((tool) => tool.function.name),
|
||||
}),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,4 +7,5 @@ export const chatInteractionEventAllSchema = baseDevDataAllSchema.extend({
|
|||
prompt: z.string(),
|
||||
completion: z.string(),
|
||||
sessionId: z.string(),
|
||||
tools: z.array(z.string()).optional()
|
||||
});
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ export const chatInteractionEventSchema_0_2_0 =
|
|||
modelTitle: true,
|
||||
modelProvider: true,
|
||||
sessionId: true,
|
||||
tools: true
|
||||
});
|
||||
|
||||
export const chatInteractionEventSchema_0_2_0_noCode =
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue