Skip to content

Commit

Permalink
fix(interface/chat_functions): simplify function_schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
stakach committed Oct 13, 2023
1 parent 754fbf4 commit 7d45dcc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 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.6
version: 6.9.7
crystal: ">= 1.0.0"

dependencies:
Expand Down
4 changes: 4 additions & 0 deletions src/placeos-driver/driver-specs/mock_driver.cr
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ abstract class DriverSpecs::MockDriver
# Filter out abstract methods
{% methods = methods.reject &.body.stringify.empty? %}

def self.driver_interface
KlassExecutor.driver_interface
end

# :nodoc:
class KlassExecutor < BaseExecutor
EXECUTORS = {
Expand Down
14 changes: 8 additions & 6 deletions src/placeos-driver/interface/chat_functions.cr
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,18 @@ abstract class PlaceOS::Driver
# overall description of what this driver implements
abstract def capabilities : String

# returns function name => [function description, {param name => JSON Schema}]
def function_schemas : Hash(String, Tuple(String, Hash(String, JSON::Any)))
# returns function name => {param name => JSON Schema}
def function_schemas : Hash(String, 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 = Hash(String, Tuple(String, Hash(String, JSON::Any))).new

# 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|
if schema = interface[function_name]?
output[function_name] = {function_description, schema}
name = function_name.to_s
if schema = interface[name]?
output[name] = schema
else
logger.warn { "described function not found: #{function_name}" }
end
Expand Down

0 comments on commit 7d45dcc

Please sign in to comment.