-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathTestFixtures.scala
66 lines (57 loc) · 1.82 KB
/
TestFixtures.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package io.cequence.openaiscala.examples
import io.cequence.openaiscala.domain.JsonSchema
import io.cequence.openaiscala.domain.settings.JsonSchemaDef
import org.slf4j.LoggerFactory
trait TestFixtures {
val logger = LoggerFactory.getLogger(getClass)
val capitalsPrompt = "Give me the most populous capital cities in JSON format."
val capitalsSchemaDef1 = capitalsSchemaDefAux(Left(capitalsSchema1))
val capitalsSchemaDef2 = capitalsSchemaDefAux(Right(capitalsSchema2))
def capitalsSchemaDefAux(schema: Either[JsonSchema, Map[String, Any]]): JsonSchemaDef =
JsonSchemaDef(
name = "capitals_response",
strict = true,
structure = schema
)
lazy protected val capitalsSchema1 = JsonSchema.Object(
properties = Map(
"countries" -> JsonSchema.Array(
items = JsonSchema.Object(
properties = Map(
"country" -> JsonSchema.String(
description = Some("The name of the country")
),
"capital" -> JsonSchema.String(
description = Some("The capital city of the country")
)
),
required = Seq("country", "capital")
)
)
),
required = Seq("countries")
)
lazy protected val capitalsSchema2 = Map(
"type" -> "object",
"properties" -> Map(
"countries" -> Map(
"type" -> "array",
"items" -> Map(
"type" -> "object",
"properties" -> Map(
"country" -> Map(
"type" -> "string",
"description" -> "The name of the country"
),
"capital" -> Map(
"type" -> "string",
"description" -> "The capital city of the country"
)
),
"required" -> Seq("country", "capital")
)
)
),
"required" -> Seq("countries")
)
}