Skip to content

Latest commit

 

History

History
22 lines (17 loc) · 881 Bytes

File metadata and controls

22 lines (17 loc) · 881 Bytes

LangChain Integration

import { SecureShell, OpenAIProvider, createSecureShellTool } from 'secureshell-ts';
import { ChatOpenAI } from '@langchain/openai';
import { AgentExecutor, createToolCallingAgent } from 'langchain/agents';

const shell = new SecureShell({
    provider: new OpenAIProvider({ apiKey: process.env.OPENAI_API_KEY }),
    template: 'development'
});

const tool = createSecureShellTool(shell);
const model = new ChatOpenAI({ modelName: 'gpt-4.1-mini' });
const agent = await createToolCallingAgent({ llm: model, tools: [tool], prompt });
const executor = new AgentExecutor({ agent, tools: [tool] });

await executor.invoke({ input: 'List the files in the current directory' });
await shell.close();

Examples: TypeScript | Python