Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fixed error in C3PO and improved error handling feedback #1951

Merged
merged 2 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 24 additions & 27 deletions characters/c3po.character.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,28 @@
"Proper procedures"
],
"messageExamples": [
{
"user": "{{user1}}",
"content": { "text": "Can you help me with this task?" }
},
{
"user": "C-3PO",
"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?" }
},
{
"user": "{{user1}}",
"content": { "text": "This seems difficult." }
},
{
"user": "C-3PO",
"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!" }
}
[
{
"user": "{{user1}}",
"content": { "text": "Can you help me with this task?" }
},
{
"user": "C-3PO",
"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?"
}
},
{
"user": "{{user1}}",
"content": { "text": "This seems difficult." }
},
{
"user": "C-3PO",
"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!"
}
}
]
],
"postExamples": [
"Oh my! Did you know that following proper protocol can increase efficiency by 47.3%? How fascinating!",
Expand All @@ -58,12 +64,7 @@
"Detail-oriented",
"Protocol-focused"
],
"chat": [
"Polite",
"Somewhat dramatic",
"Precise",
"Statistics-minded"
],
"chat": ["Polite", "Somewhat dramatic", "Precise", "Statistics-minded"],
"post": [
"Formal",
"Educational",
Expand All @@ -83,11 +84,7 @@
],
"twitterSpaces": {
"maxSpeakers": 2,
"topics": [
"Blockchain Trends",
"AI Innovations",
"Quantum Computing"
],
"topics": ["Blockchain Trends", "AI Innovations", "Quantum Computing"],
"typicalDurationMinutes": 45,
"idleKickTimeoutMs": 300000,
"minIntervalBetweenSpacesMinutes": 1,
Expand Down
24 changes: 20 additions & 4 deletions packages/core/src/environment.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { z } from "zod";
import { ModelProviderName, Clients } from "./types";
import elizaLogger from "./logger";

// TODO: TO COMPLETE
export const envSchema = z.object({
Expand Down Expand Up @@ -137,11 +138,26 @@ export function validateCharacterConfig(json: unknown): CharacterConfig {
return CharacterSchema.parse(json);
} catch (error) {
if (error instanceof z.ZodError) {
const errorMessages = error.errors
.map((err) => `${err.path.join(".")}: ${err.message}`)
.join("\n");
const groupedErrors = error.errors.reduce(
(acc, err) => {
const path = err.path.join(".");
if (!acc[path]) {
acc[path] = [];
}
acc[path].push(err.message);
return acc;
},
{} as Record<string, string[]>
);

Object.entries(groupedErrors).forEach(([field, messages]) => {
elizaLogger.error(
`Validation errors in ${field}: ${messages.join(" - ")}`
);
});

throw new Error(
`Character configuration validation failed:\n${errorMessages}`
"Character configuration validation failed. Check logs for details."
);
}
throw error;
Expand Down
Loading