(generate
{:sys "You are the best LLM in the world"
:examples "1"
:prompt "In one word: How are you?"
:template ["{{sys}}"
"Examples:"
"{{examples}}"
"{{prompt}}"
"{{res}}"]
:res {:llm/service :ollama
:llm/cache true
:llm/model-params {:model :llama3:latest}}})
=>
#:bosquet{:completions
{:sys "You are the best LLM in the world",
:examples "1",
:prompt "In one word: How are you?",
:template "You are the best LLM in the world\nExamples:\n1\nIn one word: How are you?\nExcellent!",
:res "Excellent!"},
:usage {:res {:prompt 17, :completion 3, :total 20}, :bosquet/total {:prompt 17, :completion 3, :total 20}},
:time 1874}
Empty string error:
(generate
{:sys "You are the best LLM in the world"
:examples ""
:prompt "In one word: How are you?"
:template ["{{sys}}"
"Examples:"
"{{examples}}"
"{{prompt}}"
"{{res}}"]
:res {:llm/service :ollama
:llm/cache true
:llm/model-params {:model :llama3:latest}}})
=>
;INFO [bosquet.llm.generator:168] - resolver: (template) => :sys
; Execution error (NullPointerException) at java.io.StringReader/<init> (StringReader.java:51).
; Cannot invoke "String.length()" because "s" is null
This happens in:
(defn- prep-graph
"Join strings if tempalte is provided as collection"
[graph available-data]
(->>
graph
(reduce-kv (fn [m k v] (assoc m k (if (vector? v) (u/join-coll v) v))) {})
(reduce-kv
(fn [m k v]
(assoc
m
k
(cond (string? v) (selmer/render v available-data) :else v)))
{})))
Specifically:
(cond (string? v) (selmer/render v available-data) :else v)
selmer/render returns nil when recieving an empty string.
and later bosquet throws exception.
Not sure if it's a bug or a feature but it was non-trivial to figure out :)
Working example:
Empty string error:
This happens in:
Specifically:
selmer/render
returns nil when recieving an empty string. and laterbosquet
throws exception.Not sure if it's a bug or a feature but it was non-trivial to figure out :)