Initial commit

This commit is contained in:
Oly 2023-11-16 08:52:14 +00:00
commit 7963963455
21 changed files with 140 additions and 0 deletions

1
bases/.keep Normal file
View File

@ -0,0 +1 @@

1
components/.keep Normal file
View File

@ -0,0 +1 @@

View File

@ -0,0 +1,4 @@
{:paths ["src" "resources"]
:deps {}
:aliases {:test {:extra-paths ["test"]
:extra-deps {}}}}

View File

@ -0,0 +1 @@

View File

@ -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))

View File

@ -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))

View File

@ -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)))

View File

@ -0,0 +1,4 @@
{:paths ["src" "resources"]
:deps {}
:aliases {:test {:extra-paths ["test"]
:extra-deps {}}}}

View File

@ -0,0 +1 @@
(ns org.aplex.rest-stability-ai.interface)

View File

@ -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)))

View File

@ -0,0 +1,4 @@
{:paths ["src" "resources"]
:deps {}
:aliases {:test {:extra-paths ["test"]
:extra-deps {}}}}

View File

@ -0,0 +1 @@

View File

@ -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}))

View File

@ -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))

View File

@ -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)))

10
deps.edn Normal file
View File

@ -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"}}}}}

1
development/src/.keep Normal file
View File

@ -0,0 +1 @@

2
development/src/user.clj Normal file
View File

@ -0,0 +1,2 @@
(ns src.user)

1
projects/.keep Normal file
View File

@ -0,0 +1 @@

9
workspace.edn Normal file
View File

@ -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"}}}