Skip to content

Commit

Permalink
Merge pull request #19 from langchain-ai/brace/better-img-support
Browse files Browse the repository at this point in the history
cr
  • Loading branch information
bracesproul authored Dec 19, 2024
2 parents a883d12 + 0046eef commit d1e941b
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 22 deletions.
22 changes: 17 additions & 5 deletions scripts/start-cron.ts → scripts/crons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
// }
// },
Expand All @@ -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();
Expand All @@ -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);
Expand Down
24 changes: 24 additions & 0 deletions scripts/invoke-graph.ts
Original file line number Diff line number Diff line change
@@ -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);
25 changes: 8 additions & 17 deletions src/agents/upload-post/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<CreateMediaRequest | undefined> {
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<string>,
image: Annotation<
| {
buffer?: Buffer;
imageUrl?: string;
imageUrl: string;
mimeType: string;
}
| undefined
Expand Down

0 comments on commit d1e941b

Please sign in to comment.