Skip to content

Commit

Permalink
feat(place/llm): expose new_chat via bindings
Browse files Browse the repository at this point in the history
so we can lean on redis more for chat functionality and improve performance
  • Loading branch information
stakach committed Oct 17, 2023
1 parent 200705b commit 8d515b0
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 25 deletions.
13 changes: 13 additions & 0 deletions drivers/place/llm/llm.cr
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ focus on key points in questions
simplify complex issues with steps
clarify unclear questions before answering
correct errors in previous answers),

user_hint: "Hi! I'm your workplace assistant.\n" +
"I can get you instant answers for almost anything as well as perform actions such as booking a meeting room.\n" +
"How can I help?",
})

def on_load
Expand All @@ -27,6 +31,11 @@ correct errors in previous answers),

def on_update
@prompt = setting(String, :prompt)
self[:user_hint] = setting?(String, :user_hint) || "Hi! I'm your workplace assistant."

schedule.clear
schedule.in(5.seconds) { update_prompt }
schedule.every(5.minutes) { update_prompt }
end

getter! prompt : String
Expand All @@ -47,4 +56,8 @@ correct errors in previous answers),
system_id: system.id,
}
end

protected def update_prompt
self[:prompt] = new_chat
end
end
28 changes: 14 additions & 14 deletions drivers/place/llm/llm_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,27 @@ DriverSpecs.mock_driver "Place::LLM" do

system(:DeskBookings_1).function_schemas.should eq([
{
function: "list_of_levels",
function: "list_of_levels",
description: "returns the list of levels with available desks",
parameters: {} of String => JSON::Any
parameters: {} of String => JSON::Any,
},
{
function: "book",
function: "book",
description: "books a desk, you can optionally provide a preferred level or how many days from now if the booking is for tomorrow etc",
parameters: {
parameters: {
"level" => {
"anyOf" => [{"type" => "null"}, {"type" => "string"}],
"title" => "(String | Nil)",
"default" => nil
"anyOf" => [{"type" => "null"}, {"type" => "string"}],
"title" => "(String | Nil)",
"default" => nil,
},
"days_in_future" => {
"type" => "integer",
"format" => "Int32",
"title" => "Int32",
"default" => 0
}
}
}
"type" => "integer",
"format" => "Int32",
"title" => "Int32",
"default" => 0,
},
},
},
])
end

Expand Down
22 changes: 11 additions & 11 deletions drivers/place/llm/todo_list_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ DriverSpecs.mock_driver "Place::TODOs" do

exec(:function_schemas).get.should eq([
{
"function" => "list_tasks",
"function" => "list_tasks",
"description" => "returns the list of tasks and their current status",
"parameters" => {} of String => JSON::Any
"parameters" => {} of String => JSON::Any,
},
{
"function" => "add_task",
"function" => "add_task",
"description" => "adds a new task to the list",
"parameters" => {
"description" => {"type" => "string", "title" => "String"}
}
"parameters" => {
"description" => {"type" => "string", "title" => "String"},
},
},
{
"function" => "complete_task",
"function" => "complete_task",
"description" => "marks a task as completed",
"parameters" => {
"index" => {"type" => "integer", "format" => "Int32", "title" => "Int32"}
}
}
"parameters" => {
"index" => {"type" => "integer", "format" => "Int32", "title" => "Int32"},
},
},
])
end

0 comments on commit 8d515b0

Please sign in to comment.