Skip to content

Support JSON serialization of document shapes (issue #270)#309

Merged
scottbale merged 2 commits into
cognitect-labs:mainfrom
GaspardP:fix-270
Apr 7, 2026
Merged

Support JSON serialization of document shapes (issue #270)#309
scottbale merged 2 commits into
cognitect-labs:mainfrom
GaspardP:fix-270

Conversation

@GaspardP

@GaspardP GaspardP commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Hi team, here's the fix for issue #270.

I can't recall how I listed the shapes last time but the following seems to work and still matches what I reported previously.

(require '[cognitect.aws.client.api :as aws]
         '[cognitect.aws.client.protocol :as client.protocol])

(def client (aws/client {:api :bedrock-runtime}))
(def service (-> client client.protocol/-get-info :service))
(->> service :shapes (filter (fn [[_ s]] (:document s))))
;; ([:ModelInputPayload {:type "structure", :members {}, :document true, :sensitive true}]
;;  [:Document {:type "structure", :members {}, :document true}])

The example from #272 can be used to check the fix (not sure if you want integration tests for this as the modelId keep changing?).

;; clojure -Sdeps '{:deps {com.cognitect.aws/api {:local/root "."}
;;                         com.cognitect.aws/endpoints {:mvn/version "871.2.42.24"}
;;                         com.cognitect.aws/bedrock-runtime {:mvn/version "871.2.41.25"
;;                                                            :aws/serviceFullName "Amazon Bedrock Runtime"}}}'
(require '[cognitect.aws.client.api :as aws])

(def bedrock-runtime-client
  (delay
    (aws/client {:api :bedrock-runtime})))

(aws/invoke
 @bedrock-runtime-client
 {:op      :Converse
  :request {:modelId         "us.amazon.nova-micro-v1:0"
            :messages        [{:role    "user"
                               :content [{:text "how many cars are there?"}]}]
            :toolConfig      {:tools [{:toolSpec {:name        "get-user-cars"
                                                  :description "Get all devices for a customer."
                                                  :inputSchema {:json {:type       "object"
                                                                       :properties {:customer-id {:type "string"}}
                                                                       :required   ["customer-id"]}}}}]}
            :inferenceConfig {:maxTokens   512
                              :temperature 0.5
                              :topP        0.9}}})

Let me know if you need anything else.

@scottbale scottbale left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@scottbale scottbale merged commit 1d1af13 into cognitect-labs:main Apr 7, 2026
16 checks passed
@scottbale

Copy link
Copy Markdown
Collaborator

Thanks @GaspardP 🙏

@GaspardP

GaspardP commented Apr 8, 2026

Copy link
Copy Markdown
Contributor Author

Happy to help! Thanks for the review.

@GaspardP GaspardP deleted the fix-270 branch April 8, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants