Skip to content

Commit 3973d10

Browse files
committed
Function spec (name, description, params) and new attributes for Message holder - name and function_call - introduced
1 parent db59901 commit 3973d10

File tree

4 files changed

+47
-6
lines changed

4 files changed

+47
-6
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package io.cequence.openaiscala.domain
2+
3+
case class FunctionSpec(
4+
// The name of the function to be called.
5+
// Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
6+
name: String,
7+
8+
// The description of what the function does.
9+
description: Option[String] = None,
10+
11+
// The parameters the functions accepts, described as a JSON Schema object.
12+
// See the guide for examples, and the JSON Schema reference for documentation about the format.
13+
parameters: Map[String, Any]
14+
)
Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,32 @@
11
package io.cequence.openaiscala.domain
22

3-
case class MessageSpec(role: ChatRole, content: String)
3+
case class MessageSpec(
4+
// The role of the messages author. One of system, user, assistant, or function.
5+
role: ChatRole,
6+
7+
// The contents of the message. Content is required for all messages except assistant messages with function calls.
8+
content: Option[String],
9+
10+
// The name of the author of this message. name is required if role is function, and
11+
// it should be the name of the function whose response is in the content.
12+
// May contain a-z, A-Z, 0-9, and underscores, with a maximum length of 64 characters.
13+
name: Option[String] = None,
14+
15+
// The name and arguments of a function that should be called, as generated by the model.
16+
function_call: Option[FunctionCallSpec] = None
17+
)
418

519
sealed trait ChatRole
620

721
object ChatRole {
822
case object User extends ChatRole
923
case object System extends ChatRole
1024
case object Assistant extends ChatRole
25+
26+
case object Function extends ChatRole
1127
}
28+
29+
case class FunctionCallSpec(
30+
name: String,
31+
arguments: String
32+
)

openai-core/src/main/scala/io/cequence/openaiscala/domain/response/ChatCompletionResponse.scala

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ case class ChatCompletionChoiceInfo(
1818
finish_reason: Option[String]
1919
)
2020

21-
case class ChatMessage(
22-
role: ChatRole,
23-
content: String
24-
)
25-
2621
// chunk - streamed
2722
case class ChatCompletionChunkResponse(
2823
id: String,
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package io.cequence.openaiscala.domain.response
2+
3+
import io.cequence.openaiscala.domain.{ChatRole, FunctionCallSpec}
4+
5+
@Deprecated // to be replaced by MessageSpec in the next release
6+
case class ChatMessage(
7+
role: ChatRole,
8+
content: Option[String],
9+
name: Option[String] = None,
10+
function_call: Option[FunctionCallSpec] = None
11+
)

0 commit comments

Comments
 (0)