Skip to content

Commit

Permalink
[Docs Agent] Bug fix - Fix the "index out of range" errors in Docs
Browse files Browse the repository at this point in the history
Agent's chat web app.
  • Loading branch information
kyolee415 committed May 12, 2024
1 parent 8824ddc commit 0b491c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,11 @@ def query_vector_store_to_build(
plain_token = 0
sources = []
final_pages = []
for i in range(max_sources):
# Quick fix: Ensure max_sources is not larger than the array size of search_result.
this_range = len(search_result)
if this_range > max_sources:
this_range = max_sources
for i in range(this_range):
# The current section that is being built
# eval turns str representation of array into an array
curr_section_id = search_result[i].section.name_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,9 @@ def ask_model(question, agent, template: str = "chatui/index.html"):
# Log debug information.

if docs_agent.config.enable_logs_for_debugging == "True":
top_source_url = search_result[0].section.url
top_source_url = ""
if len(search_result) > 0:
top_source_url = search_result[0].section.url
source_urls = ""
index = 1
for result in search_result:
Expand Down

0 comments on commit 0b491c3

Please sign in to comment.