File tree Expand file tree Collapse file tree 3 files changed +28
-18
lines changed
openai-client/src/test/scala/io/cequence/openaiscala
openai-core/src/main/scala/io/cequence/openaiscala
openai-examples/src/main/scala/io/cequence/openaiscala/examples Expand file tree Collapse file tree 3 files changed +28
-18
lines changed Original file line number Diff line number Diff line change @@ -57,7 +57,6 @@ class JsonFormatsSpec extends AnyWordSpecLike with Matchers {
5757 | }
5858 |}""" .stripMargin
5959
60- // | "vector_store_ids" : [ ],
6160 private val fileSearchResourcesJson2 =
6261 """ {
6362 | "file_search" : {
@@ -609,8 +608,6 @@ class JsonFormatsSpec extends AnyWordSpecLike with Matchers {
609608 if (! justSemantics) serialized shouldBe json
610609
611610 val json2 = Json .parse(json).as[A ]
612-
613- println(s " json2 = $json2" )
614611 json2 shouldBe value
615612 }
616613
Original file line number Diff line number Diff line change @@ -634,19 +634,9 @@ object JsonFormats {
634634 }
635635
636636 implicit lazy val assistantToolResourceWrites : Writes [AssistantToolResource ] = Writes {
637- case a @ AssistantToolResource (Some (codeInterpreter), _) =>
638- println(s " going to serialize: $a" )
639- println(
640- s " json = ${Json .toJson(codeInterpreter)(assistantToolResourceCodeInterpreterResourceWrites)}"
641- )
642-
637+ case AssistantToolResource (Some (codeInterpreter), _) =>
643638 Json .toJson(codeInterpreter)(assistantToolResourceCodeInterpreterResourceWrites)
644- case a @ AssistantToolResource (_, Some (fileSearch)) =>
645- println(s " going to serialize: $a" )
646- println(
647- s " json = ${Json .toJson(fileSearch)(assistantToolResourceFileSearchResourceWrites)}"
648- )
649-
639+ case AssistantToolResource (_, Some (fileSearch)) =>
650640 Json .toJson(fileSearch)(assistantToolResourceFileSearchResourceWrites)
651641 case _ => Json .obj()
652642 }
@@ -714,8 +704,6 @@ object JsonFormats {
714704 (__ \ " metadata" ).read[Map [String , String ]].orElse(Reads .pure(Map ()))
715705 )(Thread .apply _)
716706
717- // implicit lazy val threadWrites: Writes[Thread] = Json.writes[Thread]
718-
719707 implicit val fileIdFormat : Format [FileId ] = Format (
720708 Reads .StringReads .map(FileId .apply),
721709 Writes [FileId ](fileId => JsString (fileId.file_id))
Original file line number Diff line number Diff line change 11package io .cequence .openaiscala .examples
22
3- import io .cequence .openaiscala .domain .AssistantToolResource .CodeInterpreterResources
3+ import io .cequence .openaiscala .domain .AssistantToolResource .{
4+ CodeInterpreterResources ,
5+ FileSearchResources
6+ }
47import io .cequence .openaiscala .domain .ThreadAndRun .Message .{AssistantMessage , UserMessage }
58import io .cequence .openaiscala .domain .{AssistantToolResource , FileId , ThreadAndRun }
69
@@ -58,8 +61,30 @@ object CreateThreadAndRun extends Example {
5861 ),
5962 stream = false
6063 )
64+
65+ threadWithFileSearch <- service.createThreadAndRun(
66+ assistantId = " asst_GEKjNc6lewoiulFt32mWSqKl" ,
67+ thread = Some (
68+ ThreadAndRun (
69+ messages = Seq (
70+ UserMessage (" Tell me about usage of FP in Cequence." ),
71+ AssistantMessage (
72+ " Cequence does use functional programming."
73+ ),
74+ UserMessage (" Could you please provide more comprehensive answer?" )
75+ ),
76+ toolResources = AssistantToolResource (
77+ FileSearchResources (vectorStoreIds = Seq (" vs_sRwpBFIFYyfWQ3og8X9CQs3A" ))
78+ ),
79+ metadata = Map .empty
80+ )
81+ ),
82+ stream = false
83+ )
6184 } yield {
6285 println(thread)
86+ println(threadWithCodeInterpreter)
87+ println(threadWithFileSearch)
6388 }
6489
6590}
You can’t perform that action at this time.
0 commit comments