-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathCreateThreadAndRun.scala
90 lines (82 loc) · 3.11 KB
/
CreateThreadAndRun.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package io.cequence.openaiscala.examples
import io.cequence.openaiscala.domain.AssistantToolResource.{
CodeInterpreterResources,
FileSearchResources
}
import io.cequence.openaiscala.domain.ThreadAndRun.Message.{AssistantMessage, UserMessage}
import io.cequence.openaiscala.domain.{AssistantToolResource, FileId, ThreadAndRun}
import scala.concurrent.Future
object CreateThreadAndRun extends Example {
override protected def run: Future[Unit] =
for {
thread <- service.createThreadAndRun(
assistantId = "asst_GEKjNc6lewoiulFt32mWSqKl",
thread = Some(
ThreadAndRun(
messages = Seq(
UserMessage("Explain deep learning to a 5 year old."),
AssistantMessage(
"Deep learning is a type of machine learning that trains a computer to perform human-like tasks, such as recognizing speech, identifying images, or making decisions."
),
UserMessage("Could you please provide even simpler explanation?")
),
toolResources = AssistantToolResource.empty,
metadata = Map.empty
)
),
stream = false
)
// Vector Store: CUSTOMER RELATIONSHIP AGREEMENT[vs_sRwpBFIFYyfWQ3og8X9CQs3A] (3 files)
// - file-y5Q8IgmBvQ547z7vi9PDOzZQ (vector_store.file)
// - file-9pb59EqrMCRpDxivmDQ6AxqW (vector_store.file)
// - file-DQQrxLykRzcA54rqMyyfygyV (vector_store.file)
threadWithCodeInterpreter <- service.createThreadAndRun(
assistantId = "asst_GEKjNc6lewoiulFt32mWSqKl",
thread = Some(
ThreadAndRun(
messages = Seq(
UserMessage("Tell me about usage of FP in Cequence."),
AssistantMessage(
"Cequence does use functional programming."
),
UserMessage("Could you please provide more comprehensive answer?")
),
toolResources = AssistantToolResource(
CodeInterpreterResources(fileIds =
Seq(
FileId("file-y5Q8IgmBvQ547z7vi9PDOzZQ"),
FileId("file-9pb59EqrMCRpDxivmDQ6AxqW"),
FileId("file-DQQrxLykRzcA54rqMyyfygyV")
)
)
),
metadata = Map.empty
)
),
stream = false
)
threadWithFileSearch <- service.createThreadAndRun(
assistantId = "asst_GEKjNc6lewoiulFt32mWSqKl",
thread = Some(
ThreadAndRun(
messages = Seq(
UserMessage("Tell me about usage of FP in Cequence."),
AssistantMessage(
"Cequence does use functional programming."
),
UserMessage("Could you please provide more comprehensive answer?")
),
toolResources = AssistantToolResource(
FileSearchResources(vectorStoreIds = Seq("vs_sRwpBFIFYyfWQ3og8X9CQs3A"))
),
metadata = Map.empty
)
),
stream = false
)
} yield {
println(thread)
println(threadWithCodeInterpreter)
println(threadWithFileSearch)
}
}