Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Twitter Search Client Broken #943

Closed
owenwahlgren opened this issue Dec 9, 2024 · 7 comments
Closed

Twitter Search Client Broken #943

owenwahlgren opened this issue Dec 9, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@owenwahlgren
Copy link

owenwahlgren commented Dec 9, 2024

Describe the bug
The TwitterSearchClient comes broken out of box

Error engaging with search terms: TypeError: Cannot read properties of undefined (reading 'id')
    at TwitterSearchClient.fetchHomeTimeline (file:///Users/owen.wahlgren/code/eliza/packages/client-twitter/dist/index.js:337:82)
    at TwitterSearchClient.engageWithSearchTerms (file:///Users/owen.wahlgren/code/eliza/packages/client-twitter/dist/index.js:812:45)

To Reproduce
Clone most recent release
Build character.json with twitter in character files clients array.

 "clients": [
    "twitter",
    "telegram"
  ],

Update packages/client-twitter/src/index.ts to include search functionality

import { TwitterPostClient } from "./post.ts";
import { TwitterSearchClient } from "./search.ts";
import { TwitterInteractionClient } from "./interactions.ts";
import { IAgentRuntime, Client, elizaLogger } from "@ai16z/eliza";
import { validateTwitterConfig } from "./environment.ts";
import { ClientBase } from "./base.ts";

class TwitterManager {
    client: ClientBase;
    post: TwitterPostClient;
    search: TwitterSearchClient;
    interaction: TwitterInteractionClient;
    constructor(runtime: IAgentRuntime) {
        this.client = new ClientBase(runtime);
        this.post = new TwitterPostClient(this.client, runtime);
        this.search = new TwitterSearchClient(runtime); // don't start the search client by default (ADDED THIS)
        // this searches topics from character file, but kind of violates consent of random users
        // burns your rate limit and can get your account banned
        // use at your own risk
        this.interaction = new TwitterInteractionClient(this.client, runtime);
    }
}

export const TwitterClientInterface: Client = {
    async start(runtime: IAgentRuntime) {
        await validateTwitterConfig(runtime);

        elizaLogger.log("Twitter client started");

        const manager = new TwitterManager(runtime);

        await manager.client.init();

        await manager.post.start();

        await manager.interaction.start();

        await manager.search.onReady(); // (ADDED THIS)

        return manager;
    },
    async stop(_runtime: IAgentRuntime) {
        elizaLogger.warn("Twitter client does not support stopping yet");
    },
};

export default TwitterClientInterface;

Build and start project:

pnpm build
pnpm start

Expected behavior

Should engage in searched timeline activity outside of just mentions

@owenwahlgren owenwahlgren added the bug Something isn't working label Dec 9, 2024
@DaggerWilson
Copy link

I also received "runtime.getSetting is not defined" when uncommenting and adding onReady to start the client on startup and uncommenting

Tried fixing by updating createAgent and AgentRuntime, but ended up breaking the entire thing and won't launch.

@owenwahlgren
Copy link
Author

I also received "runtime.getSetting is not defined" when uncommenting and adding onReady to start the client on startup and uncommenting

Tried fixing by updating createAgent and AgentRuntime, but ended up breaking the entire thing and won't launch.

I resolved this in packages/client-twitter/src/search.ts

 constructor(runtime: IAgentRuntime) {
        // Initialize the client and pass an optional callback to be called when the client is ready
        super(
            runtime, // change this
        );
    }

@owenwahlgren
Copy link
Author

tbh this may be resolved if you bump to latest version of https://github.com/ai16z/agent-twitter-client

testing now

@DaggerWilson
Copy link

You've helped me overcome that roadblock, much appreciated! Now I see the search, but hitting:

Error engaging with search terms: TypeError: Cannot read properties of undefined (reading 'id')
    at TwitterSearchClient.fetchHomeTimeline (file:///root/eliza/packages/client-twitter/dist/index.js:311:82)
    at TwitterSearchClient.engageWithSearchTerms (file:///root/eliza/packages/client-twitter/dist/index.js:563:45)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)

Possibly unrelated to this, but will keep testing

@owenwahlgren
Copy link
Author

owenwahlgren commented Dec 9, 2024

here is my initial fix:
d0d062b
this will twitter search topics in character.json depending on SearchMode (I set top) and reply to one on eliza's startup,
I don't think it is properly looping though, still working on it.

if I make substantial progress maybe we can make a PR

@owenwahlgren
Copy link
Author

PR here:
#951

make sure you have model set in character.json

"modelProvider": "openai",
  "settings": {
    "temperature": 0.6,
    "secrets": {},
    "voice": {
      "model": "en_US-hfc_male-medium"
    },
    "model": "medium"
  },

@owenwahlgren
Copy link
Author

resolved by 649946c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants