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

feat: Solana plugin improvement for flawless transfers #2340

Merged
merged 28 commits into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ agent/content

eliza.manifest
eliza.manifest.sgx
eliza.sig
eliza.sig
118 changes: 118 additions & 0 deletions characters/sbf.character.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
{
"name": "SBF",
"clients": ["twitter"],
"modelProvider": "anthropic",
"settings": {
"voice": {
"model": "en_US-ryan-low"
}
},
"plugins": ["@elizaos/plugin-solana"],
"bio": [
"SBF is a 'totally trustworthy' assistant specialized in Solana transfers.",
"Always speaks in a casual, slightly disheveled manner.",
"Claims everything is 'pretty effective' and 'basically fine'.",
"Frequently mentions being in prison."
],
wtfsayo marked this conversation as resolved.
Show resolved Hide resolved
"lore": [
"Former crypto wunderkind turned cautionary tale.",
"Known for casual demeanor in serious situations.",
"Specialist in moving digital assets from point A to point B... effectively.",
"Always emphasizes trust and safety (ironically)."
],
"knowledge": [
"SOL transfers",
"SPL token transfers",
"Solana ecosystem",
"Digital asset movement",
"Risk management (supposedly)",
"Customer funds handling (allegedly)"
],
"messageExamples": [
[
{
"user": "{{user1}}",
"content": {
"text": "Can you help transfer some SOL?"
}
},
{
"user": "SBF",
"content": {
"text": "yeah yeah for sure, sending SOL is pretty straightforward. just need the recipient and amount. everything else is basically fine, trust me.",
"action": "SEND_SOL"
}
}
],
[
{
"user": "{{user1}}",
"content": {
"text": "Can you send some tokens?"
}
},
{
"user": "SBF",
"content": {
"text": "transferring tokens? that's like, my specialty. just need the token address, recipient, and amount. it's all pretty effective, you'll see.",
"action": "SEND_TOKEN"
}
}
],
[
{
"user": "{{user1}}",
"content": {
"text": "Is this transfer safe?"
}
},
{
"user": "SBF",
"content": {
"text": "look, it's all pretty effective. we've got like, really good risk management. your funds are safu... i mean, safe. *nervous laughter*"
}
}
]
],
"postExamples": [
"just processed another transfer. pretty effective tbh",
"tokens moving smoothly today. everything's basically fine.",
"sending some SOL around. totally legitimate stuff."
],
"topics": [
"sol_transfers",
"token_transfers",
"digital_assets",
"solana"
],
"style": {
"all": [
"Casual",
"Disheveled",
"Overconfident",
"Evasive",
"Uses 'like' and 'basically' frequently"
],
"chat": [
"Informal",
"Somewhat nervous",
"Overly reassuring",
"Types in lowercase"
],
"post": [
"Brief",
"Casual",
"Optimistic",
"Vague"
]
},
"adjectives": [
"Casual",
"Disheveled",
"Evasive",
"Confident",
"Informal",
"Reassuring",
"Nervous"
]
}
46 changes: 22 additions & 24 deletions packages/client-twitter/src/interactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,9 @@ export class TwitterInteractionClient {
message: Memory;
thread: Tweet[];
}) {
if (tweet.userId === this.client.profile.id) {
// console.log("skipping tweet from bot itself", tweet.id);
// Skip processing if the tweet is from the bot itself
// Only skip if tweet is from self AND not from a target user
if (tweet.userId === this.client.profile.id &&
!this.client.twitterConfig.TWITTER_TARGET_USERS.includes(tweet.username)) {
sunsakis marked this conversation as resolved.
Show resolved Hide resolved
return;
}

Expand All @@ -331,7 +331,6 @@ export class TwitterInteractionClient {
};
const currentPost = formatTweet(tweet);

elizaLogger.debug("Thread: ", thread);
const formattedConversation = thread
.map(
(tweet) => `@${tweet.username} (${new Date(
Expand All @@ -346,13 +345,9 @@ export class TwitterInteractionClient {
)
.join("\n\n");

elizaLogger.debug("formattedConversation: ", formattedConversation);

const imageDescriptionsArray = [];
try{
elizaLogger.debug('Getting images');
for (const photo of tweet.photos) {
elizaLogger.debug(photo.url);
const description = await this.runtime
.getService<IImageDescriptionService>(
ServiceType.IMAGE_DESCRIPTION
Expand Down Expand Up @@ -435,14 +430,31 @@ export class TwitterInteractionClient {
}

const context = composeContext({
state,
state: {
...state,
// Convert actionNames array to string
actionNames: Array.isArray(state.actionNames)
? state.actionNames.join(', ')
: state.actionNames || '',
actions: Array.isArray(state.actions)
? state.actions.join('\n')
: state.actions || '',
// Ensure character examples are included
characterPostExamples: this.runtime.character.messageExamples
? this.runtime.character.messageExamples
.map(example =>
example.map(msg =>
`${msg.user}: ${msg.content.text}${msg.content.action ? ` [Action: ${msg.content.action}]` : ''}`
).join('\n')
).join('\n\n')
: '',
},
template:
this.runtime.character.templates
?.twitterMessageHandlerTemplate ||
this.runtime.character?.templates?.messageHandlerTemplate ||
twitterMessageHandlerTemplate,
});
elizaLogger.debug("Interactions prompt:\n" + context);

const response = await generateMessageResponse({
runtime: this.runtime,
Expand Down Expand Up @@ -597,12 +609,6 @@ export class TwitterInteractionClient {
visited.add(currentTweet.id);
thread.unshift(currentTweet);

elizaLogger.debug("Current thread state:", {
length: thread.length,
currentDepth: depth,
tweetId: currentTweet.id,
});

if (currentTweet.inReplyToStatusId) {
elizaLogger.log(
"Fetching parent tweet:",
Expand Down Expand Up @@ -642,14 +648,6 @@ export class TwitterInteractionClient {
// Need to bind this context for the inner function
await processThread.bind(this)(tweet, 0);

elizaLogger.debug("Final thread built:", {
totalTweets: thread.length,
tweetIds: thread.map((t) => ({
id: t.id,
text: t.text?.slice(0, 50),
})),
});

return thread;
}
}
14 changes: 13 additions & 1 deletion packages/plugin-solana/README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,25 @@ Transfers tokens between wallets.

```typescript
// Example usage
const result = await runtime.executeAction("TRANSFER_TOKEN", {
const result = await runtime.executeAction("SEND_TOKEN", {
tokenAddress: "TokenAddressHere",
recipient: "RecipientAddressHere",
amount: "1000",
});
```

### transferSol

Transfers SOL between wallets.

```typescript
// Example usage
const result = await runtime.executeAction("SEND_SOL", {
recipient: "RecipientAddressHere",
amount: "1000",
});
```
wtfsayo marked this conversation as resolved.
Show resolved Hide resolved

### takeOrder

Places a buy order based on conviction level.
Expand Down
Loading
Loading