Skip to content

Commit 645dc9e

Browse files
authored
Merge pull request elizaOS#1805 from elizaOS/tcm-refactor-modelConfig
feat: refactor model config
2 parents 09517c5 + f5103f5 commit 645dc9e

File tree

10 files changed

+1048
-658
lines changed

10 files changed

+1048
-658
lines changed

README.md

+149-149
Original file line numberDiff line numberDiff line change
@@ -1,149 +1,149 @@
1-
# Eliza 🤖
2-
3-
<div align="center">
4-
<img src="./docs/static/img/eliza_banner.jpg" alt="Eliza Banner" width="100%" />
5-
</div>
6-
7-
<div align="center">
8-
9-
📖 [Documentation](https://elizaos.github.io/eliza/) | 🎯 [Examples](https://github.com/thejoven/awesome-eliza)
10-
11-
</div>
12-
13-
## 🌍 README Translations
14-
15-
[中文说明](./README_CN.md) | [日本語の説明](./README_JA.md) | [한국어 설명](./README_KOR.md) | [Français](./README_FR.md) | [Português](./README_PTBR.md) | [Türkçe](./README_TR.md) | [Русский](./README_RU.md) | [Español](./README_ES.md) | [Italiano](./README_IT.md) | [ไทย](./README_TH.md) | [Deutsch](./README_DE.md) | [Tiếng Việt](./README_VI.md) | [עִברִית](https://github.com/elizaos/Elisa/blob/main/README_HE.md) | [Tagalog](./README_TG.md) | [Polski](./README_PL.md) | [Arabic](./README_AR.md) | [Hungarian](./README_HU.md) | [Srpski](./README_RS.md) | [Română](./README_RO.md)
16-
17-
## 🚩 Overview
18-
19-
<div align="center">
20-
<img src="./docs/static/img/eliza_diagram.jpg" alt="Eliza Diagram" width="100%" />
21-
</div>
22-
23-
## ✨ Features
24-
25-
- 🛠️ Full-featured Discord, Twitter and Telegram connectors
26-
- 🔗 Support for every model (Llama, Grok, OpenAI, Anthropic, etc.)
27-
- 👥 Multi-agent and room support
28-
- 📚 Easily ingest and interact with your documents
29-
- 💾 Retrievable memory and document store
30-
- 🚀 Highly extensible - create your own actions and clients
31-
- ☁️ Supports many models (local Llama, OpenAI, Anthropic, Groq, etc.)
32-
- 📦 Just works!
33-
34-
## Video Tutorials
35-
36-
[AI Agent Dev School](https://www.youtube.com/watch?v=ArptLpQiKfI&list=PLx5pnFXdPTRzWla0RaOxALTSTnVq53fKL)
37-
38-
## 🎯 Use Cases
39-
40-
- 🤖 Chatbots
41-
- 🕵️ Autonomous Agents
42-
- 📈 Business Process Handling
43-
- 🎮 Video Game NPCs
44-
- 🧠 Trading
45-
46-
## 🚀 Quick Start
47-
48-
### Prerequisites
49-
50-
- [Python 2.7+](https://www.python.org/downloads/)
51-
- [Node.js 23+](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
52-
- [pnpm](https://pnpm.io/installation)
53-
54-
> **Note for Windows Users:** [WSL 2](https://learn.microsoft.com/en-us/windows/wsl/install-manual) is required.
55-
56-
### Use the Starter (Recommended)
57-
58-
```bash
59-
git clone https://github.com/elizaos/eliza-starter.git
60-
cd eliza-starter
61-
cp .env.example .env
62-
pnpm i && pnpm build && pnpm start
63-
```
64-
65-
Once the agent is running, you should see the message to run "pnpm start:client" at the end.
66-
Open another terminal and move to same directory and then run below command and follow the URL to chat to your agent.
67-
68-
```bash
69-
pnpm start:client
70-
```
71-
72-
Then read the [Documentation](https://elizaos.github.io/eliza/) to learn how to customize your Eliza.
73-
74-
### Manually Start Eliza (Only recommended if you know what you are doing)
75-
76-
```bash
77-
# Clone the repository
78-
git clone https://github.com/elizaos/eliza.git
79-
80-
# Checkout the latest release
81-
# This project iterates fast, so we recommend checking out the latest release
82-
git checkout $(git describe --tags --abbrev=0)
83-
```
84-
85-
### Start Eliza with Gitpod
86-
87-
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/elizaos/eliza/tree/main)
88-
89-
### Edit the .env file
90-
91-
Copy .env.example to .env and fill in the appropriate values.
92-
93-
```
94-
cp .env.example .env
95-
```
96-
97-
Note: .env is optional. If you're planning to run multiple distinct agents, you can pass secrets through the character JSON
98-
99-
### Automatically Start Eliza
100-
101-
This will run everything to set up the project and start the bot with the default character.
102-
103-
```bash
104-
sh scripts/start.sh
105-
```
106-
107-
### Edit the character file
108-
109-
1. Open `packages/core/src/defaultCharacter.ts` to modify the default character. Uncomment and edit.
110-
111-
2. To load custom characters:
112-
- Use `pnpm start --characters="path/to/your/character.json"`
113-
- Multiple character files can be loaded simultaneously
114-
3. Connect with X (Twitter)
115-
- change `"clients": []` to `"clients": ["twitter"]` in the character file to connect with X
116-
117-
### Manually Start Eliza
118-
119-
```bash
120-
pnpm i
121-
pnpm build
122-
pnpm start
123-
124-
# The project iterates fast, sometimes you need to clean the project if you are coming back to the project
125-
pnpm clean
126-
```
127-
128-
#### Additional Requirements
129-
130-
You may need to install Sharp. If you see an error when starting up, try installing it with the following command:
131-
132-
```
133-
pnpm install --include=optional sharp
134-
```
135-
136-
### Community & contact
137-
138-
- [GitHub Issues](https://github.com/elizaos/eliza/issues). Best for: bugs you encounter using Eliza, and feature proposals.
139-
- [Discord](https://discord.gg/ai16z). Best for: sharing your applications and hanging out with the community.
140-
141-
## Contributors
142-
143-
<a href="https://github.com/elizaos/eliza/graphs/contributors">
144-
<img src="https://contrib.rocks/image?repo=elizaos/eliza" />
145-
</a>
146-
147-
## Star History
148-
149-
[![Star History Chart](https://api.star-history.com/svg?repos=elizaos/eliza&type=Date)](https://star-history.com/#elizaos/eliza&Date)
1+
# Eliza 🤖
2+
3+
<div align="center">
4+
<img src="./docs/static/img/eliza_banner.jpg" alt="Eliza Banner" width="100%" />
5+
</div>
6+
7+
<div align="center">
8+
9+
📖 [Documentation](https://elizaos.github.io/eliza/) | 🎯 [Examples](https://github.com/thejoven/awesome-eliza)
10+
11+
</div>
12+
13+
## 🌍 README Translations
14+
15+
[中文说明](./README_CN.md) | [日本語の説明](./README_JA.md) | [한국어 설명](./README_KOR.md) | [Français](./README_FR.md) | [Português](./README_PTBR.md) | [Türkçe](./README_TR.md) | [Русский](./README_RU.md) | [Español](./README_ES.md) | [Italiano](./README_IT.md) | [ไทย](./README_TH.md) | [Deutsch](./README_DE.md) | [Tiếng Việt](./README_VI.md) | [עִברִית](https://github.com/elizaos/Elisa/blob/main/README_HE.md) | [Tagalog](./README_TG.md) | [Polski](./README_PL.md) | [Arabic](./README_AR.md) | [Hungarian](./README_HU.md) | [Srpski](./README_RS.md) | [Română](./README_RO.md)
16+
17+
## 🚩 Overview
18+
19+
<div align="center">
20+
<img src="./docs/static/img/eliza_diagram.jpg" alt="Eliza Diagram" width="100%" />
21+
</div>
22+
23+
## ✨ Features
24+
25+
- 🛠️ Full-featured Discord, Twitter and Telegram connectors
26+
- 🔗 Support for every model (Llama, Grok, OpenAI, Anthropic, etc.)
27+
- 👥 Multi-agent and room support
28+
- 📚 Easily ingest and interact with your documents
29+
- 💾 Retrievable memory and document store
30+
- 🚀 Highly extensible - create your own actions and clients
31+
- ☁️ Supports many models (local Llama, OpenAI, Anthropic, Groq, etc.)
32+
- 📦 Just works!
33+
34+
## Video Tutorials
35+
36+
[AI Agent Dev School](https://www.youtube.com/watch?v=ArptLpQiKfI&list=PLx5pnFXdPTRzWla0RaOxALTSTnVq53fKL)
37+
38+
## 🎯 Use Cases
39+
40+
- 🤖 Chatbots
41+
- 🕵️ Autonomous Agents
42+
- 📈 Business Process Handling
43+
- 🎮 Video Game NPCs
44+
- 🧠 Trading
45+
46+
## 🚀 Quick Start
47+
48+
### Prerequisites
49+
50+
- [Python 2.7+](https://www.python.org/downloads/)
51+
- [Node.js 23+](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
52+
- [pnpm](https://pnpm.io/installation)
53+
54+
> **Note for Windows Users:** [WSL 2](https://learn.microsoft.com/en-us/windows/wsl/install-manual) is required.
55+
56+
### Use the Starter (Recommended)
57+
58+
```bash
59+
git clone https://github.com/elizaos/eliza-starter.git
60+
cd eliza-starter
61+
cp .env.example .env
62+
pnpm i && pnpm build && pnpm start
63+
```
64+
65+
Once the agent is running, you should see the message to run "pnpm start:client" at the end.
66+
Open another terminal and move to same directory and then run below command and follow the URL to chat to your agent.
67+
68+
```bash
69+
pnpm start:client
70+
```
71+
72+
Then read the [Documentation](https://elizaos.github.io/eliza/) to learn how to customize your Eliza.
73+
74+
### Manually Start Eliza (Only recommended if you know what you are doing)
75+
76+
```bash
77+
# Clone the repository
78+
git clone https://github.com/elizaos/eliza.git
79+
80+
# Checkout the latest release
81+
# This project iterates fast, so we recommend checking out the latest release
82+
git checkout $(git describe --tags --abbrev=0)
83+
```
84+
85+
### Start Eliza with Gitpod
86+
87+
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/elizaos/eliza/tree/main)
88+
89+
### Edit the .env file
90+
91+
Copy .env.example to .env and fill in the appropriate values.
92+
93+
```
94+
cp .env.example .env
95+
```
96+
97+
Note: .env is optional. If you're planning to run multiple distinct agents, you can pass secrets through the character JSON
98+
99+
### Automatically Start Eliza
100+
101+
This will run everything to set up the project and start the bot with the default character.
102+
103+
```bash
104+
sh scripts/start.sh
105+
```
106+
107+
### Edit the character file
108+
109+
1. Open `packages/core/src/defaultCharacter.ts` to modify the default character. Uncomment and edit.
110+
111+
2. To load custom characters:
112+
- Use `pnpm start --characters="path/to/your/character.json"`
113+
- Multiple character files can be loaded simultaneously
114+
3. Connect with X (Twitter)
115+
- change `"clients": []` to `"clients": ["twitter"]` in the character file to connect with X
116+
117+
### Manually Start Eliza
118+
119+
```bash
120+
pnpm i
121+
pnpm build
122+
pnpm start
123+
124+
# The project iterates fast, sometimes you need to clean the project if you are coming back to the project
125+
pnpm clean
126+
```
127+
128+
#### Additional Requirements
129+
130+
You may need to install Sharp. If you see an error when starting up, try installing it with the following command:
131+
132+
```
133+
pnpm install --include=optional sharp
134+
```
135+
136+
### Community & contact
137+
138+
- [GitHub Issues](https://github.com/elizaos/eliza/issues). Best for: bugs you encounter using Eliza, and feature proposals.
139+
- [Discord](https://discord.gg/ai16z). Best for: sharing your applications and hanging out with the community.
140+
141+
## Contributors
142+
143+
<a href="https://github.com/elizaos/eliza/graphs/contributors">
144+
<img src="https://contrib.rocks/image?repo=elizaos/eliza" />
145+
</a>
146+
147+
## Star History
148+
149+
[![Star History Chart](https://api.star-history.com/svg?repos=elizaos/eliza&type=Date)](https://star-history.com/#elizaos/eliza&Date)

packages/client-discord/src/actions/chat_with_attachments.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { composeContext } from "@elizaos/core";
1+
import { composeContext, getModelSettings } from "@elizaos/core";
22
import { generateText, trimTokens } from "@elizaos/core";
3-
import { models } from "@elizaos/core";
43
import { parseJSONObjectFromText } from "@elizaos/core";
54
import {
65
Action,
@@ -185,8 +184,11 @@ const summarizeAction = {
185184

186185
let currentSummary = "";
187186

188-
const model = models[runtime.character.modelProvider];
189-
const chunkSize = model.settings.maxOutputTokens;
187+
const modelSettings = getModelSettings(
188+
runtime.character.modelProvider,
189+
ModelClass.SMALL
190+
);
191+
const chunkSize = modelSettings.maxOutputTokens;
190192

191193
state.attachmentsWithText = attachmentsWithText;
192194
state.objective = objective;

packages/client-discord/src/actions/summarize_conversation.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { composeContext } from "@elizaos/core";
1+
import { composeContext, getModelSettings } from "@elizaos/core";
22
import { generateText, splitChunks, trimTokens } from "@elizaos/core";
33
import { getActorDetails } from "@elizaos/core";
4-
import { models } from "@elizaos/core";
54
import { parseJSONObjectFromText } from "@elizaos/core";
65
import {
76
Action,
@@ -247,8 +246,11 @@ const summarizeAction = {
247246

248247
let currentSummary = "";
249248

250-
const model = models[runtime.character.settings.model];
251-
const chunkSize = model.settings.maxContextLength - 1000;
249+
const modelSettings = getModelSettings(
250+
runtime.character.modelProvider,
251+
ModelClass.SMALL
252+
);
253+
const chunkSize = modelSettings.maxOutputTokens - 1000;
252254

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

packages/client-slack/src/actions/chat_with_attachments.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
generateText,
44
trimTokens,
55
parseJSONObjectFromText,
6+
getModelSettings,
67
} from "@elizaos/core";
78
import { models } from "@elizaos/core";
89
import {
@@ -194,8 +195,11 @@ const summarizeAction: Action = {
194195

195196
let currentSummary = "";
196197

197-
const model = models[runtime.character.modelProvider];
198-
const chunkSize = model.settings.maxOutputTokens;
198+
const modelSettings = getModelSettings(
199+
runtime.character.modelProvider,
200+
ModelClass.SMALL
201+
);
202+
const chunkSize = modelSettings.maxOutputTokens;
199203

200204
currentState.attachmentsWithText = attachmentsWithText;
201205
currentState.objective = objective;

packages/client-slack/src/actions/summarize_conversation.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
splitChunks,
55
trimTokens,
66
parseJSONObjectFromText,
7+
getModelSettings,
78
} from "@elizaos/core";
89
import { models } from "@elizaos/core";
910
import { getActorDetails } from "@elizaos/core";
@@ -265,8 +266,11 @@ const summarizeAction: Action = {
265266

266267
let currentSummary = "";
267268

268-
const model = models[runtime.character.modelProvider];
269-
const chunkSize = model.settings.maxOutputTokens;
269+
const modelSettings = getModelSettings(
270+
runtime.character.modelProvider,
271+
ModelClass.SMALL
272+
);
273+
const chunkSize = modelSettings.maxOutputTokens;
270274

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

0 commit comments

Comments
 (0)