Skip to content

Commit be45563

Browse files
authored
Merge pull request #19 from Termina/llm
llm docs; separate thinking
2 parents aa849f9 + 3067ee4 commit be45563

File tree

8 files changed

+3977
-2248
lines changed

8 files changed

+3977
-2248
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11

22
calcit.cirru -diff linguist-generated
33
yarn.lock -diff linguist-generated
4+
5+
Agents.md -diff linguist-generated
6+
llms/*.md -diff linguist-generated

Agents.md

Lines changed: 445 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

calcit.cirru

Lines changed: 2281 additions & 1952 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compact.cirru

Lines changed: 67 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
.!generateContent (.-models gen-ai)
132132
js-object (:model "\"gemini-2.5-flash-image") (:contents content)
133133
:config $ js-object
134-
:httpOptions $ js-object (:baseUrl "\"https://ja.chenyong.life")
134+
:httpOptions $ js-object (:baseUrl |https://ja.chenyong.life)
135135
:signal $ let
136136
abort $ new js/AbortController
137137
reset! *abort-control abort
@@ -164,7 +164,7 @@
164164
:examples $ []
165165
|call-genai-msg! $ %{} :CodeEntry (:doc |)
166166
:code $ quote
167-
defn call-genai-msg! (variant cursor state prompt-text search? think? d! *text) (hint-fn async)
167+
defn call-genai-msg! (variant cursor state prompt-text search? think? d! *text *thinking-text) (hint-fn async)
168168
if (nil? @*gen-ai-new)
169169
reset! *gen-ai-new $ new GoogleGenAI
170170
js-object $ :apiKey (get-gemini-key!)
@@ -200,8 +200,7 @@
200200
:thinkingBudget $ get-env "\"think-budget" (if pro? 3200 800)
201201
:includeThoughts think?
202202
js-object (:thinkingBudget 0) (:includeThoughts false)
203-
:httpOptions $ js-object
204-
:baseUrl $ get-env "\"gemini-host" "\"https://ja.chenyong.life"
203+
:httpOptions $ js-object (:baseUrl |https://ja.chenyong.life)
205204
:tools $ let
206205
t $ ->
207206
js-array
@@ -223,17 +222,19 @@
223222
js-await $ js-for-await sdk-result
224223
fn (? chunk)
225224
if (some? chunk)
226-
do
227-
swap! *text str $ let
228-
t $ either (.-text chunk) js/chunk.candidates?.[0]?.content?.parts?.[0]?.text
229-
if (nil? t) (js/console.warn "\"empty text in:" chunk)
230-
or t (-> chunk .?-promptFeedback .?-blockReason) "\"__BLANK__"
231-
d! $ :: :states-merge cursor state
232-
{} (:answer @*text) (:loading? false) (:done? false)
225+
let
226+
part js/chunk.candidates?.[0]?.content?.parts?.[0]
227+
is-thinking? $ if (some? part) (.-thought part) false
228+
t $ if (some? part) (.-text part) (.-text chunk)
229+
let
230+
text $ or t (-> chunk .?-promptFeedback .?-blockReason) |__BLANK__
231+
if is-thinking? (swap! *thinking-text str text) (swap! *text str text)
232+
d! $ :: :states-merge cursor state
233+
{} (:answer @*text) (:thinking @*thinking-text) (:loading? false) (:done? false)
233234
d! $ :: :states-merge cursor state
234-
{} (:answer @*text) (:loading? false) (:done? false)
235+
{} (:answer @*text) (:thinking @*thinking-text) (:loading? false) (:done? false)
235236
d! $ :: :states-merge cursor state
236-
{} (:answer @*text) (:loading? false) (:done? true)
237+
{} (:answer @*text) (:thinking @*thinking-text) (:loading? false) (:done? true)
237238
:examples $ []
238239
|call-imagen-4-msg! $ %{} :CodeEntry (:doc |)
239240
:code $ quote
@@ -259,7 +260,7 @@
259260
.!generateImages (.-models gen-ai)
260261
js-object (:model "\"imagen-4.0-generate-001") (:prompt prompt-text)
261262
:config $ js-object (:numberOfImages 1) (:includeRaiReason true)
262-
:httpOptions $ js-object (:baseUrl "\"https://ja.chenyong.life")
263+
:httpOptions $ js-object (:baseUrl |https://ja.chenyong.life)
263264
:signal $ let
264265
abort $ new js/AbortController
265266
reset! *abort-control abort
@@ -382,15 +383,27 @@
382383
if (:loading? state)
383384
div ({}) (memof1-call-by :abort-loading comp-abort "\"Loading...")
384385
if
385-
not $ blank? (:answer state)
386+
or
387+
not $ blank? (:answer state)
388+
not $ blank? (:thinking state)
386389
div ({})
387390
if
388-
json-pattern? $ :answer state
389-
pre $ {} (:class-name style-code-content)
390-
:inner-text $ :answer state
391-
memof1-call comp-md-block
392-
-> (:answer state) (either "\"")
393-
{} $ :class-name style-md-content
391+
not $ blank? (:thinking state)
392+
div
393+
{} $ :class-name style-thinking
394+
memof1-call comp-md-block
395+
-> (:thinking state) (either "\"")
396+
{} $ :class-name style-md-content
397+
if
398+
not $ blank? (:answer state)
399+
div ({})
400+
if
401+
json-pattern? $ :answer state
402+
pre $ {} (:class-name style-code-content)
403+
:inner-text $ :answer state
404+
memof1-call comp-md-block
405+
-> (:answer state) (either "\"")
406+
{} $ :class-name style-md-content
394407
div
395408
{} $ :class-name css/row-parted
396409
div
@@ -607,6 +620,7 @@
607620
{} $ :max-width "\"90vw"
608621
"\"&" $ {} (:color "\"#999") (:transition-duration "\"300ms")
609622
:background-color $ hsl 0 0 98
623+
:touch-action :none
610624
"\"&:hover" $ {} (:color "\"#777")
611625
:background-color $ hsl 0 0 100
612626
:examples $ []
@@ -691,23 +705,37 @@
691705
"\"&" $ {} (:border-radius 12) (:height "\"max(160px,20vh)") (:width "\"100%") (:transition-duration "\"320ms") (:border :none) (:background-color :transparent)
692706
"\"&.focus-within" $ {} (:height "\"max(240px,32vh)") (:border :none) (:box-shadow :none)
693707
:examples $ []
708+
|style-thinking $ %{} :CodeEntry (:doc |)
709+
:code $ quote
710+
defstyle style-thinking $ {}
711+
"\"&" $ {} (:max-height 200) (:overflow :auto) (:padding "\"12px 16px")
712+
:background-color $ hsl 0 0 96
713+
:font-size 12
714+
:line-height "\"1.8"
715+
:color $ hsl 0 0 50
716+
:border-radius 8
717+
:margin-bottom 12
718+
:border $ str "\"1px solid " (hsl 0 0 90)
719+
"\"& .md-p" $ {} (:margin "\"4px 0")
720+
:examples $ []
694721
|submit-message! $ %{} :CodeEntry (:doc |)
695722
:code $ quote
696723
defn submit-message! (cursor state prompt-text search? think? model d!) (hint-fn async)
697724
let
698725
*text $ atom "\""
726+
*thinking-text $ atom "\""
699727
model $ :model state
700728
try
701729
case-default model
702-
js-await $ call-genai-msg! model cursor state prompt-text search? think? d! *text
703-
:gemini-pro $ js-await (call-genai-msg! model cursor state prompt-text search? think? d! *text)
730+
js-await $ call-genai-msg! model cursor state prompt-text search? think? d! *text *thinking-text
731+
:gemini-pro $ js-await (call-genai-msg! model cursor state prompt-text search? think? d! *text *thinking-text)
704732
:flash-imagen $ js-await (call-flash-imagen-msg! model cursor state prompt-text d!)
705733
:imagen-4 $ js-await (call-imagen-4-msg! model cursor state prompt-text d!)
706-
:gemini-thinking $ js-await (call-genai-msg! model cursor state prompt-text search? think? d! *text)
707-
:gemini-flash-thinking $ js-await (call-genai-msg! model cursor state prompt-text search? think? d! *text)
708-
:gemini-flash-lite $ js-await (call-genai-msg! model cursor state prompt-text search? think? d! *text)
709-
:gemini-flash $ js-await (call-genai-msg! model cursor state prompt-text search? think? d! *text)
710-
:gemini-learnlm $ js-await (call-genai-msg! model cursor state prompt-text search? think? d! *text)
734+
:gemini-thinking $ js-await (call-genai-msg! model cursor state prompt-text search? think? d! *text *thinking-text)
735+
:gemini-flash-thinking $ js-await (call-genai-msg! model cursor state prompt-text search? think? d! *text *thinking-text)
736+
:gemini-flash-lite $ js-await (call-genai-msg! model cursor state prompt-text search? think? d! *text *thinking-text)
737+
:gemini-flash $ js-await (call-genai-msg! model cursor state prompt-text search? think? d! *text *thinking-text)
738+
:gemini-learnlm $ js-await (call-genai-msg! model cursor state prompt-text search? think? d! *text *thinking-text)
711739
:claude-3.7 $ js-await (call-anthropic-msg! cursor state prompt-text "\"claude-3-7-sonnet-20250219" false d!)
712740
:openrouter/anthropic/claude-sonnet-4 $ js-await (call-openrouter! cursor state prompt-text "\"anthropic/claude-sonnet-4" true d! *text)
713741
:openrouter/anthropic/claude-opus-4 $ js-await (call-openrouter! cursor state prompt-text "\"anthropic/claude-opus-4" true d! *text)
@@ -741,6 +769,7 @@
741769
"\"@google/genai" :refer $ GoogleGenAI Modality
742770
"\"../lib/image" :refer $ base64ToBlob
743771
"\"openai" :default OpenAI
772+
:examples $ []
744773
|app.config $ %{} :FileEntry
745774
:defs $ {}
746775
|chrome-extension? $ %{} :CodeEntry (:doc |)
@@ -757,6 +786,7 @@
757786
:examples $ []
758787
:ns $ %{} :CodeEntry (:doc |)
759788
:code $ quote (ns app.config)
789+
:examples $ []
760790
|app.main $ %{} :FileEntry
761791
:defs $ {}
762792
|*reel $ %{} :CodeEntry (:doc |)
@@ -778,7 +808,7 @@
778808
if
779809
= "\"menu-trigger" $ .-action message
780810
let
781-
content $ str "\"你扮演一个专业的工程师, 对以下内容做一下讲解, 用中文, 注意要简略, 内容注意分块.\n\n" &newline &newline (.-content message)
811+
content $ str "\"你扮演一个专业的工程师, 对以下内容做一下讲解, 用中文, 注意要简略, 内容注意分块.\n\n" &newline &newline (.-content message)
782812
store $ :store @*reel
783813
cursor $ []
784814
state0 $ get-in store ([] :states :data)
@@ -797,6 +827,11 @@
797827
js/window.addEventListener |beforeunload $ fn (event) (persist-storage!)
798828
js/window.addEventListener |visibilitychange $ fn (event)
799829
if (= "\"hidden" js/document.visibilityState) (persist-storage!)
830+
js/window.addEventListener |dblclick $ fn (event) (.!preventDefault event)
831+
js/window.addEventListener |wheel
832+
fn (event)
833+
if (.-ctrlKey event) (.!preventDefault event)
834+
js-object $ :passive false
800835
; flipped js/setInterval 60000 persist-storage!
801836
let
802837
raw $ js/localStorage.getItem (:storage-key config/site)
@@ -842,6 +877,7 @@
842877
app.config :as config
843878
"\"./calcit.build-errors" :default build-errors
844879
"\"bottom-tip" :default hud!
880+
:examples $ []
845881
|app.schema $ %{} :FileEntry
846882
:defs $ {}
847883
|store $ %{} :CodeEntry (:doc |)
@@ -853,6 +889,7 @@
853889
:examples $ []
854890
:ns $ %{} :CodeEntry (:doc |)
855891
:code $ quote (ns app.schema)
892+
:examples $ []
856893
|app.updater $ %{} :FileEntry
857894
:defs $ {}
858895
|updater $ %{} :CodeEntry (:doc |)
@@ -874,3 +911,4 @@
874911
:code $ quote
875912
ns app.updater $ :require
876913
respo.cursor :refer $ update-states update-states-merge
914+
:examples $ []

deps.cirru

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

2-
{} (:calcit-version |0.9.20)
2+
{} (:calcit-version |0.10.4)
33
:dependencies $ {} (|Respo/alerts.calcit |0.10.2)
44
|Respo/reel.calcit |main
55
|Respo/respo-markdown.calcit |0.4.11
66
|Respo/respo-ui.calcit |0.6.3
7-
|Respo/respo.calcit |0.16.21
7+
|Respo/respo.calcit |0.16.22
88
|calcit-lang/lilac |main
99
|calcit-lang/memof |main

0 commit comments

Comments
 (0)