konveyor / kai

Konveyor AI - static code analysis driven migration to new targets via Generative AI
Apache License 2.0
23 stars 28 forks source link

:sparkles: Add support for google gemini model. #307

Closed Myrausman closed 2 weeks ago

Myrausman commented 3 weeks ago

Fixes #304

jwmatthews commented 3 weeks ago

@Myrausman thank you!

Quick look at the PR and looked great. I'll help run through a manual test, but I don't expect to have time to help until Wednesday.

fabianvf commented 3 weeks ago

@Myrausman Would you be able to start the server in demo mode (DEMO_MODE=true), which should dump a bunch of cached responses into kai/data/vcr/{app}/{model}, then commit those files? That will let us run some verification on our end without needing to have a valid API key

Myrausman commented 3 weeks ago

I started server in demo mode but I'm not getting any cache new response for that particular model (pro-gemini).

jwmatthews commented 3 weeks ago

I started server in demo mode but I'm not getting any cache new response for that particular model (pro-gemini).

@Myrausman did you run: https://github.com/konveyor/kai/blob/main/example/run_demo.py

To get cached responses you need to send requests to the API, so that it can cache the response. To send requests, easiest way is to use the run_demo.py against coolstore.

You can read this to learn more of how to run: https://github.com/konveyor/kai/blob/main/example/README.md

jwmatthews commented 3 weeks ago

@Myrausman this will help to give more context of updating cached responses

https://github.com/konveyor/kai/blob/main/docs/contrib/Demo_Mode.md#demo_mode-updating-cached-responses

Myrausman commented 3 weeks ago

followin this file Contributing.md, when I'm running make load-data I am getting these error:

(.venv) myra@myra-ThinkPad-T14-Gen-2i:~/extra/lfx/kai$ make load-data
PYTHONPATH="/home/myra/extra/lfx/kai/kai:" python ./kai/service/incident_store/psql.py  --config_filepath ./kai/config.toml --drop_tables False
Console logging for 'kai' is set to level 'INFO'
File logging for 'kai' is set to level 'DEBUG' writing to file: '/home/myra/extra/lfx/kai/kai/service/incident_store/../../../logs/kai_psql.log'
INFO - 2024-08-22 02:58:32,264 - kai.service.kai_application.kai_application - [  kai_application.py:54   -             __init__()] - Tracing enabled.
modelid ############################### gemini-pro
INFO - 2024-08-22 02:58:32,281 - kai.service.kai_application.kai_application - [  kai_application.py:63   -             __init__()] - Selected provider: ChatGoogleGenerativeAI
INFO - 2024-08-22 02:58:32,282 - kai.service.kai_application.kai_application - [  kai_application.py:64   -             __init__()] - Selected model: gemini-pro
INFO - 2024-08-22 02:58:32,389 - kai.service.kai_application.kai_application - [  kai_application.py:84   -             __init__()] - Selected incident store: postgresql
INFO - 2024-08-22 02:58:32,460 - kai.service.incident_store.incident_store - [   incident_store.py:91   - load_reports_from_directory()] - Loading incident store with applications: ['ejb-security', 'ejb-remote', 'kitchensink', 'bmt', 'helloworld-mdb', 'cmt', 'greeter', 'tasks-qute', 'ticket-monster']

INFO - 2024-08-22 02:58:32,461 - kai.service.incident_store.incident_store - [   incident_store.py:95   - load_reports_from_directory()] - Loading application ejb-security

Traceback (most recent call last):
  File "/home/myra/extra/lfx/kai/./kai/service/incident_store/psql.py", line 4, in <module>
    cmd("postgresql")
  File "/home/myra/extra/lfx/kai/kai/service/incident_store/incident_store.py", line 475, in cmd
    load_reports_from_directory(incident_store, args.analysis_dir_path)
  File "/home/myra/extra/lfx/kai/kai/service/incident_store/incident_store.py", line 114, in load_reports_from_directory
    repo = Repo(repo_path)
           ^^^^^^^^^^^^^^^
  File "/home/myra/extra/lfx/kai/.venv/lib/python3.11/site-packages/git/repo/base.py", line 236, in __init__
    raise NoSuchPathError(epath)
git.exc.NoSuchPathError: /home/myra/extra/lfx/kai/samples/sample_repos/ejb-security
make: *** [Makefile:22: load-data] Error 1
jwmatthews commented 3 weeks ago

I think you just need to clone a few sample repos paths

Look at this link and run the fetch_apps.py it mentions:

https://github.com/konveyor/kai/blob/main/docs/contrib/Dev_Environment.md#steps

Myrausman commented 3 weeks ago

After running python3 run_demo.py, I am getting the following output: https://gist.github.com/Myrausman/3b9112e1342baa5a9accb8cb31d913d6. I also don't see any new files from the model in this location: kai/data/vcr/{app}/{model}.

fabianvf commented 3 weeks ago

interesting, I wonder if the google library is using a different library that isn't intercepted by VCR for managing the requests

jwmatthews commented 3 weeks ago

@Myrausman please take look at the merge conflicts we will need to resolve before we can merge. We merged another PR yesterday that altered the requirements a little, so you will need to reexamine requirements.in, add your changes in, rerun pip-compile and test, then update this PR with the changes.

JonahSussman commented 2 weeks ago

@Myrausman Thank you for your contribution!