Skip to content

Commit

Permalink
Merge pull request #6 from Termina/gemini
Browse files Browse the repository at this point in the history
list more gemini models for picking
  • Loading branch information
NoEgAm authored Dec 20, 2024
2 parents 4cc8e17 + 9aee933 commit fe6afa9
Show file tree
Hide file tree
Showing 6 changed files with 497 additions and 428 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/upload.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ jobs:
node-version: 20
cache: 'yarn'

- uses: calcit-lang/[email protected]
with:
bundler: false
- uses: calcit-lang/[email protected]

- name: "compiles to js"
run: >
Expand Down
249 changes: 146 additions & 103 deletions calcit.cirru

Large diffs are not rendered by default.

40 changes: 22 additions & 18 deletions compact.cirru
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
recur
|call-gemini-msg! $ %{} :CodeEntry (:doc |)
:code $ quote
defn call-gemini-msg! (cursor state prompt-text d!) (hint-fn async)
defn call-gemini-msg! (variant cursor state prompt-text d!) (hint-fn async)
if-let
abort $ deref *abort-control
do (js/console.warn "\"Aborting prev") (.!abort abort)
Expand All @@ -168,7 +168,7 @@
content $ .replace prompt-text "\"{{selected}}" (or selected "\"<未找到内容>")
result $ js-await
.!post axios
str "\"https://sf.chenyong.life/v1beta/models/" (pick-model) "\":streamGenerateContent"
str "\"https://sf.chenyong.life/v1beta/models/" (pick-model variant) "\":streamGenerateContent"
js-object $ :contents
js-array $ js-object
:parts $ js-array
Expand Down Expand Up @@ -235,7 +235,7 @@
; :card-class style-card
; :backdrop-class style-backdrop
; :confirm-class style-confirm
:items $ [] (:: :item :gemini |Gemini) (:: :item :claude "\"Claude") (:: :item :deepinfra "\"Deepinfra")
:items $ [] (:: :item :gemini "|Gemini Flash") (:: :item :gemini-pro "|Gemini Pro") (:: :item :claude "\"Claude") (:: :item :deepinfra "\"Deepinfra")
:on-result $ fn (result d!)
d! cursor $ assoc state :model (nth result 1)
div
Expand All @@ -244,15 +244,6 @@
{} $ :class-name (str-spaced css/expand style-message-area)
div
{} $ :class-name (str-spaced style-message-list)
a $ {}
:inner-text $ turn-str
or (:model state) "\"Gemini"
:class-name $ str-spaced style-a-toggler css/font-fancy
:style $ {}
:opacity $ if (= model :anthropic) 1 0.3
:on-click $ fn (e d!)
; d! $ :: :change-model
.show model-plugin d!
if (:loading? state)
div ({}) (<> "\"loading..." css/font-fancy)
if
Expand All @@ -267,8 +258,19 @@
{} $ :class-name css/row-parted
span $ {}
div
{} $ :class-name (str-spaced css/row-middle)
comp-copy $ :answer state
{} $ :class-name (str-spaced css/row-middle css/gap8)
a $ {}
:inner-text $ turn-str
or (:model state) "\"Gemini Flash"
:class-name $ str-spaced style-a-toggler css/font-fancy
:style $ {}
:opacity $ if (= model :anthropic) 1 0.3
:on-click $ fn (e d!)
; d! $ :: :change-model
.show model-plugin d!
div
{} $ :class-name (str-spaced css/row-middle)
comp-copy $ :answer state
div
{} $ :class-name style-more
<> "\"Streaming..." $ str-spaced css/font-fancy
Expand Down Expand Up @@ -370,11 +372,12 @@
def pattern-spaced-code $ noted "\"temp fix of nested code block" (&raw-code "\"/\\n\\s+```/g")
|pick-model $ %{} :CodeEntry (:doc |)
:code $ quote
defn pick-model () $ get-env "\"model" "\"gemini-1.5-flash"
defn pick-model (variant)
if (= variant :pro) "\"gemini-1.5-pro" "\"gemini-2.0-flash-exp"
|style-a-toggler $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle style-a-toggler $ {}
"\"&" $ {} (:position :absolute) (:right 16) (:top 12) (:cursor :pointer)
"\"&" $ {} (:cursor :pointer)
|style-app-global $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle style-app-global $ {}
Expand All @@ -387,7 +390,7 @@
|style-clear $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle style-clear $ {}
"\"&" $ {} (:position :absolute) (:left 20) (:bottom 20) (:opacity 0.4)
"\"&" $ {} (:position :absolute) (:left 12) (:bottom 12) (:opacity 0.4) (:padding "\"4px 8px") (:display :inline-block) (:height "\"24px")
|style-md-content $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle style-md-content $ {}
Expand Down Expand Up @@ -429,7 +432,8 @@
*text $ atom "\""
try
case-default (:model state)
js-await $ call-gemini-msg! cursor state prompt-text d!
js-await $ call-gemini-msg! :flash cursor state prompt-text d!
:gemini-pro $ js-await (call-gemini-msg! :pro cursor state prompt-text d!)
:claude $ js-await (call-anthropic-msg! cursor state prompt-text d!)
:deepinfra $ js-await (call-deepinfra-msg! cursor state prompt-text d! *text)
fn (e)
Expand Down
2 changes: 1 addition & 1 deletion deps.cirru
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

{}
:calcit-version |0.9.5
:calcit-version |0.9.6
:dependencies $ {}
|calcit-lang/lilac |main
|calcit-lang/memof |main
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"dependencies": {
"@calcit/procs": "^0.9.5",
"@calcit/procs": "^0.9.6",
"@google/generative-ai": "^0.21.0",
"axios": "^1.7.7",
"axios": "^1.7.9",
"cirru-color": "^0.2.4",
"copy-text-to-clipboard": "^3.2.0"
},
"devDependencies": {
"bottom-tip": "^0.1.5",
"vite": "^5.4.8"
"vite": "^6.0.3"
},
"scripts": {
"build": "yarn vite build --base ./ && rm -rfv extension/dist && cp -vr dist extension/"
Expand Down
Loading

0 comments on commit fe6afa9

Please sign in to comment.