sublayerapp / sublayer

A model-agnostic Ruby Generative AI DSL and framework. Provides base classes for building Generators, Actions, Tasks, and Agents that can be used to build AI powered applications in Ruby.
https://docs.sublayer.com
MIT License
119 stars 2 forks source link

Mechanism to use a different model from the same provider #19

Open swerner opened 7 months ago

swerner commented 7 months ago

For example, being able to optionally choose between using gpt-3.5 for something, using gpt-4-turbo for others, or between using claude-haiku for some and claude-opus for others if you want, but for the majority of cases being able to mostly rely on the defaults.

swerner commented 7 months ago

Maybe this makes sense to put in the output adapter rather than the generator? Some other thing? It seems tied to the output and/or input to figure out which model (and maybe) which provider to use?

swerner commented 3 months ago

Thinking maybe there's a pattern similar to how activerecord models have overloaded find methods. If we overloaded the generate method with being able to accept some parameters we could expand the functionality of it...thinking something like:

Sublayer.configuration.ai_model = "claude-3-5-sonnet-20240620"

claude_results = MyGenerator.new(my_param: my_param).generate
gemini_flash_results = MyGenerator.new(my_param: my_param).generate(model: "gemini-1.5-flash-latest")
gpt4o_results = MyGenerator.new(my_param: my_param).generate(model: "gpt-4o")

It would probably make sense to have default mappings of models to providers like we're discussing in #85 to make this cleaner while still allowing you to override the default provider class if needed.

AndrewBKang commented 3 months ago

this is very cool. all the control and a nice optional named param off of a convention that can be expanded for other kinds of provider configs in the future)