fix blue sky is tech

This commit is contained in:
Travis Shears 2025-08-21 14:57:06 +02:00
parent 0b89cb40ab
commit 7ccd356e8c
3 changed files with 5 additions and 3 deletions

View file

@ -3,6 +3,7 @@
[clj-http.client :as http-client]
[micro-blog.pocket-base :as pb]
[micro-blog.utils :as utils]
[cheshire.core :as json]
[micro-blog.is-tech]
[taoensso.telemere :as tel]
[micro-blog.config :refer [config]]))
@ -82,10 +83,11 @@
(map #(vector (:fullsize %) (:alt %)) images)))
(defn transform-post [post]
(tel/log! {:level :info :data {:post post}} "Transforming post")
(hash-map :source :blue_sky
:fullPost post
:remoteId (:cid post)
:isTech (micro-blog.is-tech/is-tech? (:record post))
:isTech (micro-blog.is-tech/is-tech? (json/generate-string (:record post)))
:authorId (get-in post [:author :handle])
:tags (extract-tags post)
:images (extract-images post)

View file

@ -5,6 +5,7 @@
[clj-http.client :as client]))
(defn is-tech? [post-text]
(when (not (string? post-text)) (throw (ex-info "Post text must be a string" {:post-text post-text})))
(let [url (str (:mistral-host @config) "/v1/conversations")
headers {"Content-Type" "application/json"
"Accept" "application/json"
@ -12,7 +13,7 @@
body {:inputs post-text
:stream false
:agent_id (@config :mistral-agent-id)}]
(tel/log! {:level :info :data {:url url :agent_id (:agent_id body)}} "making request to mistral agent")
(tel/log! {:level :info :data {:url url :agent_id (:agent_id body) :post-text post-text}} "making request to mistral agent")
(->
(client/post url {:headers headers
:form-params body

View file

@ -185,7 +185,6 @@
[:remoteId :string]
[:authorId :string]
[:posted :string]]]
(utils/validate-with-throw post save-post-schema)
(tel/log! {:level :info :data {:remoteId (:remoteId post)}} "Post passed save validation")
(if (post-with-remote-id-already-saved? (:remoteId post))