6
6
Memory ,
7
7
type Action ,
8
8
State ,
9
+ generateWebSearch ,
9
10
} from "@elizaos/core" ;
10
11
11
12
interface DiscordMessage {
@@ -219,7 +220,7 @@ export const codeAssistantAction: Action = {
219
220
}
220
221
221
222
elizaLogger . log ( "Processing development guide request:" , message ) ;
222
- console . log ( "***inside handler" ) ;
223
+ // console.log("***inside handler");
223
224
const text = message . content . text . toLowerCase ( ) ;
224
225
const isGithubIssueQuery =
225
226
text . includes ( "latest" ) &&
@@ -231,7 +232,7 @@ export const codeAssistantAction: Action = {
231
232
previousContext : state . previousMessages ?. map ( ( m ) => m . content . text ) ,
232
233
} ) ;
233
234
234
- // Handle GitHub issue queries directly, bypassing knowledge base
235
+ // Only use GitHub API for explicit GitHub queries
235
236
if ( isGithubIssueQuery ) {
236
237
try {
237
238
elizaLogger . log ( "Fetching latest GitHub issues..." ) ;
@@ -288,47 +289,57 @@ export const codeAssistantAction: Action = {
288
289
} ) ;
289
290
return ;
290
291
}
291
- }
292
-
293
- // Only proceed with knowledge base search for non-GitHub queries
294
- const knowledgeResults = await knowledgeManager . searchKnowledge (
295
- message . content . text
296
- ) ;
292
+ } else {
293
+ // For non-GitHub queries, prioritize knowledge base search
294
+ const knowledgeResults = await knowledgeManager . searchKnowledge (
295
+ message . content . text
296
+ ) ;
297
297
298
- // Then, perform web search
299
- const searchQuery = `${ message . content . text } site:elizaos.github.io/eliza OR site:github.com/elizaos/eliza` ;
300
- const searchResponse = await generateWebSearch ( searchQuery , runtime ) ;
298
+ // Then, perform web search with more targeted scope
299
+ const searchQuery = `${ message . content . text } site:elizaos.github.io/eliza OR site:github.com/elizaos/eliza/docs OR site:github.com/elizaos/eliza/wiki` ;
300
+ const searchResponse = await generateWebSearch (
301
+ searchQuery ,
302
+ runtime
303
+ ) ;
301
304
302
- let responseText = "" ;
305
+ let responseText = "" ;
303
306
304
- // If we have knowledge base results, include them first
305
- if ( knowledgeResults . length > 0 ) {
306
- responseText +=
307
- "Here's what I found in our community knowledge:\n\n" ;
308
- responseText += knowledgeResults . slice ( 0 , 3 ) . join ( "\n" ) + "\n\n" ;
309
- }
307
+ // Prioritize knowledge base results
308
+ if ( knowledgeResults . length > 0 ) {
309
+ responseText +=
310
+ "Here's what I found in our community knowledge:\n\n" ;
311
+ responseText +=
312
+ knowledgeResults . slice ( 0 , 3 ) . join ( "\n" ) + "\n\n" ;
313
+ }
310
314
311
- // Add web search results if available
312
- if ( searchResponse && searchResponse . results . length ) {
313
- responseText += searchResponse . answer
314
- ? `Here's what I found in the Eliza documentation:\n\n${ searchResponse . answer } \n\n`
315
- : "" ;
316
-
317
- responseText += `Relevant documentation and examples:\n${ searchResponse . results
318
- . map (
319
- ( result : SearchResult , index : number ) =>
320
- `${ index + 1 } . [${ result . title } ](${ result . url } )`
321
- )
322
- . join ( "\n" ) } \n\n`;
323
- }
315
+ // Add web search results if available and relevant
316
+ if ( searchResponse && searchResponse . results . length ) {
317
+ responseText += searchResponse . answer
318
+ ? `Here's what I found in the Eliza documentation:\n\n${ searchResponse . answer } \n\n`
319
+ : "" ;
320
+
321
+ responseText += `Relevant documentation and examples:\n${ searchResponse . results
322
+ . map (
323
+ ( result : SearchResult , index : number ) =>
324
+ `${ index + 1 } . [${ result . title } ](${ result . url } )`
325
+ )
326
+ . join ( "\n" ) } \n\n`;
327
+ }
324
328
325
- responseText +=
326
- `If you need more help, consider:\n` +
327
- `- Checking the Getting Started guide\n` +
328
- `- Joining our Discord community\n` +
329
- `- Opening an issue on GitHub` ;
329
+ // Add helpful suggestions only if few results found
330
+ if (
331
+ ! knowledgeResults . length &&
332
+ ( ! searchResponse || ! searchResponse . results . length )
333
+ ) {
334
+ responseText +=
335
+ `If you need more help, consider:\n` +
336
+ `- Checking the Getting Started guide\n` +
337
+ `- Joining our Discord community\n` +
338
+ `- Opening an issue on GitHub` ;
339
+ }
330
340
331
- callback ( { text : responseText } ) ;
341
+ callback ( { text : responseText } ) ;
342
+ }
332
343
} ,
333
344
examples : [
334
345
[
0 commit comments