Skip to content

Commit

Permalink
feat(chat_gpt): update prompt with users details
Browse files Browse the repository at this point in the history
  • Loading branch information
stakach committed Oct 17, 2023
1 parent 0e5d0aa commit 533decc
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/placeos-rest-api/controllers/chat_gpt/chat_manager.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 533decc

Please sign in to comment.