Skip to content

Commit

Permalink
Merge branch 'v2-develop' into tcm/elevnlabs-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
tcm390 authored Feb 12, 2025
2 parents 0059bf9 + 8ad9ef6 commit e6aba11
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 31 deletions.
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"build:cli": "turbo run build --filter=./packages/cli && cd packages/cli && bun link",
"start": "turbo run start --filter=!./packages/docs",
"agent": "turbo run start --filter=@elizaos/agent",
"dev": "turbo run build --filter=./packages/core && turbo run dev --filter=!./packages/core --concurrency=20",
"dev": "turbo run build --filter=./packages/core && turbo run dev --filter=!./packages/core --filter=!./packages/docs --concurrency=20",
"release": "bun run build && bun format && npx lerna publish --no-private --force-publish",
"docker:build": "bash ./scripts/docker.sh build",
"docker:run": "bash ./scripts/docker.sh run",
Expand Down
3 changes: 0 additions & 3 deletions packages/agent/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,6 @@ export function createApiRouter(

router.post("/agent/start", async (req, res) => {
const { characterPath, characterJson } = req.body;
console.log("characterPath:", characterPath);
console.log("characterJson:", characterJson);
try {
let character: Character;
if (characterJson) {
Expand Down Expand Up @@ -340,7 +338,6 @@ export function createApiRouter(

router.post("/agents/:agentId/stop", async (req, res) => {
const agentId = req.params.agentId;
console.log("agentId", agentId);
const agent: IAgentRuntime = agents.get(agentId);

// update character
Expand Down
11 changes: 6 additions & 5 deletions packages/agent/src/defaultCharacter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ export const defaultCharacter: Character = {
name: "Eliza",
username: "eliza",
plugins: [
"@elizaos/plugin-anthropic",
// "@elizaos/plugin-anthropic",
"@elizaos/plugin-openai",
"@elizaos/plugin-elevenlabs",
"@elizaos/plugin-local-ai",
"@elizaos/plugin-discord",
// "@elizaos/plugin-local-ai",
// "@elizaos/plugin-discord",
"@elizaos/plugin-node",
"@elizaos/plugin-telegram",
"@elizaos/plugin-twitter",
// "@elizaos/plugin-telegram",
// "@elizaos/plugin-twitter",
"@elizaos-plugins/evm"
],
settings: {
secrets: {},
Expand Down
14 changes: 6 additions & 8 deletions packages/agent/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import {
composeContext,
logger,
generateMessageResponse,
generateObject,
messageCompletionFooter,
logger,
ModelClass,
stringToUuid,
type Character,
type Content,
type Media,
type Memory,
type IAgentRuntime,
type Character
type Media,
type Memory
} from "@elizaos/core";
import bodyParser from "body-parser";
import cors from "cors";
Expand All @@ -20,9 +19,8 @@ import * as fs from "node:fs";
import * as path from "node:path";
import { z } from "zod";
import { createApiRouter } from "./api.ts";
import { hyperfiHandlerTemplate, messageHandlerTemplate, upload } from "./helper.ts";
import replyAction from "./reply.ts";
import { messageHandlerTemplate } from "./helper.ts";
import { upload } from "./helper.ts";



Expand All @@ -31,7 +29,7 @@ export class CharacterServer {
public app: express.Application;
private agents: Map<string, IAgentRuntime>; // container management
private server: any; // Store server instance
public startAgent: () => Promise<void>; // Store startAgent function
public startAgent: (character: Character) => Promise<IAgentRuntime>; // Store startAgent function
public loadCharacterTryPath: (characterPath: string) => Promise<Character>; // Store loadCharacterTryPath function
public jsonToCharacter: (filePath: string, character: string | never) => Promise<Character>; // Store jsonToCharacter function

Expand Down
1 change: 0 additions & 1 deletion packages/cli/src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ async function installDependencies(targetDir: string, database: string, selected
})

if (selectedPlugins.length > 0) {
console.log(selectedPlugins)
await execa("bun", ["add", ...selectedPlugins, "--workspace-root"], {
cwd: targetDir,
stdio: "inherit"
Expand Down
1 change: 0 additions & 1 deletion packages/cli/src/utils/registry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const agent = process.env.https_proxy

export async function getRegistryIndex(): Promise<Registry> {
try {
console.log("REGISTRY_URL", REGISTRY_URL)
const response = await fetch(REGISTRY_URL, { agent })
// Get the response body as text first
const text = await response.text()
Expand Down
7 changes: 7 additions & 0 deletions packages/core/src/generation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,19 @@ export async function generateText({
stopSequences?: string[];
customSystemPrompt?: string;
}): Promise<string> {

logger.debug("Generating text")
logger.debug(context)

const text = await runtime.useModel(modelClass, {
runtime,
context,
stopSequences,
});

logger.debug("Generated text")
logger.debug(text)

return text;
}

Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/knowledge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ async function get(
runtime: AgentRuntime,
message: Memory
): Promise<KnowledgeItem[]> {
console.log("get", message);
// Add validation for message
if (!message?.content?.text) {
logger.warn("Invalid message for knowledge query:", {
Expand Down Expand Up @@ -70,7 +69,6 @@ async function set(
chunkSize = 512,
bleed = 20
) {
console.log("set", item);
const embedding = await runtime.useModel(ModelClass.TEXT_EMBEDDING, null);
await runtime.documentsManager.createMemory({
id: item.id,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const createStream = () => {
});
};

const defaultLevel = process?.env?.DEFAULT_LOG_LEVEL || "info";
const defaultLevel = process?.env?.DEFAULT_LOG_LEVEL || process?.env?.LOG_LEVEL || "info";

const options = {
level: defaultLevel,
Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export class MemoryManager implements IMemoryManager {
* @throws Error if the memory content is empty
*/
async addEmbeddingToMemory(memory: Memory): Promise<Memory> {
console.log("addEmbeddingToMemory", memory);
// Return early if embedding already exists
if (memory.embedding) {
return memory;
Expand Down Expand Up @@ -174,7 +173,6 @@ export class MemoryManager implements IMemoryManager {
*/
async createMemory(memory: Memory, unique = false): Promise<void> {
// TODO: check memory.agentId == this.runtime.agentId
console.log("createMemory", memory);

const existingMessage =
await this.runtime.databaseAdapter.getMemoryById(memory.id);
Expand Down
30 changes: 28 additions & 2 deletions packages/core/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,15 @@ export class AgentRuntime implements IAgentRuntime {
for(const route of plugin.routes){
this.routes.push(route);
}

for(const client of plugin.clients){
client.start(this).then((startedClient) => {
logger.debug(
`Initializing client: ${client.name}`
);
this.clients.push(startedClient);
});
}
}

this.plugins = plugins;
Expand All @@ -353,6 +362,25 @@ export class AgentRuntime implements IAgentRuntime {
this.clients.push(startedClient);
}
}

if (plugin.actions) {
for (const action of plugin.actions) {
this.registerAction(action);
}
}

if (plugin.evaluators) {
for (const evaluator of plugin.evaluators) {
this.registerEvaluator(evaluator);
}
}

if (plugin.providers) {
for (const provider of plugin.providers) {
this.registerContextProvider(provider);
}
}

if (plugin.models) {
for (const [modelClass, handler] of Object.entries(plugin.models)) {
this.registerModel(modelClass as ModelClass, handler as (params: any) => Promise<any>);
Expand Down Expand Up @@ -602,8 +630,6 @@ export class AgentRuntime implements IAgentRuntime {
modelClass: ModelClass.TEXT_SMALL,
});

console.log("***** result", result);

const evaluators = parseJsonArrayFromText(
result,
) as unknown as string[];
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ export type Media = {
*/
export type ClientInstance = {
/** Client name */
// name: string;
name?: string;

/** Stop client connection */
stop: (runtime: IAgentRuntime) => Promise<unknown>;
Expand Down
7 changes: 3 additions & 4 deletions packages/plugin-openai/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ export const openaiPlugin: Plugin = {
runtime.getSetting("SMALL_MODEL") ??
"gpt-4o-mini";

console.log("generating text")
console.log(context)

const { text: openaiResponse } = await aiGenerateText({
model: openai.languageModel(model),
prompt: context,
Expand Down Expand Up @@ -178,10 +181,6 @@ export const openaiPlugin: Plugin = {
baseURL,
});

const smallModel =
runtime.getSetting("OPENAI_SMALL_MODEL") ??
runtime.getSetting("SMALL_MODEL") ??
"gpt-4o-mini";
const model =
runtime.getSetting("OPENAI_LARGE_MODEL") ?? runtime.getSetting("LARGE_MODEL") ?? "gpt-4o";

Expand Down

0 comments on commit e6aba11

Please sign in to comment.