Skip to content

Commit

Permalink
chore: remove console logs from duckduckgo search tool
Browse files Browse the repository at this point in the history
Co-Authored-By: Nicolas Arqueros <[email protected]>
  • Loading branch information
devin-ai-integration[bot] and nicarq committed Dec 16, 2024
1 parent 6dde7e1 commit 173f06f
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions apps/shinkai-tool-duckduckgo-search/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,13 @@ const getVQD = async (keywords: string): Promise<string> => {
},
});
const text = response.data;
// console.log('DuckDuckGo response HTML:', text);

// Extract vqd token using a regular expression
const vqdMatch = text.match(/vqd=\\?"([^\\"]+)\\?"/);
// console.log('vqdMatch: ', vqdMatch);
if (!vqdMatch || vqdMatch.length < 2) {
throw new Error('Failed to retrieve vqd token');
}
const vqd = vqdMatch[1];
// console.log('vqd: ', vqd);
return vqd;
};

Expand Down Expand Up @@ -72,17 +69,12 @@ const parseDuckDuckGoResponse = (response: string): SearchResult[] => {
result.title && result.description && result.url,
);

// console.log('results: ', results);
// Convert to JSON string
return results;
};

const textSearch = async (keywords: string): Promise<any[]> => {
console.log('textSearch: ', keywords);
const vqd = await getVQD(keywords);
console.log('vqd: ', vqd);
const url = new URL('https://links.duckduckgo.com/d.js');
console.log('before url.searchParams.append');
url.searchParams.append('q', keywords);
url.searchParams.append('vqd', vqd);
url.searchParams.append('kl', 'wt-wt');
Expand All @@ -92,19 +84,15 @@ const textSearch = async (keywords: string): Promise<any[]> => {
url.searchParams.append('df', '');
url.searchParams.append('ex', '-1');

console.log('before urlString');
const urlString = url.toString();
console.log('urlString: ', urlString);

await process.nextTick(() => {});
const response = await axios.get(url.toString(), {
headers: {
'Content-Type': 'application/json',
},
});
console.log('response: ', response);
const text = response.data;
console.log('DuckDuckGo search response:', text);

// Parse the response using the custom parser
const results = parseDuckDuckGoResponse(text);
Expand All @@ -119,12 +107,8 @@ export const run: Run<Configurations, Parameters, Result> = async (
_configurations: Configurations,
params: Parameters,
): Promise<Result> => {
console.log('run duckduckgo search from js', 4);
console.log('second message', 4);
console.log('params: ', params);
try {
const results = await textSearch(params.message);
console.log('results: ', results);
return { message: JSON.stringify(results) };
} catch (error) {
let errorMessage = 'An unknown error occurred';
Expand Down

0 comments on commit 173f06f

Please sign in to comment.