Skip to content

Commit

Permalink
Merge branch 'develop' into feat-adapter-qdrant
Browse files Browse the repository at this point in the history
  • Loading branch information
oxf71 authored Jan 16, 2025
2 parents ee5aee0 + 5076588 commit 3a7f800
Show file tree
Hide file tree
Showing 30 changed files with 1,230 additions and 771 deletions.
19 changes: 19 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Ignore node_modules from the build context
node_modules

# Ignore logs and temporary files
*.log
*.tmp
.DS_Store

# Ignore Git files and metadata
.gitignore

# Ignore IDE and editor config files
.vscode
.idea
*.swp

# Ignore build artifacts from the host
dist
build
62 changes: 43 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,43 +1,62 @@
# Use a specific Node.js version for better reproducibility
FROM node:23.3.0-slim AS builder

# Install pnpm globally and install necessary build tools
# Install pnpm globally and necessary build tools
RUN npm install -g pnpm@9.4.0 && \
apt-get update && \
apt-get install -y git python3 make g++ && \
apt-get upgrade -y && \
apt-get install -y \
git \
python3 \
python3-pip \
curl \
node-gyp \
ffmpeg \
libtool-bin \
autoconf \
automake \
libopus-dev \
make \
g++ \
build-essential \
libcairo2-dev \
libjpeg-dev \
libpango1.0-dev \
libgif-dev \
openssl \
libssl-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Set Python 3 as the default python
RUN ln -s /usr/bin/python3 /usr/bin/python
RUN ln -sf /usr/bin/python3 /usr/bin/python

# Set the working directory
WORKDIR /app

# Copy package.json and other configuration files
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc turbo.json ./
# Copy application code
COPY . .

# Copy the rest of the application code
COPY agent ./agent
COPY packages ./packages
COPY scripts ./scripts
COPY characters ./characters
# Install dependencies
RUN pnpm install --no-frozen-lockfile

# Install dependencies and build the project
RUN pnpm install \
&& pnpm build-docker \
&& pnpm prune --prod
# Build the project
RUN pnpm run build && pnpm prune --prod

# Create a new stage for the final image
# Final runtime image
FROM node:23.3.0-slim

# Install runtime dependencies if needed
# Install runtime dependencies
RUN npm install -g pnpm@9.4.0 && \
apt-get update && \
apt-get install -y git python3 && \
apt-get install -y \
git \
python3 \
ffmpeg && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Set the working directory
WORKDIR /app

# Copy built artifacts and production dependencies from the builder stage
Expand All @@ -47,9 +66,14 @@ COPY --from=builder /app/.npmrc ./
COPY --from=builder /app/turbo.json ./
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/agent ./agent
COPY --from=builder /app/client ./client
COPY --from=builder /app/lerna.json ./
COPY --from=builder /app/packages ./packages
COPY --from=builder /app/scripts ./scripts
COPY --from=builder /app/characters ./characters

# Set the command to run the application
CMD ["pnpm", "start"]
# Expose necessary ports
EXPOSE 3000 5173

# Command to start the application
CMD ["sh", "-c", "pnpm start & pnpm start:client"]
36 changes: 8 additions & 28 deletions Dockerfile.docs
Original file line number Diff line number Diff line change
@@ -1,63 +1,43 @@
# syntax=docker/dockerfile:1

## Modified version of https://docusaurus.community/knowledge/deployment/docker/

# Stage 1: Base image.
## Start with a base image containing NodeJS so we can build Docusaurus.
FROM node:23.3.0-slim AS base
## Disable colour output from yarn to make logs easier to read.

## https://pnpm.io/docker
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"

ENV FORCE_COLOR=0
## Enable corepack.
RUN corepack enable
## Set the working directory to `/opt/docusaurus`.
WORKDIR /opt/docusaurus

## Required by docusaurus: [ERROR] Loading of version failed for version current
RUN apt-get update && apt-get install -y git

# Stage 2a: Development mode.
FROM base AS dev
## Set the working directory to `/opt/docusaurus`.
WORKDIR /opt/docusaurus
## Expose the port that Docusaurus will run on.
EXPOSE 3000
## Run the development server.
CMD [ -d "node_modules" ] && npm run start -- --host 0.0.0.0 --poll 1000 || pnpm install && pnpm run start -- --host 0.0.0.0 --poll 1000
CMD [ -d "node_modules" ] && pnpm start -- --host 0.0.0.0 --poll 1000 || pnpm install && pnpm start -- --host 0.0.0.0 --poll 1000

