Skip to content

Commit

Permalink
Fix scenario example
Browse files Browse the repository at this point in the history
  • Loading branch information
ovistoica committed Feb 17, 2025
1 parent 9b0c0b3 commit 86adfaf
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions examples/src/voice_fn_examples/scenario_example.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
[clojure.core.async.flow :as flow]
[taoensso.telemere :as t]
[voice-fn-examples.local :as local]
[voice-fn.processors.groq :as groq]
[voice-fn.scenario-manager :as sm]
[voice-fn.secrets :refer [secret]]))
[voice-fn.scenario-manager :as sm]))

(def scenario-config
{:initial-node :start
Expand Down Expand Up @@ -66,36 +64,32 @@
degrades when it has a big complex prompt to enact, so to ensure a consistent
output use scenarios that transition the LLM into a new scenario node with a clear
instruction for the current node."
[]
(let [flow (local/make-local-flow
{;; Don't add any context because the scenario will handle that
:llm/context {:messages []
:tools []}
;; add gateway process for scenario to inject frames
:extra-procs {:scenario {:proc (flow/process #'sm/scenario-in-process)}

;; Use groq instead of openai
:llm {:proc groq/groq-llm-process
:args {:api-key (secret [:groq :api-key])
:model "llama-3.3-70b-versatile"}}
([]
(scenario-example {:initial-node :start}))
([{:keys [initial-node]}]
(let [flow (local/make-local-flow
{;; Don't add any context because the scenario will handle that
:llm/context {:messages []
:tools []}
:language :ro

;; Groq has a different tool result format than openai
:context-aggregator {:args {:llm/tool-result-adapter groq/tool-result-adapter}}}
;; add gateway process for scenario to inject frames
:extra-procs {:scenario {:proc (flow/process #'sm/scenario-in-process)}}

:extra-conns [[[:scenario :speak-out] [:tts :in]]
[[:scenario :context-out] [:context-aggregator :in]]]})

s (sm/scenario-manager {:flow flow
:flow-in-coord [:scenario :scenario-in] ;; scenario-manager will inject frames through this channel
:scenario-config scenario})]
:scenario-config (assoc scenario-config :initial-node initial-node)})]

{:flow flow
:scenario s})))

(comment

;; create flow & scenario
(def s (scenario-example))
(def s (scenario-example {:initial-node :start}))

;; Start local ai flow - starts paused
(let [{:keys [report-chan error-chan]} (flow/start (:flow s))]
Expand Down

0 comments on commit 86adfaf

Please sign in to comment.