add example
This commit is contained in:
+36
@@ -0,0 +1,36 @@
|
||||
// example.js
|
||||
const LMStudioFileAgent = require('./agent');
|
||||
|
||||
async function example() {
|
||||
const agent = new LMStudioFileAgent({
|
||||
workspaceDir: './my_project'
|
||||
});
|
||||
|
||||
// Read a file
|
||||
const content = await agent.readFile('example.js');
|
||||
console.log('File content:', content);
|
||||
|
||||
// Create a new file
|
||||
console.log(await agent.createFile('new_script.js', 'console.log("Hello World");', 'javascript'));
|
||||
|
||||
// List directory
|
||||
const items = await agent.listDirectory();
|
||||
console.log('Directory:', items);
|
||||
|
||||
// Search for files
|
||||
const files = await agent.searchFiles('*.js');
|
||||
console.log('JS files:', files);
|
||||
|
||||
// Edit a file
|
||||
console.log(await agent.editFile('new_script.js', 'Hello World', 'Hello Agent'));
|
||||
|
||||
// Search content
|
||||
const results = await agent.searchContent('console.log', '.');
|
||||
console.log('Search results:', results);
|
||||
|
||||
// Process natural language request
|
||||
const response = await agent.processRequest('Create a new JavaScript file called test.js with a main function');
|
||||
console.log('Agent response:', response);
|
||||
}
|
||||
|
||||
example().catch(console.error);
|
||||
Reference in New Issue
Block a user