Skip to content

Commit

Permalink
improve tweet
Browse files Browse the repository at this point in the history
  • Loading branch information
ponderingdemocritus committed Jan 19, 2025
1 parent 66623eb commit fefdb86
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 47 deletions.
51 changes: 8 additions & 43 deletions examples/example-twitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ async function main() {
LogLevel.DEBUG
);

// Initialize consciousness
const consciousness = new Consciousness(llmClient, roomManager, {
intervalMs: 300000, // Think every 5 minutes
minConfidence: 0.7,
logLevel: LogLevel.DEBUG,
});

// Register Twitter inputs
core.registerInput({
name: "twitter_mentions",
Expand All @@ -70,55 +77,13 @@ async function main() {
interval: 60000,
});

// // Monitor specific Twitter accounts
// const accountsToMonitor = ["elonmusk", "sama", "naval"];

// for (const account of accountsToMonitor) {
// core.registerInput({
// name: `twitter_timeline_${account}`,
// handler: async () => {
// console.log(chalk.blue(`📱 Checking ${account}'s timeline...`));
// return twitter.createTimelineInput(account, 300000).handler();
// },
// response: {
// type: "string",
// content: "string",
// metadata: "object",
// },
// interval: 300000, // Check timelines every 5 minutes
// });
// }

// Initialize consciousness
const consciousness = new Consciousness(llmClient, roomManager, {
intervalMs: 300000, // Think every 5 minutes
minConfidence: 0.7,
logLevel: LogLevel.DEBUG,
});

// Register consciousness input
core.registerInput({
name: "consciousness_thoughts",
handler: async () => {
console.log(chalk.blue("🧠 Generating thoughts..."));
const thought = await consciousness.start();

// Only return thought if it's not an error and has sufficient confidence
if (thought.type !== "error" && thought.type !== "low_confidence") {
// If it's a social_share type thought, format it for Twitter
if (thought.metadata?.type === "social_share") {
return {
type: "thought",
content: thought.content,
metadata: {
...thought.metadata,
suggestedPlatform: "twitter",
thoughtType: "social_share",
},
};
}
}
return null;
return thought;
},
response: {
type: "string",
Expand Down
4 changes: 0 additions & 4 deletions packages/core/src/core/consciousness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,9 @@ Focus on:
}

private async think(): Promise<Thought> {
console.log("thinking");
try {
console.log("generating thought");
const thought = await this.generateThought();

console.log("thought", thought);

if (thought.confidence >= (this.config.minConfidence || 0.7)) {
return {
type: "internal_thought",
Expand Down

0 comments on commit fefdb86

Please sign in to comment.