change isTech from bool to "yes_ai"

This commit is contained in:
Travis Shears 2025-08-15 21:46:03 +02:00
parent 672e1944b0
commit 57b4a13a7c
3 changed files with 25 additions and 13 deletions

5
deploy.sh Executable file
View file

@ -0,0 +1,5 @@
#!/bin/sh
export AWS_PROFILE=personal
docker buildx build --platform linux/amd64,linux/arm64 -t 853019563312.dkr.ecr.eu-central-1.amazonaws.com/micro-blog-fetchers-homelabstack:latest --push .

View file

@ -4,7 +4,7 @@
[taoensso.telemere :as tel]
[clj-http.client :as client]))
(defn call-mistral-api [post-text]
(defn is-tech? [post-text]
(let [url (str (:mistral-host @config) "/v1/conversations")
headers {"Content-Type" "application/json"
"Accept" "application/json"
@ -22,7 +22,4 @@
:outputs
first
:content
(#(if (= "1" %) true false)))))
(defn is-tech? [post-text]
(call-mistral-api post-text))
(#(if (= "1" %) :yes_ai :no)))))

View file

@ -40,6 +40,7 @@
new-token))))
(def source-enum [:enum :pleroma :blue_sky :mastodon :pixelfed :nostr])
(def is-tech-enum [:enum :yes_ai :no :yes_human])
(defn valid-source? [source]
(m/validate source-enum source))
@ -178,7 +179,7 @@
(let [save-post-schema [:map
[:source source-enum]
[:fullPost :any]
[:isTech :boolean]
[:isTech is-tech-enum]
[:tags [:sequential :string]]
[:images [:sequential [:tuple :string :string]]]
[:remoteId :string]
@ -189,13 +190,22 @@
(tel/log! {:level :info :data {:remoteId (:remoteId post)}} "Post passed save validation")
(if (post-with-remote-id-already-saved? (:remoteId post))
(println "post already saved")
(try
(http-client/post (str (@config :pocket-base-host) "/api/collections/micro_blog_posts/records")
{:headers {"Authorization" (get-login-token-with-cache)}
:form-params (assoc post
:tags (map get-tag-id (:tags post))
:images (map #(apply get-image-id %) (:images post)))
:content-type :json
:as :json}))))
:as :json})
(catch Exception e
(tel/log! {:level :error
:id :pocket-base/save-post-error
:data {:remoteId (:remoteId post)
:error (.getMessage e)
:exception e}}
"Error saving post to pocketbase")
(throw e))))))
(defn set-is-tech [post-id is-tech]
(tel/log! {:level :info :data {:post-id post-id}} "Setting post.is-tech to yes_ai")