From 703bc540ff1654a4973f6669333fa86872a407bb Mon Sep 17 00:00:00 2001 From: odilitime Date: Tue, 10 Dec 2024 03:39:12 +0000 Subject: [PATCH 1/8] feat: allow character.json settings => secrets to override models for OpenRouter --- packages/core/src/generation.ts | 64 ++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/packages/core/src/generation.ts b/packages/core/src/generation.ts index 9642aa8d10..cca8ef486c 100644 --- a/packages/core/src/generation.ts +++ b/packages/core/src/generation.ts @@ -76,27 +76,49 @@ export async function generateText({ runtime.character.modelEndpointOverride || models[provider].endpoint; let model = models[provider].model[modelClass]; - // if runtime.getSetting("LLAMACLOUD_MODEL_LARGE") is true and modelProvider is LLAMACLOUD, then use the large model - if ( - (runtime.getSetting("LLAMACLOUD_MODEL_LARGE") && - provider === ModelProviderName.LLAMACLOUD) || - (runtime.getSetting("TOGETHER_MODEL_LARGE") && - provider === ModelProviderName.TOGETHER) - ) { - model = - runtime.getSetting("LLAMACLOUD_MODEL_LARGE") || - runtime.getSetting("TOGETHER_MODEL_LARGE"); - } - - if ( - (runtime.getSetting("LLAMACLOUD_MODEL_SMALL") && - provider === ModelProviderName.LLAMACLOUD) || - (runtime.getSetting("TOGETHER_MODEL_SMALL") && - provider === ModelProviderName.TOGETHER) - ) { - model = - runtime.getSetting("LLAMACLOUD_MODEL_SMALL") || - runtime.getSetting("TOGETHER_MODEL_SMALL"); + // allow character.json settings => secrets to override models + // FIXME: add MODEL_MEDIUM support + switch(provider) { + // if runtime.getSetting("LLAMACLOUD_MODEL_LARGE") is true and modelProvider is LLAMACLOUD, then use the large model + case ModelProviderName.LLAMACLOUD: { + switch(modelClass) { + case ModelClass.LARGE: { + model = runtime.getSetting("LLAMACLOUD_MODEL_LARGE") || model; + } + break; + case ModelClass.SMALL: { + model = runtime.getSetting("LLAMACLOUD_MODEL_SMALL") || model; + } + break; + } + } + break; + case ModelProviderName.TOGETHER: { + switch(modelClass) { + case ModelClass.LARGE: { + model = runtime.getSetting("TOGETHER_MODEL_LARGE") || model; + } + break; + case ModelClass.SMALL: { + model = runtime.getSetting("TOGETHER_MODEL_SMALL") || model; + } + break; + } + } + break; + case ModelProviderName.OPENROUTER: { + switch(modelClass) { + case ModelClass.LARGE: { + model = runtime.getSetting("LARGE_OPENROUTER_MODEL") || model; + } + break; + case ModelClass.SMALL: { + model = runtime.getSetting("SMALL_OPENROUTER_MODEL") || model; + } + break; + } + } + break; } elizaLogger.info("Selected model:", model); From 82b90d3b4761f66922de6a5eb6656d273835174f Mon Sep 17 00:00:00 2001 From: odilitime Date: Tue, 10 Dec 2024 04:06:25 +0000 Subject: [PATCH 2/8] rename intiface plugin --- .../{plugin-buttplug => plugin-intiface}/.npmignore | 0 .../intiface-engine/CHANGELOG.md | 0 .../intiface-engine/README.md | 0 .../intiface-engine/intiface-engine | Bin .../package.json | 0 .../src/buttplug-user-device-config.json | 0 .../src/environment.ts | 0 .../src/index.ts | 0 .../src/utils.ts | 0 .../test/buttplug-user-device-config-test.json | 0 .../test/fake-buttplug.ts | 0 .../test/simulate.ts | 0 .../tsconfig.json | 0 .../tsup.config.ts | 0 14 files changed, 0 insertions(+), 0 deletions(-) rename packages/{plugin-buttplug => plugin-intiface}/.npmignore (100%) rename packages/{plugin-buttplug => plugin-intiface}/intiface-engine/CHANGELOG.md (100%) rename packages/{plugin-buttplug => plugin-intiface}/intiface-engine/README.md (100%) rename packages/{plugin-buttplug => plugin-intiface}/intiface-engine/intiface-engine (100%) rename packages/{plugin-buttplug => plugin-intiface}/package.json (100%) rename packages/{plugin-buttplug => plugin-intiface}/src/buttplug-user-device-config.json (100%) rename packages/{plugin-buttplug => plugin-intiface}/src/environment.ts (100%) rename packages/{plugin-buttplug => plugin-intiface}/src/index.ts (100%) rename packages/{plugin-buttplug => plugin-intiface}/src/utils.ts (100%) rename packages/{plugin-buttplug => plugin-intiface}/test/buttplug-user-device-config-test.json (100%) rename packages/{plugin-buttplug => plugin-intiface}/test/fake-buttplug.ts (100%) rename packages/{plugin-buttplug => plugin-intiface}/test/simulate.ts (100%) rename packages/{plugin-buttplug => plugin-intiface}/tsconfig.json (100%) rename packages/{plugin-buttplug => plugin-intiface}/tsup.config.ts (100%) diff --git a/packages/plugin-buttplug/.npmignore b/packages/plugin-intiface/.npmignore similarity index 100% rename from packages/plugin-buttplug/.npmignore rename to packages/plugin-intiface/.npmignore diff --git a/packages/plugin-buttplug/intiface-engine/CHANGELOG.md b/packages/plugin-intiface/intiface-engine/CHANGELOG.md similarity index 100% rename from packages/plugin-buttplug/intiface-engine/CHANGELOG.md rename to packages/plugin-intiface/intiface-engine/CHANGELOG.md diff --git a/packages/plugin-buttplug/intiface-engine/README.md b/packages/plugin-intiface/intiface-engine/README.md similarity index 100% rename from packages/plugin-buttplug/intiface-engine/README.md rename to packages/plugin-intiface/intiface-engine/README.md diff --git a/packages/plugin-buttplug/intiface-engine/intiface-engine b/packages/plugin-intiface/intiface-engine/intiface-engine similarity index 100% rename from packages/plugin-buttplug/intiface-engine/intiface-engine rename to packages/plugin-intiface/intiface-engine/intiface-engine diff --git a/packages/plugin-buttplug/package.json b/packages/plugin-intiface/package.json similarity index 100% rename from packages/plugin-buttplug/package.json rename to packages/plugin-intiface/package.json diff --git a/packages/plugin-buttplug/src/buttplug-user-device-config.json b/packages/plugin-intiface/src/buttplug-user-device-config.json similarity index 100% rename from packages/plugin-buttplug/src/buttplug-user-device-config.json rename to packages/plugin-intiface/src/buttplug-user-device-config.json diff --git a/packages/plugin-buttplug/src/environment.ts b/packages/plugin-intiface/src/environment.ts similarity index 100% rename from packages/plugin-buttplug/src/environment.ts rename to packages/plugin-intiface/src/environment.ts diff --git a/packages/plugin-buttplug/src/index.ts b/packages/plugin-intiface/src/index.ts similarity index 100% rename from packages/plugin-buttplug/src/index.ts rename to packages/plugin-intiface/src/index.ts diff --git a/packages/plugin-buttplug/src/utils.ts b/packages/plugin-intiface/src/utils.ts similarity index 100% rename from packages/plugin-buttplug/src/utils.ts rename to packages/plugin-intiface/src/utils.ts diff --git a/packages/plugin-buttplug/test/buttplug-user-device-config-test.json b/packages/plugin-intiface/test/buttplug-user-device-config-test.json similarity index 100% rename from packages/plugin-buttplug/test/buttplug-user-device-config-test.json rename to packages/plugin-intiface/test/buttplug-user-device-config-test.json diff --git a/packages/plugin-buttplug/test/fake-buttplug.ts b/packages/plugin-intiface/test/fake-buttplug.ts similarity index 100% rename from packages/plugin-buttplug/test/fake-buttplug.ts rename to packages/plugin-intiface/test/fake-buttplug.ts diff --git a/packages/plugin-buttplug/test/simulate.ts b/packages/plugin-intiface/test/simulate.ts similarity index 100% rename from packages/plugin-buttplug/test/simulate.ts rename to packages/plugin-intiface/test/simulate.ts diff --git a/packages/plugin-buttplug/tsconfig.json b/packages/plugin-intiface/tsconfig.json similarity index 100% rename from packages/plugin-buttplug/tsconfig.json rename to packages/plugin-intiface/tsconfig.json diff --git a/packages/plugin-buttplug/tsup.config.ts b/packages/plugin-intiface/tsup.config.ts similarity index 100% rename from packages/plugin-buttplug/tsup.config.ts rename to packages/plugin-intiface/tsup.config.ts From 4528c46ac8d48a97fb27ec4be55ae3eab9f2bffc Mon Sep 17 00:00:00 2001 From: odilitime Date: Tue, 10 Dec 2024 04:16:38 +0000 Subject: [PATCH 3/8] rename intiface-user-device-config.json --- ...er-device-config.json => intiface-user-device-config.json} | 0 packages/plugin-intiface/src/utils.ts | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename packages/plugin-intiface/src/{buttplug-user-device-config.json => intiface-user-device-config.json} (100%) diff --git a/packages/plugin-intiface/src/buttplug-user-device-config.json b/packages/plugin-intiface/src/intiface-user-device-config.json similarity index 100% rename from packages/plugin-intiface/src/buttplug-user-device-config.json rename to packages/plugin-intiface/src/intiface-user-device-config.json diff --git a/packages/plugin-intiface/src/utils.ts b/packages/plugin-intiface/src/utils.ts index 43e930dbf4..12019898d9 100644 --- a/packages/plugin-intiface/src/utils.ts +++ b/packages/plugin-intiface/src/utils.ts @@ -24,7 +24,7 @@ export async function isPortAvailable(port: number): Promise { export async function startIntifaceEngine(): Promise { const configPath = path.join( __dirname, - "../src/buttplug-user-device-config.json" + "../src/intiface-user-device-config.json" ); try { const child = spawn( @@ -34,7 +34,7 @@ export async function startIntifaceEngine(): Promise { "12345", "--use-bluetooth-le", "--server-name", - "Eliza Buttplugin Server", + "Eliza Intiface Server", "--use-device-websocket-server", "--user-device-config-file", configPath, From 8debe125e201d4c7eb9ca023047f14a92c9fc0c1 Mon Sep 17 00:00:00 2001 From: odilitime Date: Tue, 10 Dec 2024 04:17:53 +0000 Subject: [PATCH 4/8] rename intiface plugin --- agent/package.json | 2 +- packages/core/src/types.ts | 4 +- packages/plugin-intiface/src/environment.ts | 14 +++--- packages/plugin-intiface/src/index.ts | 48 ++++++++++----------- 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/agent/package.json b/agent/package.json index 6724b5a5d2..e27d4aa5ee 100644 --- a/agent/package.json +++ b/agent/package.json @@ -29,7 +29,7 @@ "@ai16z/plugin-0g": "workspace:*", "@ai16z/plugin-aptos": "workspace:*", "@ai16z/plugin-bootstrap": "workspace:*", - "@ai16z/plugin-buttplug": "workspace:*", + "@ai16z/plugin-intiface": "workspace:*", "@ai16z/plugin-coinbase": "workspace:*", "@ai16z/plugin-conflux": "workspace:*", "@ai16z/plugin-evm": "workspace:*", diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index 9b33376c45..b67647ea52 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -681,7 +681,7 @@ export type Character = { /** Optional configuration */ settings?: { secrets?: { [key: string]: string }; - buttplug?: boolean; + intiface?: boolean; voice?: { model?: string; // For VITS url?: string; // Legacy VITS support @@ -1143,7 +1143,7 @@ export enum ServiceType { BROWSER = "browser", SPEECH_GENERATION = "speech_generation", PDF = "pdf", - BUTTPLUG = "buttplug", + INTIFACE = "intiface", } export enum LoggingLevel { diff --git a/packages/plugin-intiface/src/environment.ts b/packages/plugin-intiface/src/environment.ts index 47ba5c0cd5..9359952df7 100644 --- a/packages/plugin-intiface/src/environment.ts +++ b/packages/plugin-intiface/src/environment.ts @@ -1,10 +1,10 @@ import { IAgentRuntime } from "@ai16z/eliza"; import { z } from "zod"; -export const buttplugEnvSchema = z +export const intifaceEnvSchema = z .object({ INTIFACE_URL: z.string().default("ws://localhost:12345"), - INTIFACE_NAME: z.string().default("Eliza Buttplug Client"), + INTIFACE_NAME: z.string().default("Eliza Intiface Client"), DEVICE_NAME: z.string().default("Lovense Nora"), }) .refine( @@ -20,11 +20,11 @@ export const buttplugEnvSchema = z } ); -export type ButtplugConfig = z.infer; +export type IntifaceConfig = z.infer; -export async function validateButtplugConfig( +export async function validateIntifaceConfig( runtime: IAgentRuntime -): Promise { +): Promise { try { const config = { INTIFACE_URL: @@ -36,14 +36,14 @@ export async function validateButtplugConfig( runtime.getSetting("DEVICE_NAME") || process.env.DEVICE_NAME, }; - return buttplugEnvSchema.parse(config); + return intifaceEnvSchema.parse(config); } catch (error) { if (error instanceof z.ZodError) { const errorMessages = error.errors .map((err) => `${err.path.join(".")}: ${err.message}`) .join("\n"); throw new Error( - `Buttplug configuration validation failed:\n${errorMessages}` + `Intiface configuration validation failed:\n${errorMessages}` ); } throw error; diff --git a/packages/plugin-intiface/src/index.ts b/packages/plugin-intiface/src/index.ts index b9da82b015..3cf09276e9 100644 --- a/packages/plugin-intiface/src/index.ts +++ b/packages/plugin-intiface/src/index.ts @@ -1,5 +1,5 @@ import { ButtplugClient, ButtplugNodeWebsocketClientConnector } from "buttplug"; -import { validateButtplugConfig, type ButtplugConfig } from "./environment"; +import { validateIntifaceConfig, type IntifaceConfig } from "./environment"; import type { Action, HandlerCallback, @@ -15,7 +15,7 @@ import { shutdownIntifaceEngine, } from "./utils"; -export interface IButtplugService extends Service { +export interface IIntifaceService extends Service { vibrate(strength: number, duration: number): Promise; rotate?(strength: number, duration: number): Promise; getBatteryLevel?(): Promise; @@ -23,14 +23,14 @@ export interface IButtplugService extends Service { getDevices(): any[]; } -export class ButtplugService extends Service implements IButtplugService { - static serviceType: ServiceType = ServiceType.BUTTPLUG; +export class IntifaceService extends Service implements IIntifaceService { + static serviceType: ServiceType = ServiceType.INTIFACE; private client: ButtplugClient; private connected = false; private devices: Map = new Map(); private vibrateQueue: VibrateEvent[] = []; private isProcessingQueue = false; - private config: ButtplugConfig | null = null; + private config: IntifaceConfig | null = null; private maxVibrationIntensity = 1; private rampUpAndDown = false; private rampSteps = 20; @@ -62,16 +62,16 @@ export class ButtplugService extends Service implements IButtplugService { } await shutdownIntifaceEngine(); } catch (error) { - console.error("[ButtplugService] Cleanup error:", error); + console.error("[IntifaceService] Cleanup error:", error); } } - getInstance(): IButtplugService { + getInstance(): IIntifaceService { return this; } async initialize(runtime: IAgentRuntime): Promise { - this.config = await validateButtplugConfig(runtime); + this.config = await validateIntifaceConfig(runtime); this.preferredDeviceName = this.config.DEVICE_NAME; this.client = new ButtplugClient(this.config.INTIFACE_NAME); @@ -118,7 +118,7 @@ export class ButtplugService extends Service implements IButtplugService { await new Promise((r) => setTimeout(r, 2000)); } else { console.error( - "Failed to connect to Buttplug server after all retries:", + "Failed to connect to Intiface server after all retries:", error ); throw error; @@ -144,7 +144,7 @@ export class ButtplugService extends Service implements IButtplugService { private async ensureDeviceAvailable() { if (!this.connected) { - throw new Error("Not connected to Buttplug server"); + throw new Error("Not connected to Intiface server"); } if (this.devices.size === 0) { @@ -325,7 +325,7 @@ const vibrateAction: Action = { description: "Control vibration intensity of connected devices", validate: async (runtime: IAgentRuntime, _message: Memory) => { try { - await validateButtplugConfig(runtime); + await validateIntifaceConfig(runtime); return true; } catch { return false; @@ -338,11 +338,11 @@ const vibrateAction: Action = { options: any, callback: HandlerCallback ) => { - const service = runtime.getService( - ServiceType.BUTTPLUG + const service = runtime.getService( + ServiceType.INTIFACE ); if (!service) { - throw new Error("Buttplug service not available"); + throw new Error("Intiface service not available"); } // Extract intensity and duration from message @@ -435,7 +435,7 @@ const rotateAction: Action = { description: "Control rotation intensity of connected devices", validate: async (runtime: IAgentRuntime, _message: Memory) => { try { - await validateButtplugConfig(runtime); + await validateIntifaceConfig(runtime); return true; } catch { return false; @@ -448,8 +448,8 @@ const rotateAction: Action = { options: any, callback: HandlerCallback ) => { - const service = runtime.getService( - ServiceType.BUTTPLUG + const service = runtime.getService( + ServiceType.INTIFACE ); if (!service || !service.rotate) { throw new Error("Rotation not supported"); @@ -493,7 +493,7 @@ const batteryAction: Action = { description: "Check battery level of connected devices", validate: async (runtime: IAgentRuntime, _message: Memory) => { try { - await validateButtplugConfig(runtime); + await validateIntifaceConfig(runtime); return true; } catch { return false; @@ -506,8 +506,8 @@ const batteryAction: Action = { options: any, callback: HandlerCallback ) => { - const service = runtime.getService( - ServiceType.BUTTPLUG + const service = runtime.getService( + ServiceType.INTIFACE ); if (!service || !service.getBatteryLevel) { throw new Error("Battery level check not supported"); @@ -573,13 +573,13 @@ interface VibrateEvent { deviceId?: number; } -export const buttplugPlugin: Plugin = { - name: "buttplug", +export const intifacePlugin: Plugin = { + name: "intiface", description: "Controls intimate hardware devices", actions: [vibrateAction, rotateAction, batteryAction], evaluators: [], providers: [], - services: [new ButtplugService()], + services: [new IntifaceService()], }; -export default buttplugPlugin; +export default intifacePlugin; From cc1a9402b4bf1008e42ef84b8b8f9938d6af64eb Mon Sep 17 00:00:00 2001 From: odilitime Date: Tue, 10 Dec 2024 04:18:45 +0000 Subject: [PATCH 5/8] rename intiface plugin --- agent/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agent/src/index.ts b/agent/src/index.ts index e866ad264d..04c7380841 100644 --- a/agent/src/index.ts +++ b/agent/src/index.ts @@ -27,7 +27,7 @@ import { import { zgPlugin } from "@ai16z/plugin-0g"; import { goatPlugin } from "@ai16z/plugin-goat"; import { bootstrapPlugin } from "@ai16z/plugin-bootstrap"; -// import { buttplugPlugin } from "@ai16z/plugin-buttplug"; +// import { intifacePlugin } from "@ai16z/plugin-intiface"; import { coinbaseCommercePlugin, coinbaseMassPaymentsPlugin, From 1935ad8f3df945a3680609ff40f23619ab2a828b Mon Sep 17 00:00:00 2001 From: odilitime Date: Tue, 10 Dec 2024 21:23:22 +0000 Subject: [PATCH 6/8] rename package name --- packages/plugin-intiface/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugin-intiface/package.json b/packages/plugin-intiface/package.json index e00b348aad..16cc574f3e 100644 --- a/packages/plugin-intiface/package.json +++ b/packages/plugin-intiface/package.json @@ -1,5 +1,5 @@ { - "name": "@ai16z/plugin-buttplug", + "name": "@ai16z/plugin-intiface", "version": "0.1.5-alpha.5", "main": "dist/index.js", "type": "module", From 8f3b11d94064ff8f8f4f881be1007bc2eb518ebf Mon Sep 17 00:00:00 2001 From: odilitime Date: Tue, 10 Dec 2024 21:44:30 +0000 Subject: [PATCH 7/8] add build-docker action --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 7e9b1a9194..ebbafb73a8 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "scripts": { "preinstall": "npx only-allow pnpm", "build": "turbo run build --filter=!eliza-docs", + "build-docker": "turbo run build", "start": "pnpm --filter \"@ai16z/agent\" start --isRoot", "start:client": "pnpm --dir client start --isRoot", "start:debug": "cross-env NODE_ENV=development VERBOSE=true DEBUG=eliza:* pnpm --filter \"@ai16z/agent\" start --isRoot", From 6337fa8d4e784acc20c6ad7032cc7751153a2f51 Mon Sep 17 00:00:00 2001 From: odilitime Date: Tue, 10 Dec 2024 21:45:03 +0000 Subject: [PATCH 8/8] use build-docker --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index a16b33ac0c..d97ed212cb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,7 +25,7 @@ COPY characters ./characters # Install dependencies and build the project RUN pnpm install \ - && pnpm build \ + && pnpm build-docker \ && pnpm prune --prod # Create a new stage for the final image