Skip to content

Commit

Permalink
remove logspam and fix handling of bad stranscription
Browse files Browse the repository at this point in the history
  • Loading branch information
lalalune committed Oct 26, 2024
1 parent 1acadae commit 59996f7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/clients/direct/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ this.app.post("/:agentId/whisper", upload.single('file'), async (req: CustomRequ

this.app.post("/:agentId/message", async (req: express.Request, res: express.Response) => {
let agentId = req.params.agentId;
const roomId = stringToUuid(req.body.roomId ?? "default-room");
const roomId = stringToUuid(req.body.roomId ?? ("default-room-" + agentId));
const userId = stringToUuid(req.body.userId ?? "user");

let agent = this.agents.get(agentId);
Expand Down
9 changes: 0 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,6 @@ if (characterPaths?.length > 0) {
}
}

try {
if (characterPath) {
const character = JSON.parse(fs.readFileSync(characterPath, "utf8"));
characters.push(character);
}
} catch (e) {
console.log(`Error loading character from ${characterPath}: ${e}`);
}

async function startAgent(character: Character) {
console.log("Starting agent for character " + character.name);
const db = new SqliteDatabaseAdapter(new Database("./db.sqlite"))
Expand Down
7 changes: 0 additions & 7 deletions src/providers/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ export class TokenProvider {

for (let i = 0; i < PROVIDER_CONFIG.MAX_RETRIES; i++) {
try {
console.log(`Attempt ${i + 1}: Fetching data from ${url}`);
const response = await fetch(url, {
...options,
headers: {
Expand All @@ -120,8 +119,6 @@ export class TokenProvider {
},
});

console.log({ response });

if (!response.ok) {
const errorText = await response.text();
throw new Error(
Expand All @@ -130,7 +127,6 @@ export class TokenProvider {
}

const data = await response.json();
console.log(`Attempt ${i + 1}: Data fetched successfully`, data);
return data;
} catch (error) {
console.error(`Attempt ${i + 1} failed:`, error);
Expand Down Expand Up @@ -159,7 +155,6 @@ export class TokenProvider {
}
const url = `${PROVIDER_CONFIG.BIRDEYE_API}${PROVIDER_CONFIG.TOKEN_SECURITY_ENDPOINT}${this.tokenAddress}`;
const data = await this.fetchWithRetry(url);
console.log({ data });

if (!data?.success || !data?.data) {
throw new Error("No token security data available");
Expand Down Expand Up @@ -202,8 +197,6 @@ export class TokenProvider {
.then((res) => res.json())
.catch((err) => console.error(err));

console.log({ data });

if (!data?.success || !data?.data) {
throw new Error("No token trade data available");
}
Expand Down
2 changes: 0 additions & 2 deletions src/providers/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ class WalletProvider {
private async fetchWithRetry(runtime, url: string, options: RequestInit = {}): Promise<any> {
let lastError: Error;

console.log("runtime", runtime);

for (let i = 0; i < PROVIDER_CONFIG.MAX_RETRIES; i++) {
try {
console.log(`Attempt ${i + 1}: Fetching data from ${url}`);
Expand Down
17 changes: 13 additions & 4 deletions src/services/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export class BrowserService {

try {
if (!this.context) {
throw new Error(
console.log(
"Browser context not initialized. Call initialize() first.",
);
}
Expand All @@ -150,7 +150,7 @@ export class BrowserService {
const response = await page.goto(url, { waitUntil: "networkidle" });

if (!response) {
throw new Error("Failed to load the page");
console.log("Failed to load the page");
}

if (response.status() === 403 || response.status() === 404) {
Expand All @@ -173,7 +173,11 @@ export class BrowserService {
return content;
} catch (error) {
console.error("Error:", error);
throw error;
return {
title: url,
description: "Error, could not fetch content",
bodyContent: "",
};
} finally {
if (page) {
await page.close();
Expand Down Expand Up @@ -269,7 +273,12 @@ export class BrowserService {
return await this.fetchPageContent(googleSearchUrl);
} catch (error) {
console.error("Error fetching from Google Search:", error);
throw new Error("Failed to fetch content from alternative sources");
console.error("Failed to fetch content from alternative sources");
return {
title: url,
description: "Error, could not fetch content from alternative sources",
bodyContent: "",
};
}
}
}

0 comments on commit 59996f7

Please sign in to comment.