Initial commit
This commit is contained in:
commit
7963963455
|
|
@ -0,0 +1 @@
|
||||||
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
{:paths ["src" "resources"]
|
||||||
|
:deps {}
|
||||||
|
:aliases {:test {:extra-paths ["test"]
|
||||||
|
:extra-deps {}}}}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
(ns org.aplex.helpers.core
|
||||||
|
(:require
|
||||||
|
[clojure.string :as s]))
|
||||||
|
|
||||||
|
(defn map-replace
|
||||||
|
"Given a string with {:key} strings substitute the matching key in a hash map"
|
||||||
|
[text m]
|
||||||
|
(reduce
|
||||||
|
(fn [acc [k v]] (s/replace acc (str "{" k "}") (str v)))
|
||||||
|
text m))
|
||||||
|
|
||||||
|
(defn build-url [root-url path params]
|
||||||
|
(str root-url (map-replace path params)))
|
||||||
|
|
||||||
|
(defn attach-handler [hm fn]
|
||||||
|
(assoc hm :handler fn))
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
(ns org.aplex.helpers.interface
|
||||||
|
(:require
|
||||||
|
[org.aplex.helpers.core :as c])
|
||||||
|
(:import
|
||||||
|
(java.lang System)))
|
||||||
|
|
||||||
|
(defmacro load-default-env [env-var]
|
||||||
|
(System/getenv env-var))
|
||||||
|
|
||||||
|
(defn map-replace [text m]
|
||||||
|
(c/map-replace text m))
|
||||||
|
|
||||||
|
|
||||||
|
(defn build-url [root-url path params]
|
||||||
|
(c/build-url root-url path params))
|
||||||
|
|
||||||
|
(defn attach-handler [hm fn]
|
||||||
|
(c/attach-handler hm fn))
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
(ns org.aplex.helpers.interface-test
|
||||||
|
(:require [clojure.test :as test :refer :all]
|
||||||
|
[org.aplex.helpers.interface :as helpers]))
|
||||||
|
|
||||||
|
(deftest dummy-test
|
||||||
|
(is (= 1 1)))
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
{:paths ["src" "resources"]
|
||||||
|
:deps {}
|
||||||
|
:aliases {:test {:extra-paths ["test"]
|
||||||
|
:extra-deps {}}}}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
(ns org.aplex.rest-stability-ai.interface)
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
(ns org.aplex.rest-stability-ai.interface-test
|
||||||
|
(:require [clojure.test :as test :refer :all]
|
||||||
|
[org.aplex.rest-stability-ai.interface :as rest-stability-ai]))
|
||||||
|
|
||||||
|
(deftest dummy-test
|
||||||
|
(is (= 1 1)))
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
{:paths ["src" "resources"]
|
||||||
|
:deps {}
|
||||||
|
:aliases {:test {:extra-paths ["test"]
|
||||||
|
:extra-deps {}}}}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
(ns org.aplex.stability-ai.core
|
||||||
|
(:require [org.aplex.helpers.interface :as h])
|
||||||
|
)
|
||||||
|
|
||||||
|
(def api-config (atom {:api-host "https://api.stability.ai"
|
||||||
|
:api-key "STABILITY_API_KEY"}))
|
||||||
|
|
||||||
|
(def api-host "https://api.stability.ai")
|
||||||
|
(def api-key "sk-t8dmTcOV2jOAALqJ4yjS8qEOgr4NZHumuHd3ppuMsQn9os2W")
|
||||||
|
|
||||||
|
(def default-authed-payload {:headers {"Authorization" (str "Bearer " api-key)
|
||||||
|
"content-type" "application/json"}})
|
||||||
|
|
||||||
|
(defn init-config [cfg]
|
||||||
|
(reset! api-config (merge @api-config cfg)))
|
||||||
|
|
||||||
|
(defn build-url [path]
|
||||||
|
(str api-host path))
|
||||||
|
|
||||||
|
(defn fetch-user-account []
|
||||||
|
(merge default-authed-payload
|
||||||
|
{:url (build-url "/v1/user/account")
|
||||||
|
:handler prn}))
|
||||||
|
|
||||||
|
(defn fetch-user-balance []
|
||||||
|
(merge default-authed-payload
|
||||||
|
{:url (build-url "/v1/user/balance")
|
||||||
|
:handler prn}))
|
||||||
|
|
||||||
|
(defn fetch-generation-text-to-image []
|
||||||
|
(merge default-authed-payload
|
||||||
|
{:url (build-url "/v1/user/balance")
|
||||||
|
:format :json
|
||||||
|
:response-format :json
|
||||||
|
:params {:text_prompts [{:text "A wooden hand crafted light house"
|
||||||
|
:weight 0.5}]}
|
||||||
|
:handler prn}))
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
(ns org.aplex.stability-ai.interface
|
||||||
|
(:require [org.aplex.stability-ai.core :as c]))
|
||||||
|
|
||||||
|
|
||||||
|
(defn init-config [cfg] (c/init-config cfg))
|
||||||
|
(defn fetch-user-account [] (c/fetch-user-account ))
|
||||||
|
(defn fetch-user-balance [] (c/fetch-user-balance ))
|
||||||
|
(defn fetch-generation-text-to-image [required optional] (c/fetch-generation-text-to-image required optional))
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
(ns org.aplex.stability-ai.interface-test
|
||||||
|
(:require [clojure.test :as test :refer :all]
|
||||||
|
[org.aplex.stability-ai.interface :as stability-ai]))
|
||||||
|
|
||||||
|
(deftest dummy-test
|
||||||
|
(is (= 1 1)))
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
{:aliases {:dev {:extra-paths ["development/src"]
|
||||||
|
:extra-deps {org.clojure/clojure {:mvn/version "1.11.1"}}}
|
||||||
|
|
||||||
|
:test {:extra-paths []}
|
||||||
|
|
||||||
|
:poly {:main-opts ["-m" "polylith.clj.core.poly-cli.core"]
|
||||||
|
:extra-deps {polyfy/polylith
|
||||||
|
{:git/url "https://github.com/polyfy/polylith"
|
||||||
|
:sha "f85a99a6c446a6808e12d051359bc319fab86769"
|
||||||
|
:deps/root "projects/poly"}}}}}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
(ns src.user)
|
||||||
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
{:top-namespace "org.aplex"
|
||||||
|
:interface-ns "interface"
|
||||||
|
:default-profile-name "default"
|
||||||
|
:compact-views #{}
|
||||||
|
:vcs {:name "git"
|
||||||
|
:auto-add false}
|
||||||
|
:tag-patterns {:stable "stable-*"
|
||||||
|
:release "v[0-9]*"}
|
||||||
|
:projects {"development" {:alias "dev"}}}
|
||||||
Loading…
Reference in New Issue