Fork me on GitHub
#shadow-cljs
<
2023-12-21
>
Rob Haisfield03:12:03

I’ve never used cljs, only clojure, but now that I know some JS I want to give it a shot. I want to create a shadow-cljs project and import mistralai. I cannot seem to get things working, just trying to replicate the code in the chat completions example here. It doesn’t seem to recognize the mistralai import. Can anyone advise me on how I should be setting up my shadow-cljs.edn or index.cljs file differently? https://docs.mistral.ai/platform/client

thheller06:12:38

js/ prefix is reserved for revering to global variables, and is therefore incorrect in this case. You just use MistralClient instead here, since that is the thing your required in the ns

thheller06:12:51

it is not a literal conversion of the JS variant

thheller06:12:21

also the build config is mostly nonsense, please actually follow the documentation for the specific target. you cannot just use a :browser config and swap the :target. https://shadow-cljs.github.io/docs/UsersGuide.html#target-node-script

thheller06:12:30

it only takes :main, not :modules

thheller06:12:40

and :output-to not :output-dir

thheller06:12:52

:npm-deps also has no effect there

thheller06:12:21

{:target :node-script :output-to "out/script.js" :main index/main}

Rob Haisfield14:12:04

Thank you! I’m gonna try this all out when I’m at my computer.

martinklepsch14:12:32

Besides the js-await issue I think you also want (.chat client ,,,) instead of (.-chat client ,,,) .- is for accessing properties, . is for invoking properties as functions. And probably the options passed to that function are expected to be JS so may want to wrap that map with :model in it in (clj->js ,,,)

Olav Fosse07:12:52

Hey What is the most straight forward way to use your own version of a ClojureScript dep? Say I wanna fork a repo and use my fork instead of the maven dependency. My shadow-cljs.edn looks like this

;; shadow-cljs configuration
{:source-paths
 ["cljs/"]

 :dependencies
 [[cjohansen/dumdom "2023.11.06"]
  ;; For time literals and parsing edn time literals from the backend
  [com.widdindustries/time-literals "0.1.10"]
  [tick "0.7.5"]

  ;; 
  [cider/cider-nrepl "0.44.0"]
  [refactor-nrepl/refactor-nrepl "3.9.0"]
  ]

 ;; 
 :nrepl {:middleware [cider.nrepl/cider-middleware
                      refactor-nrepl.middleware/wrap-refactor]
         :port 3012}

 :builds
 {:frontend
  {:target :browser
   :output-dir "target/resources/public/cljs"
   :asset-path "/cljs"
   :modules {:cljs {:init-fn ing.beij.cljs/init}}}}}
and i wanna replace [cjohansen/dumdom "2023.11.06"] with https://github.com/olavfosse/dumdom. Thanks!

thheller07:12:31

use deps.edn with :local/root or git dep

👍 1