| 8101 | buf_free(&b); |
| 8102 | free(items); |
| 8103 | return ok; |
| 8104 | } |
| 8105 | |
| 8106 | static bool final_response(int fd, bool enable_cors, |
| 8107 | const request *r, const char *id, const char *text, |
| 8108 | const char *reasoning, const tool_calls *calls, const char *finish, |
| 8109 | int prompt_tokens, int completion_tokens) { |
| 8110 | buf b = {0}; |
| 8111 | long now = (long)time(NULL); |
| 8112 | if (r->kind == REQ_CHAT) { |
| 8113 | buf_printf(&b, "{\"id\":\"%s\",\"object\":\"chat.completion\",\"created\":%ld,\"model\":", id, now); |
| 8114 | json_escape(&b, r->model); |
| 8115 | buf_puts(&b, ",\"choices\":[{\"index\":0,\"message\":{\"role\":\"assistant\",\"content\":"); |