fix blue sky is tech
This commit is contained in:
parent
0b89cb40ab
commit
7ccd356e8c
3 changed files with 5 additions and 3 deletions
|
|
@ -3,6 +3,7 @@
|
||||||
[clj-http.client :as http-client]
|
[clj-http.client :as http-client]
|
||||||
[micro-blog.pocket-base :as pb]
|
[micro-blog.pocket-base :as pb]
|
||||||
[micro-blog.utils :as utils]
|
[micro-blog.utils :as utils]
|
||||||
|
[cheshire.core :as json]
|
||||||
[micro-blog.is-tech]
|
[micro-blog.is-tech]
|
||||||
[taoensso.telemere :as tel]
|
[taoensso.telemere :as tel]
|
||||||
[micro-blog.config :refer [config]]))
|
[micro-blog.config :refer [config]]))
|
||||||
|
|
@ -82,10 +83,11 @@
|
||||||
(map #(vector (:fullsize %) (:alt %)) images)))
|
(map #(vector (:fullsize %) (:alt %)) images)))
|
||||||
|
|
||||||
(defn transform-post [post]
|
(defn transform-post [post]
|
||||||
|
(tel/log! {:level :info :data {:post post}} "Transforming post")
|
||||||
(hash-map :source :blue_sky
|
(hash-map :source :blue_sky
|
||||||
:fullPost post
|
:fullPost post
|
||||||
:remoteId (:cid 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])
|
:authorId (get-in post [:author :handle])
|
||||||
:tags (extract-tags post)
|
:tags (extract-tags post)
|
||||||
:images (extract-images post)
|
:images (extract-images post)
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
[clj-http.client :as client]))
|
[clj-http.client :as client]))
|
||||||
|
|
||||||
(defn is-tech? [post-text]
|
(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")
|
(let [url (str (:mistral-host @config) "/v1/conversations")
|
||||||
headers {"Content-Type" "application/json"
|
headers {"Content-Type" "application/json"
|
||||||
"Accept" "application/json"
|
"Accept" "application/json"
|
||||||
|
|
@ -12,7 +13,7 @@
|
||||||
body {:inputs post-text
|
body {:inputs post-text
|
||||||
:stream false
|
:stream false
|
||||||
:agent_id (@config :mistral-agent-id)}]
|
: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
|
(client/post url {:headers headers
|
||||||
:form-params body
|
:form-params body
|
||||||
|
|
|
||||||
|
|
@ -185,7 +185,6 @@
|
||||||
[:remoteId :string]
|
[:remoteId :string]
|
||||||
[:authorId :string]
|
[:authorId :string]
|
||||||
[:posted :string]]]
|
[:posted :string]]]
|
||||||
|
|
||||||
(utils/validate-with-throw post save-post-schema)
|
(utils/validate-with-throw post save-post-schema)
|
||||||
(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))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue