From 533decc637a1a9bf35ba18f3d0800e1d0c85a097 Mon Sep 17 00:00:00 2001 From: Stephen von Takach Date: Wed, 18 Oct 2023 09:59:13 +1100 Subject: [PATCH] feat(chat_gpt): update prompt with users details --- .../controllers/chat_gpt/chat_manager.cr | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/placeos-rest-api/controllers/chat_gpt/chat_manager.cr b/src/placeos-rest-api/controllers/chat_gpt/chat_manager.cr index 812dcf9e..bb75cc9f 100644 --- a/src/placeos-rest-api/controllers/chat_gpt/chat_manager.cr +++ b/src/placeos-rest-api/controllers/chat_gpt/chat_manager.cr @@ -128,10 +128,19 @@ module PlaceOS::Api messages = [] of OpenAI::ChatMessage if payload = chat_payload - messages << OpenAI::ChatMessage.new(role: :system, content: payload.prompt) - messages << OpenAI::ChatMessage.new(role: :system, content: "request function lists and call functions as required to fulfil requests.\n" + - "make sure to interpret results and reply appropriately once you have all the information.\n" + - "remember to only use valid capability ids, they can be found in this JSON:\n```json\n#{payload.capabilities.to_json}\n```") + user = Model::User.find!(chat.user_id) + + messages << OpenAI::ChatMessage.new( + role: :system, + content: payload.prompt + + "\n\nrequest function lists and call functions as required to fulfil requests.\n" + + "make sure to interpret results and reply appropriately once you have all the information.\n" + + "remember to only use valid capability ids, they can be found in this JSON:\n```json\n#{payload.capabilities.to_json}\n```\n\n" + + "my name is: #{user.name}\n" + + "my email is: #{user.email}\n" + + "my user_id is: #{user.id}\n" + + "use these details in function calls as required" + ) messages.each { |m| save_history(chat.id.as(String), m) } else