gofireflyio / aiac

Artificial Intelligence Infrastructure-as-Code Generator.
Apache License 2.0
3.52k stars 276 forks source link

Add ollama backend #86

Closed usey11 closed 4 months ago

usey11 commented 9 months ago

For some use-cases using an external API may be too expensive or unsafe. Using Ollama as a backend allows you to run use aiac completely locally.

ghost commented 9 months ago
👇 Click on the image for a new way to code review #### [![Review these changes using an interactive CodeSee Map](https://s3.us-east-2.amazonaws.com/maps.codesee.io/images/github/gofireflyio/aiac/86/85bb387f/9b700bb5a218bb91d4af422117f01280806c0cd8.svg)](https://app.codesee.io/r/reviews?pr=86&src=https%3A%2F%2Fgithub.com%2Fgofireflyio%2Faiac) #### Legend CodeSee Map legend
ido50 commented 9 months ago

Oh damn, I just opened a PR for this, didn't notice this one...

My version has the benefit of not importing the ollama codebase, so we're not taking a large hit on dependencies. Your version has the benefit of returning actual supported models in ListModels (mine are hardcoded). Only problem is that it panics in case of errors, but I guess you had no choice, the interface doesn't call for errors.

I'll keep this open and perhaps rebase the model-related code on top of mine. I just need to figure out if and how to change the interface so that we don't panic.

Thanks a lot for your contribution, regardless.

usey11 commented 9 months ago

Nice! I think for Ollama having the actual models is more important in comparison to OpenAI and Bedrock due to how many models are available and ollama also allows users to add customized models

ido50 commented 9 months ago

Yep, it's kinda how Bedrock works too, by the way. I've been rethinking whether hard coding the list of supported models makes sense since Bedrock support was added. On the one hand, it allows us to cherry-pick models, those that are actually geared towards code generation so we can maintain a high quality of results. On the other hand, it forces us to release new versions of aiac when models are added and it removes a potentially beneficial flexibility.

I haven't made up my mind yet, but a combination of both might be the way to go.

ido50 commented 4 months ago

Since version 5.0.0, we finally no longer hardcode the list of models, and the ListModels method actually contacts the provider API to query for supported models. Thanks for your contribution despite this not getting in, it was helpful.