is_tech.clj
· 878 B · Clojure
Raw
(ns micro-blog.is-tech
(:require
[micro-blog.config :refer [config]]
[taoensso.telemere :as tel]
[clj-http.client :as client]))
(defn is-tech? [post-text]
(let [url (str (:mistral-host @config) "/v1/conversations")
headers {"Content-Type" "application/json"
"Accept" "application/json"
"Authorization" (str "Bearer " (@config :mistral-api-key))}
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")
(->
(client/post url {:headers headers
:form-params body
:content-type :json
:as :json})
:body
:outputs
first
:content
(#(if (= "1" %) true false)))))
| 1 | (ns micro-blog.is-tech |
| 2 | (:require |
| 3 | [micro-blog.config :refer [config]] |
| 4 | [taoensso.telemere :as tel] |
| 5 | [clj-http.client :as client])) |
| 6 | |
| 7 | (defn is-tech? [post-text] |
| 8 | (let [url (str (:mistral-host @config) "/v1/conversations") |
| 9 | headers {"Content-Type" "application/json" |
| 10 | "Accept" "application/json" |
| 11 | "Authorization" (str "Bearer " (@config :mistral-api-key))} |
| 12 | body {:inputs post-text |
| 13 | :stream false |
| 14 | :agent_id (@config :mistral-agent-id)}] |
| 15 | (tel/log! {:level :info :data {:url url :agent_id (:agent_id body)}} "making request to mistral agent") |
| 16 | (-> |
| 17 | (client/post url {:headers headers |
| 18 | :form-params body |
| 19 | :content-type :json |
| 20 | :as :json}) |
| 21 | :body |
| 22 | :outputs |
| 23 | first |
| 24 | :content |
| 25 | (#(if (= "1" %) true false))))) |
| 26 |