-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathgemini.clj
More file actions
37 lines (33 loc) · 1.32 KB
/
Copy pathgemini.clj
File metadata and controls
37 lines (33 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
(ns simulflow-examples.gemini
(:require
[clojure.core.async :as a]
[clojure.core.async.flow :as flow]
[simulflow-examples.local :as local]
[simulflow.async :refer [vthread-loop]]
[simulflow.processors.google :as google]
[simulflow.secrets :refer [secret]]
[simulflow.vad.silero :as silero]
[taoensso.telemere :as t]))
(comment
(def local-flow-gemini
(local/make-local-flow {:extra-procs {:llm {:proc google/google-llm-process
:args {:llm/model :gemini-2.0-flash
:google/api-key (secret [:google :api-key])}}}
:vad-analyser (silero/create-silero-vad)}))
(defonce flow-started? (atom false))
;; Start local ai flow - starts paused
(let [{:keys [report-chan error-chan]} (flow/start local-flow-gemini)]
(reset! flow-started? true)
;; Resume local ai -> you can now speak with the AI
(flow/resume local-flow-gemini)
(vthread-loop []
(when @flow-started?
(when-let [[msg c] (a/alts!! [report-chan error-chan])]
(when (map? msg)
(t/log! {:level :debug :id (if (= c error-chan) :error :report)} msg))
(recur)))))
;; Stop the conversation
(do
(flow/stop local-flow-gemini)
(reset! flow-started? false))
,)