patterns-ai-core / langchainrb_rails

MIT License
168 stars 20 forks source link

Prompt Template integration #97

Open andreibondarev opened 3 weeks ago

andreibondarev commented 3 weeks ago

langchainrb offers a way to manage prompt templates: https://github.com/patterns-ai-core/langchainrb?tab=readme-ov-file#prompt-templates. It offers a way to save templates to json or yaml files but to a database. Keeping prompts in a database table allows you to modify prompts on the fly and version them if needed.

sergiobayona commented 3 weeks ago

possible api:

Prompt is an ActiveRecord model.

Creates instance of a prompt:

p = Prompt.new(template: "Tell me a {adjective} joke about {subject}.")
p.save # persist to db

Renders prompt template:

p.render({adjective: "funny", subject: "birds"})
# => "Tell me a funny joke about birds"

Return the template variables:

p.template_variables 
# => ['adjective', 'subject']
andreibondarev commented 3 weeks ago

@sergiobayona Makes sense to me!

sergiobayona commented 2 weeks ago

see https://github.com/patterns-ai-core/langchainrb_rails/pull/101