diff --git a/scripts/start-cron.ts b/scripts/crons.ts similarity index 72% rename from scripts/start-cron.ts rename to scripts/crons.ts index 0703ed2..93739e1 100644 --- a/scripts/start-cron.ts +++ b/scripts/crons.ts @@ -3,14 +3,14 @@ // async function main() { // const client = new Client({ -// apiUrl: "ADD_URL_HERE", +// apiUrl: process.env.LANGGRAPH_API_URL, // }); // const res = await client.crons.create("ingest_data", { // schedule: "0 0 * * *", // config: { // configurable: { -// slackChannelId: "", +// slackChannelId: "C06BU7XF5S7", // maxDaysHistory: 1, // } // }, @@ -28,7 +28,7 @@ // async function backfill() { // const client = new Client({ -// apiUrl: "ADD_URL_HERE", +// apiUrl: process.env.LANGGRAPH_API_URL, // }); // const thread = await client.threads.create(); @@ -47,11 +47,23 @@ // backfill().catch(console.error); +// async function listCrons() { +// const client = new Client({ +// apiUrl: process.env.LANGGRAPH_API_URL, +// }); + +// const crons = await client.crons.search(); +// console.log("Crons"); +// console.log(crons) +// } + +// listCrons().catch(console.error); + // async function deleteCron() { -// const cronId = "" +// const cronId = "1efb9c04-6dec-6ab7-842e-a4cdf7eddf44" // const client = new Client({ -// apiUrl: "ADD_URL_HERE", +// apiUrl: process.env.LANGGRAPH_API_URL, // }); // await client.crons.delete(cronId); diff --git a/scripts/invoke-graph.ts b/scripts/invoke-graph.ts new file mode 100644 index 0000000..d3ea555 --- /dev/null +++ b/scripts/invoke-graph.ts @@ -0,0 +1,24 @@ +import "dotenv/config"; +import { Client } from "@langchain/langgraph-sdk"; + +async function invokeGraph() { + const repoUrl = ""; + + const client = new Client({ + apiUrl: process.env.LANGGRAPH_API_URL, + }); + + const { thread_id } = await client.threads.create(); + await client.runs.create(thread_id, "generate_post", { + input: { + links: [repoUrl], + }, + config: { + configurable: { + twitterUserId: process.env.TWITTER_USER_ID, + }, + }, + }); +} + +invokeGraph().catch(console.error); diff --git a/src/agents/upload-post/index.ts b/src/agents/upload-post/index.ts index 086d51b..fb87160 100644 --- a/src/agents/upload-post/index.ts +++ b/src/agents/upload-post/index.ts @@ -10,31 +10,22 @@ import { imageUrlToBuffer } from "../utils.js"; import { CreateMediaRequest } from "../../clients/twitter/types.js"; async function getMediaFromImage(image?: { - buffer?: Buffer; - imageUrl?: string; + imageUrl: string; mimeType: string; }): Promise { - if (image?.buffer) { - return { - media: image.buffer, - mimeType: image.mimeType, - }; - } else if (image?.imageUrl) { - const { buffer, contentType } = await imageUrlToBuffer(image.imageUrl); - return { - media: buffer, - mimeType: contentType, - }; - } - return undefined; + if (!image) return undefined; + const { buffer, contentType } = await imageUrlToBuffer(image.imageUrl); + return { + media: buffer, + mimeType: contentType, + }; } const UploadPostAnnotation = Annotation.Root({ post: Annotation, image: Annotation< | { - buffer?: Buffer; - imageUrl?: string; + imageUrl: string; mimeType: string; } | undefined