Add support for documentation content exceeding token limits (#1670)

* - Add support for documentation content exceeding token limits via two phase operation:
1. Ask LLM to rank headings which are most likely to contain an answer to a user question
2. Provide the corresponding files for the LLM to search for an answer.

- Refactor of help_docs to make the code more readable
- For the purpose of getting canonical path: git providers to use default branch and not the PR's source branch.
- Refactor of token counting and making it clear on when an estimate factor will be used.

* Code review changes:
1. Correctly handle exception during retry_with_fallback_models (to allow fallback model to run in case of failure)
2. Better naming for default_branch in bitbucket cloud provider
This commit is contained in:
sharoneyal
2025-04-03 11:51:26 +03:00
committed by GitHub
parent ceaca3e621
commit 14971c4f5f
9 changed files with 505 additions and 187 deletions

View File

@ -64,9 +64,15 @@ class BitbucketServerProvider(GitProvider):
workspace_name = None
project_name = None
if not repo_git_url:
desired_branch = self.get_pr_branch()
workspace_name = self.workspace_slug
project_name = self.repo_slug
default_branch_dict = self.bitbucket_client.get_default_branch(workspace_name, project_name)
if 'displayId' in default_branch_dict:
desired_branch = default_branch_dict['displayId']
else:
get_logger().error(f"Cannot obtain default branch for workspace_name={workspace_name}, "
f"project_name={project_name}, default_branch_dict={default_branch_dict}")
return ("", "")
elif '.git' in repo_git_url and 'scm/' in repo_git_url:
repo_path = repo_git_url.split('.git')[0].split('scm/')[-1]
if repo_path.count('/') == 1: # Has to have the form <workspace>/<repo>