export JIGSAWSTACK_API_KEY="your-api-key"
npm install @langchain/jigsawstack
yarn add @langchain/jigsawstack
pnpm add @langchain/jigsawstack
import { JigsawStackPromptEngine } from "@langchain/jigsawstack";
export const run = async () => {
const model = new JigsawStackPromptEngine();
const res = await model.invoke("Tell me about the leaning tower of pisa?\nAnswer:");
console.log({ res });
};
import {
JigsawStackAIScrape,
JigsawStackAISearch,
JigsawStackSpeechToText,
JigsawStackVOCR,
JigsawStackTextToSQL,
} from "@langchain/jigsawstack";
const aiScrapeTool = new JigsawStackAIScrape({
params: {
element_prompts: ["Pro plan"]
}
});
const scrapeResult = await aiScrapeTool.invoke("https://jigsawstack.com/pricing");
console.log({ scrapeResult });
const aiSearchTool = new JigsawStackAISearch();
const searchResult = await aiSearchTool.invoke("The leaning tower of Pisa");
console.log({ searchResult });
const vocrTool = new JigsawStackVOCR({
params: {
prompt: "Describe the image in detail"
}
});
const vocrResult = await vocrTool.invoke("https://link-to-image.jpg");
console.log({ vocrResult });
const sttTool = new JigsawStackSpeechToText();
await sttTool.invoke("https://link-to-video.mp4");
const sqlTool = new JigsawStackTextToSQL({
params: {
sql_schema: "CREATE TABLE Transactions (transaction_id INT PRIMARY KEY, user_id INT NOT NULL, ... )",
},
});
const sqlResult = await sqlTool.invoke("Generate a query to get transactions exceeding $10,000.");
console.log({ sqlResult });
import { ChatOpenAI } from "@langchain/openai";
import { initializeAgentExecutorWithOptions } from "langchain/agents";
import {
JigsawStackAIScrape,
JigsawStackAISearch,
JigsawStackVOCR,
JigsawStackSpeechToText,
JigsawStackTextToSQL,
} from "@langchain/jigsawstack";
const model = new ChatOpenAI({ temperature: 0 });
const tools = [
new JigsawStackAIScrape(),
new JigsawStackAISearch(),
new JigsawStackVOCR(),
new JigsawStackSpeechToText(),
new JigsawStackTextToSQL(),
];
const executor = await initializeAgentExecutorWithOptions(tools, model, {
agentType: "zero-shot-react-description",
verbose: true
});
const res = await executor.invoke({
input: "Kokkalo Restaurant Santorini"
});
console.log(res.output);