Skip to content

Commit

Permalink
fix(interface/chat_functions): include description with function schema
Browse files Browse the repository at this point in the history
  • Loading branch information
stakach committed Oct 13, 2023
1 parent 727d8a7 commit 9e99e2f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: placeos-driver
version: 6.9.8
version: 6.9.9
crystal: ">= 1.0.0"

dependencies:
Expand Down
10 changes: 7 additions & 3 deletions src/placeos-driver/interface/chat_functions.cr
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,21 @@ abstract class PlaceOS::Driver
abstract def capabilities : String

# returns function name => {param name => JSON Schema}
def function_schemas : Hash(String, Hash(String, JSON::Any))
def function_schemas : Array(NamedTuple(function: String, description: String, parameters: Hash(String, JSON::Any)))
# function name => {param name => JSON Schema}
interface = Hash(String, Hash(String, JSON::Any)).from_json(self.class.driver_interface)
output = Hash(String, Hash(String, JSON::Any)).new
output = Array(NamedTuple(function: String, description: String, parameters: Hash(String, JSON::Any))).new(interface.size)

# filter the interface to those functions with descriptions
# as these are the only ones that the LLM should use
function_descriptions.each do |function_name, function_description|
name = function_name.to_s
if schema = interface[name]?
output[name] = schema
output << {
function: name,
description: function_description,
parameters: schema,
}
else
logger.warn { "described function not found: #{function_name}" }
end
Expand Down

0 comments on commit 9e99e2f

Please sign in to comment.