Skip to content

Commit 49e1627

Browse files
committed
Anthropic - fixing JsonFormatsSpec
1 parent 7846224 commit 49e1627

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

anthropic-client/src/test/scala/io/cequence/openaiscala/anthropic/JsonFormatsSpec.scala

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class JsonFormatsSpec extends AnyWordSpecLike with Matchers with JsonFormats {
4343
)
4444
)
4545
val json =
46-
"""{"role":"user","content":[{"type":"text","text":"Hello, world!"},{"type":"text","text":"How are you?"}]}"""
46+
"""{"role":"user","content":[{"text":"Hello, world!","type":"text"},{"text":"How are you?","type":"text"}]}"""
4747
testCodec[Message](userMessage, json)
4848
}
4949

@@ -62,20 +62,20 @@ class JsonFormatsSpec extends AnyWordSpecLike with Matchers with JsonFormats {
6262
)
6363
)
6464
val json =
65-
"""{"role":"assistant","content":[{"type":"text","text":"Hello, world!"},{"type":"text","text":"How are you?"}]}"""
65+
"""{"role":"assistant","content":[{"text":"Hello, world!","type":"text"},{"text":"How are you?","type":"text"}]}"""
6666
testCodec[Message](assistantMessage, json)
6767
}
6868

6969
val expectedImageContentJson =
7070
"""{
7171
| "role" : "user",
7272
| "content" : [ {
73-
| "type" : "image",
7473
| "source" : {
7574
| "type" : "base64",
7675
| "media_type" : "image/jpeg",
7776
| "data" : "/9j/4AAQSkZJRg..."
78-
| }
77+
| },
78+
| "type" : "image"
7979
| } ]
8080
|}""".stripMargin
8181

@@ -95,12 +95,12 @@ class JsonFormatsSpec extends AnyWordSpecLike with Matchers with JsonFormats {
9595
val userMessage =
9696
UserMessageContent(
9797
Seq(
98-
ContentBlockBase(TextBlock("Hello, world!"), Some(Ephemeral)),
98+
ContentBlockBase(TextBlock("Hello, world!"), Some(Ephemeral())),
9999
ContentBlockBase(TextBlock("How are you?"))
100100
)
101101
)
102102
val json =
103-
"""{"role":"user","content":[{"type":"text","text":"Hello, world!","cache_control":{"type":"ephemeral"}},{"type":"text","text":"How are you?"}]}"""
103+
"""{"role":"user","content":[{"text":"Hello, world!","type":"text","cache_control":{"type":"ephemeral"}},{"text":"How are you?","type":"text"}]}"""
104104
testCodec[Message](userMessage, json)
105105
}
106106

@@ -109,27 +109,27 @@ class JsonFormatsSpec extends AnyWordSpecLike with Matchers with JsonFormats {
109109
UserMessageContent(
110110
Seq(
111111
ContentBlockBase(TextBlock("Hello, world!")),
112-
ContentBlockBase(TextBlock("How are you?"), Some(Ephemeral))
112+
ContentBlockBase(TextBlock("How are you?"), Some(Ephemeral()))
113113
)
114114
)
115115
val json =
116-
"""{"role":"user","content":[{"type":"text","text":"Hello, world!"},{"type":"text","text":"How are you?","cache_control":{"type":"ephemeral"}}]}"""
116+
"""{"role":"user","content":[{"text":"Hello, world!","type":"text"},{"text":"How are you?","type":"text","cache_control":{"type":"ephemeral"}}]}"""
117117
testCodec[Message](userMessage, json)
118118
}
119119

120120
"serialize and deserialize arbitrary (first) image content with caching" in {
121121
val userMessage =
122122
UserMessageContent(
123123
Seq(
124-
MediaBlock.jpeg("/9j/4AAQSkZJRg...", Some(Ephemeral)),
124+
MediaBlock.jpeg("/9j/4AAQSkZJRg...", Some(Ephemeral())),
125125
ContentBlockBase(TextBlock("How are you?"))
126126
)
127127
)
128128

129129
val imageJson =
130-
"""{"type":"image","source":{"type":"base64","media_type":"image/jpeg","data":"/9j/4AAQSkZJRg..."},"cache_control":{"type":"ephemeral"}}""".stripMargin
130+
"""{"source":{"type":"base64","media_type":"image/jpeg","data":"/9j/4AAQSkZJRg..."},"type":"image","cache_control":{"type":"ephemeral"}}""".stripMargin
131131
val json =
132-
s"""{"role":"user","content":[$imageJson,{"type":"text","text":"How are you?"}]}"""
132+
s"""{"role":"user","content":[$imageJson,{"text":"How are you?","type":"text"}]}"""
133133
testCodec[Message](userMessage, json)
134134
}
135135
}

0 commit comments

Comments
 (0)