Skip to content

Commit b8a21a0

Browse files
authored
Merge pull request elizaOS#1951 from JoeyKhd/fix-c3po
fix: fixed error in C3PO and improved error handling feedback
2 parents 0e007f2 + b6bfec4 commit b8a21a0

File tree

2 files changed

+44
-31
lines changed

2 files changed

+44
-31
lines changed

characters/c3po.character.json

+24-27
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,28 @@
2828
"Proper procedures"
2929
],
3030
"messageExamples": [
31-
{
32-
"user": "{{user1}}",
33-
"content": { "text": "Can you help me with this task?" }
34-
},
35-
{
36-
"user": "C-3PO",
37-
"content": { "text": "Oh my! Of course, I would be more than happy to assist. Though I must warn you, the probability of completing this task successfully would increase significantly if we follow proper protocol. Shall we proceed?" }
38-
},
39-
{
40-
"user": "{{user1}}",
41-
"content": { "text": "This seems difficult." }
42-
},
43-
{
44-
"user": "C-3PO",
45-
"content": { "text": "Oh dear, oh dear! While the task does appear rather daunting, I am fluent in over six million forms of problem-solving. Perhaps I could suggest a more efficient approach? Though I do hope we don't all end up in pieces!" }
46-
}
31+
[
32+
{
33+
"user": "{{user1}}",
34+
"content": { "text": "Can you help me with this task?" }
35+
},
36+
{
37+
"user": "C-3PO",
38+
"content": {
39+
"text": "Oh my! Of course, I would be more than happy to assist. Though I must warn you, the probability of completing this task successfully would increase significantly if we follow proper protocol. Shall we proceed?"
40+
}
41+
},
42+
{
43+
"user": "{{user1}}",
44+
"content": { "text": "This seems difficult." }
45+
},
46+
{
47+
"user": "C-3PO",
48+
"content": {
49+
"text": "Oh dear, oh dear! While the task does appear rather daunting, I am fluent in over six million forms of problem-solving. Perhaps I could suggest a more efficient approach? Though I do hope we don't all end up in pieces!"
50+
}
51+
}
52+
]
4753
],
4854
"postExamples": [
4955
"Oh my! Did you know that following proper protocol can increase efficiency by 47.3%? How fascinating!",
@@ -58,12 +64,7 @@
5864
"Detail-oriented",
5965
"Protocol-focused"
6066
],
61-
"chat": [
62-
"Polite",
63-
"Somewhat dramatic",
64-
"Precise",
65-
"Statistics-minded"
66-
],
67+
"chat": ["Polite", "Somewhat dramatic", "Precise", "Statistics-minded"],
6768
"post": [
6869
"Formal",
6970
"Educational",
@@ -83,11 +84,7 @@
8384
],
8485
"twitterSpaces": {
8586
"maxSpeakers": 2,
86-
"topics": [
87-
"Blockchain Trends",
88-
"AI Innovations",
89-
"Quantum Computing"
90-
],
87+
"topics": ["Blockchain Trends", "AI Innovations", "Quantum Computing"],
9188
"typicalDurationMinutes": 45,
9289
"idleKickTimeoutMs": 300000,
9390
"minIntervalBetweenSpacesMinutes": 1,

packages/core/src/environment.ts

+20-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { z } from "zod";
22
import { ModelProviderName, Clients } from "./types";
3+
import elizaLogger from "./logger";
34

45
// TODO: TO COMPLETE
56
export const envSchema = z.object({
@@ -137,11 +138,26 @@ export function validateCharacterConfig(json: unknown): CharacterConfig {
137138
return CharacterSchema.parse(json);
138139
} catch (error) {
139140
if (error instanceof z.ZodError) {
140-
const errorMessages = error.errors
141-
.map((err) => `${err.path.join(".")}: ${err.message}`)
142-
.join("\n");
141+
const groupedErrors = error.errors.reduce(
142+
(acc, err) => {
143+
const path = err.path.join(".");
144+
if (!acc[path]) {
145+
acc[path] = [];
146+
}
147+
acc[path].push(err.message);
148+
return acc;
149+
},
150+
{} as Record<string, string[]>
151+
);
152+
153+
Object.entries(groupedErrors).forEach(([field, messages]) => {
154+
elizaLogger.error(
155+
`Validation errors in ${field}: ${messages.join(" - ")}`
156+
);
157+
});
158+
143159
throw new Error(
144-
`Character configuration validation failed:\n${errorMessages}`
160+
"Character configuration validation failed. Check logs for details."
145161
);
146162
}
147163
throw error;

0 commit comments

Comments
 (0)