Skip to content

Commit

Permalink
Merge pull request #1951 from JoeyKhd/fix-c3po
Browse files Browse the repository at this point in the history
fix: fixed error in C3PO and improved error handling feedback
  • Loading branch information
lalalune authored Jan 7, 2025
2 parents 0e007f2 + b6bfec4 commit b8a21a0
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 31 deletions.
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

0 comments on commit b8a21a0

Please sign in to comment.