Skip to content

Conversation

yu-iskw
Copy link
Contributor

@yu-iskw yu-iskw commented Oct 28, 2024

Overview

It would be good to support Google AI Studio in addition to Vertex AI, as Google AI Studio offers the free tier to call APIs. Developers can try PR Agent with it for free.

Test

I implemented a python script to locally test the implemented feature for my own repository. I got the generated comment in the subsequent pull request.

yu-iskw/dbt-artifacts-parser#123 (comment)

from pr_agent import cli
from pr_agent.config_loader import get_settings


def main():
    # Fill in the following values
    provider = "github"  # github/gitlab/bitbucket/azure_devops
    user_token = "..."  #  user token
    gemini_api_key = "..."  # Gemini API Key
    pr_url = (
        "https://github.com/yu-iskw/dbt-artifacts-parser/pull/123"  # PR URL, for example 'https://github.com/Codium-ai/pr-agent/pull/809'
    )
    command = "/review"  # Command to run (e.g. '/review', '/describe', '/ask="What is the purpose of this PR?"', ...)

    # Setting the configurations
    get_settings().set("CONFIG.git_provider", provider)
    get_settings().set("CONFIG.model", "gemini/gemini-1.5-flash")
    get_settings().set("CONFIG.model_turbo", "gemini/gemini-1.5-flash")
    get_settings().set("GOOGLE_AI_STUDIO.GEMINI_API_KEY", gemini_api_key)
    get_settings().set("github.user_token", user_token)

    # Run the command. Feedback will appear in GitHub PR comments
    cli.run_command(pr_url, command)


if __name__ == "__main__":
    main()
$ python test_gemini.py 

2024-10-29 07:07:47.996 | INFO     | pr_agent.tools.pr_reviewer:run:122 - Reviewing PR: https://github.com/yu-iskw/dbt-artifacts-parser/pull/123 ...
2024-10-29 07:07:47.997 | INFO     | pr_agent.git_providers.git_provider:get_user_description:89 - Existing description was not generated by the pr-agent
2024-10-29 07:07:49.738 | INFO     | pr_agent.algo.pr_processing:get_pr_diff:72 - PR main language: Other
2024-10-29 07:07:49.740 | INFO     | pr_agent.algo.pr_processing:get_pr_diff:83 - Tokens: 1771, total tokens under limit: 32000, returning full diff.
2024-10-29 07:07:51.809 | INFO     | pr_agent.tools.pr_reviewer:set_review_labels:440 - Setting review labels:
['Review effort [1-5]: 1', 'dependencies', 'python']

Reference

Signed-off-by: Yu Ishikawa <yu-iskw@users.noreply.github.com>
@yu-iskw yu-iskw marked this pull request as ready for review October 28, 2024 23:05
@mrT23
Copy link
Collaborator

mrT23 commented Oct 29, 2024

looks good, with documentation and everything :-)

Thanks

@mrT23 mrT23 merged commit 7186bf4 into qodo-ai:main Oct 29, 2024
@yu-iskw yu-iskw deleted the support-google-ai-studio branch October 30, 2024 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants