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

View file

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