Skip to content

Commit

Permalink
fix: handle env using runtime getSetting function
Browse files Browse the repository at this point in the history
  • Loading branch information
shakkernerd committed Jan 3, 2025
1 parent 5f923a9 commit 7cb04dc
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions packages/core/src/generation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,22 @@ export async function generateText({
baseURL: endpoint,
fetch: async (url: string, options: any) => {
const fetching = await runtime.fetch(url, options);
if (process.env.ETERNAL_AI_LOG_REQUEST) {
elizaLogger.info("Request data: ", JSON.stringify(options, null, 2));
if (
parseBooleanFromText(
runtime.getSetting("ETERNAL_AI_LOG_REQUEST")
)
) {
elizaLogger.info(
"Request data: ",
JSON.stringify(options, null, 2)
);
const clonedResponse = fetching.clone();
clonedResponse.json().then(data => {
elizaLogger.info("Response data: ", JSON.stringify(data, null, 2));
})
clonedResponse.json().then((data) => {
elizaLogger.info(
"Response data: ",
JSON.stringify(data, null, 2)
);
});
}
return fetching;
},
Expand Down

0 comments on commit 7cb04dc

Please sign in to comment.