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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
import * as JSX from './jsx';
import $ from 'jquery';
import { Page, GroupBox } from './components';
export default function Api() {
return <Page>
<GroupBox title="API" style="width: 85%">
<div id="support-container" style="text-align: left; width: 100%">
<h2>POST /update-settings</h2>
<p>Updates user settings based on the preferences provided.</p>
<h3>Request</h3>
<p><strong>Body:</strong></p>
<pre><code>{ `{
"token": "JWT token",
"prefs": {
"nickname": "string",
"prompt_data": { "system": "string" },
"site_prefs": { "model": "string" }
}
}` }</code></pre>
<h3>Responses</h3>
<pre>{ $( `<code>{
"status": "ok" | "error",
"msg": "settings updated" | "error message",
"userprefs": {
"uuid": "string", <span class="comment">/* the user uuid */</span>
"nickname": "string", <span class="comment">/* the user's set nickname */</span>
"prompt_data": { "system": "string" }, <span class="comment">/* the custom system prompt */</span>
"site_prefs": { "model": "string" }, <span class="comment">/* the user preferred model */</span>
"chat_files": { "files": [ { "id": "string", "name": "string" } ] }, <span class="comment">/* list of user's chat files */</span>
}
}</code>` )[0] }</pre>
<ul>
<li><span class="status">200 OK</span>: Settings updated successfully</li>
<li><span class="status">400 Bad Request</span>: Invalid value or nickname out of allowed range</li>
<li><span class="status">401 Unauthorized</span>: Invalid or expired token</li>
<li><span class="status">500 Internal Server Error</span>: General server error</li>
</ul>
<hr />
<h2>POST /settings</h2>
<p>Fetches user settings.</p>
<h3>Request</h3>
<p><strong>Body:</strong></p>
<pre><code>{ `{
"token": "JWT token"
}` }</code></pre>
<h3>Responses</h3>
<pre>{ $( `<code>{
"uuid": "string", <span class="comment">/* the user uuid */</span>
"nickname": "string", <span class="comment">/* the user's set nickname */</span>
"prompt_data": { "system": "string" }, <span class="comment">/* the custom system prompt */</span>
"site_prefs": { "model": "string" }, <span class="comment">/* the user preferred model */</span>
"chat_files": { "files": [ { "id": "string", "name": "string" } ] }, <span class="comment">/* list of user's chat files */</span>
}</code>` )[0] }</pre>
<ul>
<li><span class="status">200 OK</span>: Returns user preferences</li>
<li><span class="status">401 Unauthorized</span>: Invalid or expired token</li>
<li><span class="status">500 Internal Server Error</span>: No user data found</li>
</ul>
<hr />
<h2>POST /create-chat</h2>
<p>Creates a new chat file for the user.</p>
<h3>Request</h3>
<p><strong>Body:</strong></p>
<pre><code>{ `{
"token": "JWT token"
}` }</code></pre>
<h3>Responses</h3>
<pre>{ $( `<code>{
"status": "ok" | "nodata" | "error",
"msg": "chat created" | "error message",
"chatId": "string" <span class="comment">/* the uuid/filename of the newly created chat. */</span>
}</code>` )[0] }</pre>
<ul>
<li><span class="status">200 OK</span>: Chat created with ID and topic name</li>
<li><span class="status">400 Bad Request</span>: Missing user data</li>
<li><span class="status">401 Unauthorized</span>: Invalid or expired token</li>
<li><span class="status">500 Internal Server Error</span>: Error creating chat file or updating database</li>
</ul>
<hr />
<h2>POST /get-chat</h2>
<p>Fetches the contents of a specified chat file.</p>
<h3>Request</h3>
<p><strong>Body:</strong></p>
<pre>{ $( `<code>{
"token": "JWT token",
"chatId": "string" <span class="comment">/* chat file uuid */</span>
}</code>` )[0] }</pre>
<h3>Responses</h3>~
<pre><code>{ `{
"status": "ok" | "error",
"msg": "chat not found" | "error message",
"contents": [ { }, ... ]
}` }</code></pre>
<ul>
<li><span class="status">200 OK</span>: Returns chat file contents</li>
<li><span class="status">401 Unauthorized</span>: Invalid or expired token</li>
<li><span class="status">404 Not Found</span>: Chat does not exist</li>
<li><span class="status">500 Internal Server Error</span>: User data not found</li>
</ul>
<hr />
<h2>POST /models</h2>
<p>Lists available models for chat.</p>
<h3>Request</h3>
<p><strong>Body:</strong></p>
<pre><code>{ `{
"token": "JWT token"
}` }</code></pre>
<h3>Responses</h3>
<ul>
<li><span class="status">200 OK</span>: Returns list of models with their attributes</li>
<li><span class="status">401 Unauthorized</span>: Invalid or expired token</li>
</ul>
<hr />
<h2>POST /generate</h2>
<p>Generates text based on the input prompt. Can optionally be used for in-the-middle generation.</p>
<h3>Request</h3>
<p><strong>Body:</strong></p>
<pre>{ $( `<code>{
"token": "JWT token",
"prompt": "string", <span class="comment">/* the text before the generated text */</span>
"suffix": "string", <span class="comment">/* optional - the text after the generated text */</span>
"model": "string",
"options": { "seed": Number, "temperature": Number } <span class="comment">/* optional */</span>
}</code>` )[0] }</pre>
<h3>Response</h3>
<p><strong>Body:</strong></p>
<pre>{ $( `<code>{
"status": "ok" | "error",
"response": "string",
"finalMsg": "string" <span class="comment">/* optional - only at the end of chunked transmission */</span>
}</code>` )[0] }</pre>
<ul>
<li><span class="status">200 OK</span>: Returns streamed chat response</li>
<li><span class="status">400 Bad Request</span>: Missing required parameters</li>
<li><span class="status">401 Unauthorized</span>: Invalid or expired token</li>
<li><span class="status">429 Too Many Requests</span>: A request from this user is already being processed</li>
<li><span class="status">504 Gateway Timeout</span>: No chat instance available</li>
<li><span class="status">500 Internal Server Error</span>: Chat server error</li>
</ul>
<hr />
<h2>POST /chat</h2>
<p>Sends a message to the chat server and streams the response back to the user.</p>
<h3>Request</h3>
<p><strong>Body:</strong></p>
<pre>{ $( `<code>{
"token": "JWT token",
"model": "string",
"messages": [ {
"role": "user" | "assistant" | "tool" | "system",
"content": "string",
timestamp: "string"
} ],
"system": "string", <span class="comment">/* optional */</span>
"options": { "seed": Number, "temperature": Number }, <span class="comment">/* optional */</span>
"chatfile": "string" <span class="comment">/* optional - chat file uuid */</span>
}</code>` )[0] }</pre>
<h3>Responses</h3>
<p><strong>Message:</strong></p>
<pre><code>{ `{
"status": "ok" | "error",
"msg": "string",
"done": false,
"tool": "string"
}` }</code></pre>
<p><strong>End:</strong></p>
<pre><code>{ `{
"status": "ok" | "error",
"msg": "string",
"fullMsg": "full message returned by the model",
"done": true | false
}` }</code></pre>
<ul>
<li><span class="status">200 OK</span>: Returns streamed chat response</li>
<li><span class="status">400 Bad Request</span>: Missing required parameters</li>
<li><span class="status">401 Unauthorized</span>: Invalid or expired token</li>
<li><span class="status">429 Too Many Requests</span>: A request from this user is already being processed</li>
<li><span class="status">504 Gateway Timeout</span>: No chat instance available</li>
<li><span class="status">500 Internal Server Error</span>: Chat server error</li>
</ul>
</div>
</GroupBox>
</Page>
}
|