# Stage 2b: Production build mode.
FROM base AS preprod
FROM base AS prod
## Set the working directory to `/opt/docusaurus`.
WORKDIR /opt/docusaurus

## This is in case someone needs to build the lock file
#RUN apt install python-is-python3 g++ make -y

COPY docs/package.json /opt/docusaurus/package.json
COPY docs/package-lock.json /opt/docusaurus/package-lock.json

FROM preprod AS prod

## Install dependencies with `--immutable` to ensure reproducibility.
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install

## Copy over the source code.
COPY docs/ /opt/docusaurus/
COPY packages/ /opt/packages/

## Required buy docusaurus [ERROR] Loading of version failed for version current
COPY .git/ /opt/.git/

# Build from sources
RUN pnpm run build
## Install dependencies with `--frozen-lockfile` to ensure reproducibility.
RUN pnpm install --no-frozen-lockfile
## Build the static site.
RUN pnpm build

# Stage 3a: Serve with `docusaurus serve`.
FROM prod AS serve
## Expose the port that Docusaurus will run on.
EXPOSE 3000
## Run the production server.
CMD ["npm", "run", "serve", "--", "--host", "0.0.0.0", "--no-open"]

CMD ["pnpm", "run", "serve", "--host", "0.0.0.0", "--no-open"]
1 change: 1 addition & 0 deletions agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"@elizaos/plugin-avalanche": "workspace:*",
"@elizaos/plugin-video-generation": "workspace:*",
"@elizaos/plugin-web-search": "workspace:*",
"@elizaos/plugin-dexscreener": "workspace:*",
"@elizaos/plugin-letzai": "workspace:*",
"@elizaos/plugin-thirdweb": "workspace:*",
"@elizaos/plugin-genlayer": "workspace:*",
Expand Down
10 changes: 8 additions & 2 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ import { coinmarketcapPlugin } from "@elizaos/plugin-coinmarketcap";
import { confluxPlugin } from "@elizaos/plugin-conflux";
import { createCosmosPlugin } from "@elizaos/plugin-cosmos";
import { cronosZkEVMPlugin } from "@elizaos/plugin-cronoszkevm";
import { echoChambersPlugin } from "@elizaos/plugin-echochambers";
import { evmPlugin } from "@elizaos/plugin-evm";
import { flowPlugin } from "@elizaos/plugin-flow";
import { fuelPlugin } from "@elizaos/plugin-fuel";
Expand Down Expand Up @@ -100,6 +99,9 @@ import { thirdwebPlugin } from "@elizaos/plugin-thirdweb";
import { tonPlugin } from "@elizaos/plugin-ton";
import { squidRouterPlugin } from "@elizaos/plugin-squid-router";
import { webSearchPlugin } from "@elizaos/plugin-web-search";
import { echoChambersPlugin } from "@elizaos/plugin-echochambers";
import { dexScreenerPlugin } from "@elizaos/plugin-dexscreener";

import { zksyncEraPlugin } from "@elizaos/plugin-zksync-era";
import Database from "better-sqlite3";
import fs from "fs";
Expand All @@ -108,6 +110,7 @@ import path from "path";
import { fileURLToPath } from "url";
import yargs from "yargs";


const __filename = fileURLToPath(import.meta.url); // get the resolved path to the file
const __dirname = path.dirname(__filename); // get the name of the directory

