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: unruggable #398

Merged
merged 7 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion packages/agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import fs from "fs";
import readline from "readline";
import yargs from "yargs";
import { character } from "./character.ts";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove custom blobert and revert changes to original character


export const wait = (minTime: number = 1000, maxTime: number = 3000) => {
const waitTime =
Math.floor(Math.random() * (maxTime - minTime + 1)) + minTime;
Expand Down
8 changes: 4 additions & 4 deletions packages/client-direct/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import bodyParser from "body-parser";
import cors from "cors";
import express, { Request as ExpressRequest } from "express";
import multer, { File } from "multer";
import { generateCaption, generateImage } from "@ai16z/eliza";
import { elizaLogger, generateCaption, generateImage } from "@ai16z/eliza";
import { composeContext } from "@ai16z/eliza";
import { generateMessageResponse } from "@ai16z/eliza";
import { messageCompletionFooter } from "@ai16z/eliza";
Expand Down Expand Up @@ -279,21 +279,21 @@ export class DirectClient {

public start(port: number) {
this.app.listen(port, () => {
console.log(`Server running at http://localhost:${port}/`);
elizaLogger.success(`Server running at http://localhost:${port}/`);
});
}
}

export const DirectClientInterface: Client = {
start: async (runtime: IAgentRuntime) => {
console.log("DirectClientInterface start");
elizaLogger.log("DirectClientInterface start");
const client = new DirectClient();
const serverPort = parseInt(settings.SERVER_PORT || "3000");
client.start(serverPort);
return client;
},
stop: async (runtime: IAgentRuntime) => {
console.warn("Direct client does not support stopping yet");
elizaLogger.warn("Direct client does not support stopping yet");
},
};

Expand Down
6 changes: 2 additions & 4 deletions packages/client-discord/src/actions/chat_with_attachments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,12 @@ const summarizeAction = {

let currentSummary = "";

const model = models[runtime.character.settings.model];
const chunkSize = model.settings.maxContextLength;
const model = models[runtime.character.modelProvider];
const chunkSize = model.settings.maxOutputTokens;

state.attachmentsWithText = attachmentsWithText;
state.objective = objective;

const datestr = new Date().toUTCString().replace(/:/g, "-");

const context = composeContext({
state,
// make sure it fits, we can pad the tokens a bit
Expand Down
4 changes: 2 additions & 2 deletions packages/client-discord/src/actions/summarize_conversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ const summarizeAction = {

let currentSummary = "";

const model = models[runtime.character.settings.model];
const chunkSize = model.settings.maxContextLength - 1000;
const model = models[runtime.character.modelProvider];
const chunkSize = model.settings.maxOutputTokens - 1000;

const chunks = await splitChunks(formattedMemories, chunkSize, 0);

Expand Down
18 changes: 9 additions & 9 deletions packages/client-twitter/src/interactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class TwitterInteractionClient extends ClientBase {
}

async handleTwitterInteractions() {
console.log("Checking Twitter interactions");
elizaLogger.log("Checking Twitter interactions");
try {
// Check for mentions
const tweetCandidates = (
Expand Down Expand Up @@ -167,7 +167,7 @@ export class TwitterInteractionClient extends ClientBase {
);
}
} catch (error) {
console.error(
elizaLogger.error(
"Error saving latest checked tweet ID to file:",
error
);
Expand All @@ -185,15 +185,15 @@ export class TwitterInteractionClient extends ClientBase {
);
}
} catch (error) {
console.error(
elizaLogger.error(
"Error saving latest checked tweet ID to file:",
error
);
}

console.log("Finished checking Twitter interactions");
elizaLogger.log("Finished checking Twitter interactions");
} catch (error) {
console.error("Error handling Twitter interactions:", error);
elizaLogger.error("Error handling Twitter interactions:", error);
}
}

Expand All @@ -213,7 +213,7 @@ export class TwitterInteractionClient extends ClientBase {
}

if (!message.content.text) {
console.log("skipping tweet with no text", tweet.id);
elizaLogger.log("skipping tweet with no text", tweet.id);
return { text: "", action: "IGNORE" };
}
elizaLogger.log("handling tweet", tweet.id);
Expand Down Expand Up @@ -277,7 +277,7 @@ export class TwitterInteractionClient extends ClientBase {
await this.runtime.messageManager.getMemoryById(tweetId);

if (!tweetExists) {
console.log("tweet does not exist, saving");
elizaLogger.log("tweet does not exist, saving");
const userIdUUID = stringToUuid(tweet.userId as string);
const roomId = stringToUuid(tweet.conversationId);

Expand Down Expand Up @@ -321,7 +321,7 @@ export class TwitterInteractionClient extends ClientBase {

// Promise<"RESPOND" | "IGNORE" | "STOP" | null> {
if (shouldRespond !== "RESPOND") {
console.log("Not responding to message");
elizaLogger.log("Not responding to message");
return { text: "Response Decision:", action: shouldRespond };
}

Expand Down Expand Up @@ -398,7 +398,7 @@ export class TwitterInteractionClient extends ClientBase {
fs.writeFileSync(debugFileName, responseInfo);
await wait();
} catch (error) {
console.error(`Error sending response tweet: ${error}`);
elizaLogger.error(`Error sending response tweet: ${error}`);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-bootstrap/src/actions/continue.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { composeContext } from "@ai16z/eliza";
import { composeContext, elizaLogger } from "@ai16z/eliza";
import { generateMessageResponse, generateTrueOrFalse } from "@ai16z/eliza";
import { booleanFooter, messageCompletionFooter } from "@ai16z/eliza";
import {
Expand Down Expand Up @@ -123,7 +123,7 @@ export const continueAction: Action = {

const shouldContinue = await _shouldContinue(state);
if (!shouldContinue) {
console.log("Not elaborating");
elizaLogger.log("Not elaborating, returning");
return;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-node/src/services/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ export class ImageDescriptionService extends Service {
return;
}

const model = models[runtime.character.settings.model];
const model = models[runtime.character.modelProvider];

if (model === ModelProviderName.LLAMALOCAL) {
if (model === models[ModelProviderName.LLAMALOCAL]) {
this.modelId = "onnx-community/Florence-2-base-ft";

env.allowLocalModels = false;
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-solana/src/actions/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
createTransferInstruction,
} from "@solana/spl-token";
import bs58 from "bs58";
import { settings } from "@ai16z/eliza";
import { elizaLogger, settings } from "@ai16z/eliza";

import {
Connection,
Expand Down Expand Up @@ -103,7 +103,7 @@ export default {
_options: { [key: string]: unknown },
callback?: HandlerCallback
): Promise<boolean> => {
console.log("Starting TRANSFER_TOKEN handler...");
elizaLogger.log("Starting SEND_TOKEN handler...");

// Initialize or update state
if (!state) {
Expand Down
1 change: 1 addition & 0 deletions packages/plugin-starknet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"@ai16z/eliza": "workspace:*",
"@ai16z/plugin-trustdb": "workspace:*",
"@avnu/avnu-sdk": "^2.1.1",
"@unruggable_starknet/core": "^0.1.0",
"starknet": "^6.17.0",
"tsup": "^8.3.5",
"vitest": "^2.1.4"
Expand Down
10 changes: 7 additions & 3 deletions packages/plugin-starknet/src/actions/swap.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
ActionExample,
elizaLogger,
HandlerCallback,
IAgentRuntime,
Memory,
Expand Down Expand Up @@ -90,6 +91,7 @@ export const executeSwap: Action = {
_options: { [key: string]: unknown },
callback?: HandlerCallback
): Promise<boolean> => {
elizaLogger.log("Starting EXECUTE_STARKNET_SWAP handler...");
if (!state) {
state = (await runtime.composeState(message)) as State;
} else {
Expand All @@ -107,7 +109,7 @@ export const executeSwap: Action = {
modelClass: ModelClass.MEDIUM,
});

console.log("Response:", response);
elizaLogger.debug("Response:", response);

if (!isSwapContent(response)) {
callback?.({ text: "Invalid swap content, please try again." });
Expand All @@ -134,7 +136,9 @@ export const executeSwap: Action = {
}
);

console.log("Swap completed successfully!");
elizaLogger.log(
"Swap completed successfully! tx: " + swapResult.transactionHash
);
callback?.({
text:
"Swap completed successfully! tx: " +
Expand All @@ -143,7 +147,7 @@ export const executeSwap: Action = {

return true;
} catch (error) {
console.error("Error during token swap:", error);
elizaLogger.error("Error during token swap:", error);
callback?.({ text: `Error during swap:` });
return false;
}
Expand Down
15 changes: 7 additions & 8 deletions packages/plugin-starknet/src/actions/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
// It should just transfer tokens from the agent's wallet to the recipient.

import {
settings,
ActionExample,
Content,
HandlerCallback,
IAgentRuntime,
Memory,
Expand All @@ -13,6 +11,7 @@ import {
type Action,
composeContext,
generateObject,
elizaLogger,
} from "@ai16z/eliza";
import {
getStarknetAccount,
Expand Down Expand Up @@ -70,7 +69,7 @@ export default {
_options: { [key: string]: unknown },
callback?: HandlerCallback
): Promise<boolean> => {
console.log("Starting TRANSFER_TOKEN handler...");
elizaLogger.log("Starting SEND_TOKEN handler...");

// Initialize or update state
if (!state) {
Expand All @@ -92,11 +91,11 @@ export default {
modelClass: ModelClass.MEDIUM,
});

console.log("Transfer content:", content);
elizaLogger.debug("Transfer content:", content);

// Validate transfer content
if (!isTransferContent(content)) {
console.error("Invalid content for TRANSFER_TOKEN action.");
elizaLogger.error("Invalid content for TRANSFER_TOKEN action.");
if (callback) {
callback({
text: "Not enough information to transfer tokens. Please respond with token address, recipient, and amount.",
Expand All @@ -120,7 +119,7 @@ export default {
amountWei
);

console.log(
elizaLogger.success(
"Transferring",
amountWei,
"of",
Expand All @@ -131,7 +130,7 @@ export default {

const tx = await account.execute(transferCall);

console.log(
elizaLogger.success(
"Transfer completed successfully! tx: " + tx.transaction_hash
);
if (callback) {
Expand All @@ -145,7 +144,7 @@ export default {

return true;
} catch (error) {
console.error("Error during token transfer:", error);
elizaLogger.error("Error during token transfer:", error);
if (callback) {
callback({
text: `Error transferring tokens: ${error.message}`,
Expand Down
Loading