Skip to content

Commit

Permalink
Merge pull request #256 from o-on-x/main
Browse files Browse the repository at this point in the history
bigint support in logger
  • Loading branch information
o-on-x authored Nov 11, 2024
2 parents 86d8be9 + a27ba5f commit 6f53ba0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
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

0 comments on commit 6f53ba0

Please sign in to comment.