From 57b4a13a7ce5934cf02096dcd1e3b3ba58a7f979 Mon Sep 17 00:00:00 2001 From: Travis Shears Date: Fri, 15 Aug 2025 21:46:03 +0200 Subject: [PATCH] change isTech from bool to "yes_ai" --- deploy.sh | 5 +++++ src/micro_blog/is_tech.clj | 7 ++----- src/micro_blog/pocket_base.clj | 26 ++++++++++++++++++-------- 3 files changed, 25 insertions(+), 13 deletions(-) create mode 100755 deploy.sh diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..e6e200a --- /dev/null +++ b/deploy.sh @@ -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 . \ No newline at end of file diff --git a/src/micro_blog/is_tech.clj b/src/micro_blog/is_tech.clj index 03cd950..6a33047 100644 --- a/src/micro_blog/is_tech.clj +++ b/src/micro_blog/is_tech.clj @@ -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))))) diff --git a/src/micro_blog/pocket_base.clj b/src/micro_blog/pocket_base.clj index 05056a0..a4dc520 100644 --- a/src/micro_blog/pocket_base.clj +++ b/src/micro_blog/pocket_base.clj @@ -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") - (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})))) + (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}) + (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")