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

bigint support in logger #256

Merged
merged 2 commits into from
Nov 11, 2024
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
4 changes: 2 additions & 2 deletions packages/core/src/embedding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function getRemoteEmbedding(input: string, options: EmbeddingOptions): Pro
// Construct full URL
const fullUrl = `${baseEndpoint}/embeddings`;

console.log("Calling embedding API at:", fullUrl); // Debug log
//console.log("Calling embedding API at:", fullUrl); // Debug log

const requestOptions = {
method: "POST",
Expand Down Expand Up @@ -129,7 +129,7 @@ async function getLocalEmbedding(input: string): Promise<number[]> {

const trimmedInput = trimTokens(input, 8000, "gpt-4o-mini");
const embedding = await embeddingModel.queryEmbed(trimmedInput);
console.log("Embedding dimensions: ", embedding.length);
//console.log("Embedding dimensions: ", embedding.length);
return embedding;
}

Expand Down
10 changes: 9 additions & 1 deletion packages/core/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,20 @@ class ElizaLogger {
const c = this.#getColor(foregroundColor, backgroundColor);
// turns objects into printable strings
strings = strings.map((item) => {
if (typeof item === "object") item = JSON.stringify(item);
if (typeof item === "object") {
// Handle BigInt serialization
return JSON.stringify(item, (key, value) =>
typeof value === 'bigint'
? value.toString()
: value
);
}
return item;
});
console.log(c, strings.join(""), this.#getColorReset());
if (this.closeByNewLine) console.log("");
}

log(...strings) {
const fg = "white";
const bg = "";
Expand Down
Loading