diff --git a/src/micro_blog/blue_sky.clj b/src/micro_blog/blue_sky.clj index 1c9579c..d491dac 100644 --- a/src/micro_blog/blue_sky.clj +++ b/src/micro_blog/blue_sky.clj @@ -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) diff --git a/src/micro_blog/is_tech.clj b/src/micro_blog/is_tech.clj index 6a33047..49eb22d 100644 --- a/src/micro_blog/is_tech.clj +++ b/src/micro_blog/is_tech.clj @@ -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 diff --git a/src/micro_blog/pocket_base.clj b/src/micro_blog/pocket_base.clj index bd43e02..ab3f3ae 100644 --- a/src/micro_blog/pocket_base.clj +++ b/src/micro_blog/pocket_base.clj @@ -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))