Skip to content

Commit

Permalink
Add prompt template
Browse files Browse the repository at this point in the history
  • Loading branch information
mattlindsey committed Jan 20, 2024
1 parent 8bd6136 commit 6330e00
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
12 changes: 6 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ GEM
ast (2.4.2)
baran (0.1.10)
base64 (0.2.0)
bigdecimal (3.1.5)
bigdecimal (3.1.6)
bindex (0.8.1)
bootsnap (1.17.1)
msgpack (~> 1.2)
Expand All @@ -100,7 +100,7 @@ GEM
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
colorize (0.8.1)
concurrent-ruby (1.2.2)
concurrent-ruby (1.2.3)
connection_pool (2.4.1)
coveralls_reborn (0.28.0)
simplecov (~> 0.22.0)
Expand Down Expand Up @@ -139,7 +139,7 @@ GEM
actionpack (>= 6.0.0)
activesupport (>= 6.0.0)
railties (>= 6.0.0)
io-console (0.7.1)
io-console (0.7.2)
irb (1.11.1)
rdoc
reline (>= 0.4.2)
Expand All @@ -149,7 +149,7 @@ GEM
json (2.7.1)
json-schema (4.0.0)
addressable (>= 2.8)
langchainrb (0.8.2)
langchainrb (0.9.0)
baran (~> 0.1.9)
colorize (~> 0.8.1)
json-schema (~> 4.0.0)
Expand All @@ -171,7 +171,7 @@ GEM
marcel (1.0.2)
matrix (0.4.2)
mini_mime (1.1.5)
minitest (5.21.1)
minitest (5.21.2)
msgpack (1.7.2)
multipart-post (2.3.0)
mutex_m (0.2.0)
Expand All @@ -196,7 +196,7 @@ GEM
nokogiri (1.16.0-x86_64-linux)
racc (~> 1.4)
parallel (1.24.0)
parser (3.3.0.3)
parser (3.3.0.4)
ast (~> 2.4.1)
racc
pg (1.5.4)
Expand Down
4 changes: 2 additions & 2 deletions app/jobs/story_create_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def perform(*args)
logger.error "Unknown LLM: #{llm_name}"
end

prompt = Langchain::Prompt::PromptTemplate.new(template: "Tell me a very short story from {mythology_name} mythology that would be appropriately titled {title}.", input_variables: ["mythology_name", "title"])
prompt_text = prompt.format(mythology_name: mythology_name, title: story.title)
template = Langchain::Prompt.load_from_path(file_path: "app/prompts/story_create_template.yaml")
prompt_text = template.format(mythology_name: mythology_name, title: story.title)
story.update(body: llm.complete(prompt: prompt_text).completion)
end
end
7 changes: 7 additions & 0 deletions app/prompts/story_create_template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

_type: prompt
template: |
Tell me a very short story from {mythology_name} mythology that would be appropriately titled {title}.
input_variables:
- mythology_name
- title

0 comments on commit 6330e00

Please sign in to comment.