forked from janhq/cortex.cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmessages.h
More file actions
61 lines (49 loc) · 2.32 KB
/
messages.h
File metadata and controls
61 lines (49 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#pragma once
#include <drogon/HttpController.h>
#include <trantor/utils/Logger.h>
#include "services/message_service.h"
using namespace drogon;
class Messages : public drogon::HttpController<Messages, false> {
public:
METHOD_LIST_BEGIN
ADD_METHOD_TO(Messages::CreateMessage, "/v1/threads/{1}/messages", Options,
Post);
ADD_METHOD_TO(Messages::ListMessages,
"/v1/threads/{thread_id}/"
"messages?limit={limit}&order={order}&after={after}&before={"
"before}&run_id={run_id}",
Get);
ADD_METHOD_TO(Messages::RetrieveMessage, "/v1/threads/{1}/messages/{2}", Get);
ADD_METHOD_TO(Messages::ModifyMessage, "/v1/threads/{1}/messages/{2}",
Options, Patch);
ADD_METHOD_TO(Messages::DeleteMessage, "/v1/threads/{1}/messages/{2}",
Options, Delete);
METHOD_LIST_END
Messages(std::shared_ptr<MessageService> msg_srv)
: message_service_{msg_srv} {}
void CreateMessage(const HttpRequestPtr& req,
std::function<void(const HttpResponsePtr&)>&& callback,
const std::string& thread_id);
void ListMessages(const HttpRequestPtr& req,
std::function<void(const HttpResponsePtr&)>&& callback,
const std::string& thread_id,
std::optional<std::string> limit,
std::optional<std::string> order,
std::optional<std::string> after,
std::optional<std::string> before,
std::optional<std::string> run_id) const;
void RetrieveMessage(const HttpRequestPtr& req,
std::function<void(const HttpResponsePtr&)>&& callback,
const std::string& thread_id,
const std::string& message_id) const;
void ModifyMessage(const HttpRequestPtr& req,
std::function<void(const HttpResponsePtr&)>&& callback,
const std::string& thread_id,
const std::string& message_id);
void DeleteMessage(const HttpRequestPtr& req,
std::function<void(const HttpResponsePtr&)>&& callback,
const std::string& thread_id,
const std::string& message_id);
private:
std::shared_ptr<MessageService> message_service_;
};