CoderHeaders builds the set of Coder identity headers to attach to outgoing LLM API requests for the given chat.
(chat database.Chat)
| 1126 | // CoderHeaders builds the set of Coder identity headers to attach |
| 1127 | // to outgoing LLM API requests for the given chat. |
| 1128 | func CoderHeaders(chat database.Chat) map[string]string { |
| 1129 | chatID := chat.ID |
| 1130 | if chat.ParentChatID.Valid { |
| 1131 | chatID = chat.ParentChatID.UUID |
| 1132 | } |
| 1133 | h := map[string]string{ |
| 1134 | HeaderCoderOwnerID: chat.OwnerID.String(), |
| 1135 | HeaderCoderChatID: chatID.String(), |
| 1136 | } |
| 1137 | if chat.ParentChatID.Valid { |
| 1138 | h[HeaderCoderSubchatID] = chat.ID.String() |
| 1139 | } |
| 1140 | if chat.WorkspaceID.Valid { |
| 1141 | h[HeaderCoderWorkspaceID] = chat.WorkspaceID.UUID.String() |
| 1142 | } |
| 1143 | return h |
| 1144 | } |
| 1145 | |
| 1146 | // CoderHeadersFromIDs is a convenience form of CoderHeaders for call |
| 1147 | // sites that do not have a full database.Chat in scope. |