Expand Down Expand Up @@ -419,7 +422,7 @@ export function getTokenForProvider(
);
case ModelProviderName.OPENROUTER:
return (
character.settings?.secrets?.OPENROUTER ||
character.settings?.secrets?.OPENROUTER_API_KEY ||
settings.OPENROUTER_API_KEY
);
case ModelProviderName.GROK:
Expand Down Expand Up @@ -771,6 +774,9 @@ export async function createAgent(
// character.plugins are handled when clients are added
plugins: [
bootstrapPlugin,
getSecret(character, "DEXSCREENER_API_KEY")
? dexScreenerPlugin
: null,
getSecret(character, "CONFLUX_CORE_PRIVATE_KEY")
? confluxPlugin
: null,
Expand Down
10 changes: 6 additions & 4 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
services:
tee:
eliza:
build:
context: .
dockerfile: Dockerfile
stdin_open: true
tty: true
volumes:
- /var/run/tappd.sock:/var/run/tappd.sock
- tee:/app/packages/client-twitter/src/tweetcache
- tee:/app/db.sqlite
- eliza:/app/packages/client-twitter/src/tweetcache
- eliza:/app/db.sqlite
environment:
- OPENAI_API_KEY=
- REDPILL_API_KEY=
Expand All @@ -32,9 +32,11 @@ services:
- HELIUS_API_KEY=
- SERVER_PORT=3000
- WALLET_SECRET_SALT=secret_salt
# Refer to: https://github.com/elizaOS/eliza/blob/develop/.env.example for all available environment variables
ports:
- "3000:3000"
- "5173:5173"
restart: always

volumes:
tee:
eliza:
18 changes: 9 additions & 9 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
"write-heading-ids": "docusaurus write-heading-ids"
},
"dependencies": {
"@docusaurus/core": "3.6.3",
"@docusaurus/plugin-content-blog": "3.6.3",
"@docusaurus/plugin-content-docs": "3.6.3",
"@docusaurus/plugin-ideal-image": "3.6.3",
"@docusaurus/preset-classic": "3.6.3",
"@docusaurus/theme-mermaid": "3.6.3",
"@docusaurus/theme-common": "3.6.3",
"@docusaurus/core": "3.7.0",
"@docusaurus/plugin-content-blog": "3.7.0",
"@docusaurus/plugin-content-docs": "3.7.0",
"@docusaurus/plugin-ideal-image": "3.7.0",
"@docusaurus/preset-classic": "3.7.0",
"@docusaurus/theme-mermaid": "3.7.0",
"@docusaurus/theme-common": "3.7.0",
"@mdx-js/react": "3.0.1",
"clsx": "2.1.1",
"docusaurus-lunr-search": "3.5.0",
Expand All @@ -34,8 +34,8 @@
"react-router-dom": "6.22.1"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "3.6.3",
"@docusaurus/types": "3.6.3",
"@docusaurus/module-type-aliases": "3.7.0",
"@docusaurus/types": "3.7.0",
"docusaurus-plugin-typedoc": "1.0.5",
"typedoc": "0.26.11",
"typedoc-plugin-markdown": "4.2.10"
Expand Down
1 change: 0 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"@rollup/plugin-terser": "0.1.0",
"@rollup/plugin-typescript": "11.1.6",
"@solana/web3.js": "1.95.8",
"@tavily/core": "^0.0.2",
"@types/fluent-ffmpeg": "2.1.27",
"@types/jest": "29.5.14",
"@types/mocha": "10.0.10",
Expand Down
25 changes: 1 addition & 24 deletions packages/core/src/generation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import {
ModelClass,
ModelProviderName,
ServiceType,
SearchResponse,
ActionResponse,
IVerifiableInferenceAdapter,
VerifiableInferenceOptions,
Expand All @@ -51,7 +50,7 @@ import {
TokenizerType,
} from "./types.ts";
import { fal } from "@fal-ai/client";
import { tavily } from "@tavily/core";

import BigNumber from "bignumber.js";
import {createPublicClient, http} from "viem";

Expand Down Expand Up @@ -1818,28 +1817,6 @@ export const generateCaption = async (
};
};

export const generateWebSearch = async (
query: string,
runtime: IAgentRuntime
): Promise<SearchResponse> => {
try {
const apiKey = runtime.getSetting("TAVILY_API_KEY") as string;
if (!apiKey) {
throw new Error("TAVILY_API_KEY is not set");
}
const tvly = tavily({ apiKey });
const response = await tvly.search(query, {
includeAnswer: true,
maxResults: 3, // 5 (default)
topic: "general", // "general"(default) "news"
searchDepth: "basic", // "basic"(default) "advanced"
includeImages: false, // false (default) true
});
return response;
} catch (error) {
elizaLogger.error("Error:", error);
}
};
/**
* Configuration options for generating objects with a model.
*/
Expand Down
23 changes: 1 addition & 22 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1418,28 +1418,6 @@ export interface ITeeLogService extends Service {
): Promise<boolean>;
}

export type SearchImage = {
url: string;
description?: string;
};

export type SearchResult = {
title: string;
url: string;
content: string;
rawContent?: string;
score: number;
publishedDate?: string;
};

export type SearchResponse = {
answer?: string;
query: string;
responseTime: number;
images: SearchImage[];
results: SearchResult[];
};

export enum ServiceType {
IMAGE_DESCRIPTION = "image_description",
TRANSCRIPTION = "transcription",
Expand All @@ -1456,6 +1434,7 @@ export enum ServiceType {
IRYS = "irys",
TEE_LOG = "tee_log",
GOPLUS_SECURITY = "goplus_security",
WEB_SEARCH = "web_search",
}

export enum LoggingLevel {
Expand Down
Loading

0 comments on commit 3a7f800

Please sign in to comment.