|
309 | 309 | "\n", |
310 | 310 | "4. It retrieves the content of the first choice from the response and splits it into an array of strings using `Environment.NewLine` as the separator. This array represents the generated search queries.\n", |
311 | 311 | "\n", |
312 | | - "Finally, the method returns the array of generated search queries.\n", |
313 | | - "\n", |
314 | | - "In terms of improvements, the code is quite efficient and readable as it is. However, you might consider adding comments to explain what each line of code does, especially if this code will be read by others who may not be familiar with the OpenAI API or the concept of query rewriting." |
| 312 | + "Finally, it returns the array of generated search queries.\n", |
| 313 | + "\n" |
315 | 314 | ] |
316 | 315 | }, |
317 | 316 | { |
|
449 | 448 | "source": [ |
450 | 449 | "The `SearchAsync` function is used to perform a search given a query and a collection of knowledge. It takes three parameters: `query` which is a string representing the search query, `knowledge` which is a collection of `PageBlockWithEmbeddings` objects representing the knowledge base, and `resultCount` which is an optional parameter that defaults to 5 and represents the number of search results to return.\n", |
451 | 450 | "\n", |
452 | | - "Inside the method, several operations are performed:\n", |
| 451 | + "This is what happens in the function:\n", |
453 | 452 | "\n", |
454 | 453 | "1. It retrieves the embedding for the query using the `GetEmbeddingsAsync` method of the `client` object and stores it in `queryEmbedding`.\n", |
455 | 454 | "\n", |
|
463 | 462 | "\n", |
464 | 463 | "6. It scores the `retrievedFacts` by similarity to the `queryEmbedding`, filters out items with a score less than 0.8, takes the top `resultCount` items, and transforms them into `SearchResult` objects. This part is usually referred to as re-ranking.\n", |
465 | 464 | "\n", |
466 | | - "Finally, the method returns the resulting collection of `SearchResult` objects.\n", |
467 | | - "\n", |
468 | | - "In terms of improvements, the code is quite efficient and readable as it is. However, you might consider adding comments to explain what each line of code does, especially if this code will be read by others who may not be familiar with embeddings or query rewriting." |
| 465 | + "Finally, it returns the resulting collection of `SearchResult` objects." |
469 | 466 | ] |
470 | 467 | }, |
471 | 468 | { |
|
0 commit comments