-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathgemini.clj
More file actions
43 lines (39 loc) · 1.76 KB
/
gemini.clj
File metadata and controls
43 lines (39 loc) · 1.76 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
38
39
40
41
42
43
(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]]
[taoensso.telemere :as t]))
(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])}}}
:llm-context {:messages
[{:role "system"
:content "You are a voice agent operating via phone. Be
concise in your answers. The input you receive comes from a
speech-to-text (transcription) system that isn't always
efficient and may send unclear text. Ask for
clarification when you're unsure what the person said."}]
:tools []}}))
(defonce flow-started? (atom false))
(comment
;; 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))
,)