From d92d97b7ebd62f9953d97e0ae5f2ffe701ff7f15 Mon Sep 17 00:00:00 2001 From: Christopher Gerber Date: Thu, 5 Dec 2024 15:46:47 -0800 Subject: [PATCH] refinements for twitter langchain --- twitter-langchain/src/actions/account_details.ts | 7 +++++-- twitter-langchain/src/tests/user_mentions_test.ts | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/twitter-langchain/src/actions/account_details.ts b/twitter-langchain/src/actions/account_details.ts index 880da98..54b5aa9 100644 --- a/twitter-langchain/src/actions/account_details.ts +++ b/twitter-langchain/src/actions/account_details.ts @@ -24,7 +24,10 @@ A failure response will return a message with a Twitter API request error: /** * Input argument schema for the account details action. */ -export const AccountDetailsInput = z.object({}).strip().describe("Input schema for retrieving account details"); +export const AccountDetailsInput = z + .object({}) + .strip() + .describe("Input schema for retrieving account details"); /** * Get the authenticated Twitter (X) user account details. @@ -47,7 +50,7 @@ export async function accountDetails( } /** - * AccountDetailsAction + * Account Details Action */ export class AccountDetailsAction implements TwitterAction { public name = "account_details"; diff --git a/twitter-langchain/src/tests/user_mentions_test.ts b/twitter-langchain/src/tests/user_mentions_test.ts index de33433..1c37c95 100644 --- a/twitter-langchain/src/tests/user_mentions_test.ts +++ b/twitter-langchain/src/tests/user_mentions_test.ts @@ -1,7 +1,7 @@ import { userMentions, UserMentionsInput } from "../actions/user_mentions"; import { TwitterApi, TwitterApiv2 } from "twitter-api-v2"; -const MOCK_USER_ID = "1857479287504584856" +const MOCK_USER_ID = "1857479287504584856"; describe("User Mentions Input", () => { it("should successfully parse valid input", () => { @@ -55,10 +55,10 @@ describe("User Mentions Action", () => { }); it("should successfully retrieve user mentions", async () => { - const args = { userId: "1857479287504584856" }; + const args = { userId: MOCK_USER_ID }; const response = await userMentions(mockApi, args); - expect(mockClient.userMentionTimeline).toHaveBeenCalledWith(MOCK_USER_ID); + expect(mockApi.v2.userMentionTimeline).toHaveBeenCalledWith(MOCK_USER_ID); expect(response).toContain("Successfully retrieved user mentions:"); expect(response).toContain(JSON.stringify(mockApiResponse)); });