Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(chat): refactor and fix Tool #304

Merged
merged 3 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ public data class Tool(
*/
@SerialName("type") val type: ToolType,

/**
* Tool description.
*/
@SerialName("description") val description: String? = null,

/**
* A description of what the function does, used by the model to choose when and how to call the function.
*/
Expand All @@ -38,8 +33,7 @@ public data class Tool(
public fun function(name: String, description: String? = null, parameters: Parameters): Tool =
Tool(
type = ToolType.Function,
description = description,
function = FunctionTool(name = name, parameters = parameters)
function = FunctionTool(name = name, description = description, parameters = parameters)
)
}
}
Expand All @@ -56,12 +50,17 @@ public data class FunctionTool(
@SerialName("name") val name: String,

/**
* The parameters the function accepts, described as a JSON Schema object.
* See the [guide](https://github.com/aallam/openai-kotlin/blob/main/guides/ChatToolCalls.md) for examples,
* and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about
* The parameters the functions accept, described as a JSON Schema object.
* See the [guide](https://platform.openai.com/docs/guides/text-generation/function-calling) for examples,
* and the [JSON Schema reference](https://json-schema.org/understanding-json-schema) for documentation about
* the format.
*
* To describe a function that accepts no parameters, provide [Parameters.Empty]`.
* Omitting `parameters` defines a function with an empty parameter list.
*/
@SerialName("parameters") val parameters: Parameters? = null,

/**
* A description of what the function does, used by the model to choose when and how to call the function.
*/
@SerialName("parameters") val parameters: Parameters
@SerialName("description") public val description: String? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ public data class ErrorInfo(
/**
* A human-readable error message.
*/
val message: String,
val message: String? = null,

/**
* A machine-readable error code.
*/
val code: String,
val code: String? = null,

/**
* The parameter that was invalid (e.g., `training_file`, `validation_file`), or null if not parameter-specific.
Expand Down
Loading