Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Add gemini backend #52

Merged
merged 18 commits into from
Mar 12, 2024

Conversation

aislasq
Copy link
Contributor

@aislasq aislasq commented Mar 3, 2024

This is the implementation of the Gemini API.

I've been using for general questions outside neovim and it works well, I think it would greatly benefit from the custom system prompts.

  • Implement trait for new backend.
  • Update the BackendName enum with your new Backend name.
  • Update the BackendManager to provide your new backend.
  • Write tests
  • Update Readme
  • Update config

Copy link
Owner

@dustinblackman dustinblackman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there! Sorry for the late reply, weekends are generally my time for looking at open source. I'll try to get back to this one ASAP!

Thanks for the PR, this is really exciting. I haven't had the chance to play with Gemini yet, and it'll be sick for my first experience to be in Oatmeal.

Just got a few comments and questions, mostly around getting tests fixed up.

src/infrastructure/backends/gemini.rs Outdated Show resolved Hide resolved
let url = format!(
"{url}/v1beta/{model}?key={key}",
url = self.url,
model = Config::get(ConfigKey::Model),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚓 Health checks are failing due to this. I admit configuration should be injected in the backend interface rather than pulled in from a global repository, but I haven't gotten around to doing it. As this is a health check, you could hardcode the default model here and that'd be enough.

Alternatively, you could call Config::set right before calling the healthcheck function in your test and set it to model-1.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a possibility to get more info on the test? I am doing the Config::set in the test exactly as you mentioned:
https://github.com/aislasq/oatmeal/blob/5f4fd4f89b0634060e456ef9b3e4144167ddfeee/src/infrastructure/backends/gemini_test.rs#L54

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The github actions test suite is using nextest, this runs tests in parallel process' where memory will be different for each test. You have Config:set being used in one test, but it's gotta be use in all your healthcheck tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, let me check the linter so you can re-run the tests. Thanks!

src/infrastructure/backends/gemini_test.rs Outdated Show resolved Hide resolved
config.example.toml Outdated Show resolved Hide resolved
@aislasq
Copy link
Contributor Author

aislasq commented Mar 10, 2024

The lint is failing because my formatter is changing it on save, I am using rustfmt 1.6.0-stable (79e9716c 2023-11-13). Should I use a different one?

@dustinblackman
Copy link
Owner

The lint is failing because my formatter is changing it on save, I am using rustfmt 1.6.0-stable (79e9716c 2023-11-13). Should I use a different one?

The project is using a nightly version of rustfmt to gain access to other features I wanted. You can run cargo cmd lint-fix to fix everything before committing. If the command fails, you may need to take a look at the setup guide to get all the dependencies setup, otherwise I should have a devcontainer available tomorrow if that's a workflow you enjoy using. :)

Copy link
Owner

@dustinblackman dustinblackman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really appreciate this, code looks great and I'm excited to play with it more. Great job!

@dustinblackman dustinblackman merged commit 55f7e7d into dustinblackman:main Mar 12, 2024
3 checks passed
@aislasq aislasq deleted the feature/backend-gemini branch March 17, 2024 20:13
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