u
This commit is contained in:
2
API.md
2
API.md
@@ -292,7 +292,7 @@ The store is exposed as a `LibDashStore` instance (see `src/index.js`). Each met
|
||||
- `list(googleAuthId: number, tx?: object): Promise<Array<{id: number, companyuser_id: number, provider: string, model: string, created_at: string, updated_at: string, state: string}>>`
|
||||
- `setState(googleAuthId: number, conversationId: number, state: string, tx?: object): Promise<{id: number, companyuser_id: number, provider: string, model: string, created_at: string, updated_at: string, state: string}>`
|
||||
- [modelmessage](API.modelmessage.md)
|
||||
- `add(googleAuthId: number, conversationId: number, input: {message: string, role?: 'user'|'assistant'|'system'|'tool'|'reasoning'}, tx?: object): Promise<{id: number, conversation_id: number, created_at: string, role: string, message: string}>`
|
||||
- `add(googleAuthId: number, conversationId: number, input: {message: string, role?: 'user'|'assistant'|'system'|'tool'|'reasoning'|'usage'}, tx?: object): Promise<{id: number, conversation_id: number, created_at: string, role: string, message: string}>`
|
||||
- `list(googleAuthId: number, conversationId: number, tx?: object): Promise<Array<{id: number, conversation_id: number, created_at: string, role: string, message: string}>>`
|
||||
- [modelvfs](API.modelvfs.md)
|
||||
- `delete(googleAuthId: number, name: string, tx?: object): Promise<{deleted: boolean}>`
|
||||
|
||||
@@ -16,7 +16,7 @@ Appends a message to one of the user's own conversations. `user` messages are re
|
||||
| `conversationId` | `number` | The conversation id. |
|
||||
| `input` | `object` | Message input. |
|
||||
| `input.message` | `string` | Message text. |
|
||||
| `[input.role='user']` | `'user'|'assistant'|'system'|'tool'|'reasoning'` | Message role. |
|
||||
| `[input.role='user']` | `'user'|'assistant'|'system'|'tool'|'reasoning'|'usage'` | Message role. |
|
||||
| `[tx]` | `object` | Optional transaction to run within. |
|
||||
|
||||
**Returns**
|
||||
|
||||
@@ -833,7 +833,7 @@ BEGIN
|
||||
role NVARCHAR(20) NOT NULL,
|
||||
message NVARCHAR(MAX) NOT NULL,
|
||||
CONSTRAINT FK_modelmessage_conversation FOREIGN KEY (conversation_id) REFERENCES modelconversation(id) ON DELETE CASCADE,
|
||||
CONSTRAINT CK_modelmessage_role CHECK (role IN ('system', 'user', 'assistant', 'tool', 'reasoning'))
|
||||
CONSTRAINT CK_modelmessage_role CHECK (role IN ('system', 'user', 'assistant', 'tool', 'reasoning', 'usage'))
|
||||
);
|
||||
CREATE INDEX IX_modelmessage_conversation ON modelmessage (conversation_id, id);
|
||||
END
|
||||
|
||||
@@ -518,7 +518,7 @@ CREATE TABLE IF NOT EXISTS modelmessage (
|
||||
id INTEGER PRIMARY KEY,
|
||||
conversation_id INTEGER NOT NULL,
|
||||
created_at TEXT NOT NULL DEFAULT (${UTC_NOW}),
|
||||
role TEXT NOT NULL CHECK (role IN ('system', 'user', 'assistant', 'tool', 'reasoning')),
|
||||
role TEXT NOT NULL CHECK (role IN ('system', 'user', 'assistant', 'tool', 'reasoning', 'usage')),
|
||||
message TEXT NOT NULL,
|
||||
FOREIGN KEY (conversation_id) REFERENCES modelconversation(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
@@ -31,7 +31,7 @@ export default function add(provider) {
|
||||
* @param {number} conversationId - The conversation id.
|
||||
* @param {object} input - Message input.
|
||||
* @param {string} input.message - Message text.
|
||||
* @param {'user'|'assistant'|'system'|'tool'|'reasoning'} [input.role='user'] - Message role.
|
||||
* @param {'user'|'assistant'|'system'|'tool'|'reasoning'|'usage'} [input.role='user'] - Message role.
|
||||
* @param {object} [tx] - Optional transaction to run within.
|
||||
* @returns {Promise<{id: number, conversation_id: number, created_at: string, role: string, message: string}>}
|
||||
* @throws {Error} 'Conversation not found', 'Conversation is not idle', 'Message required', 'Invalid role'.
|
||||
@@ -42,7 +42,7 @@ export default function add(provider) {
|
||||
throw new Error('Conversation not found');
|
||||
}
|
||||
const role = input.role || 'user';
|
||||
if (!['user', 'assistant', 'system', 'tool', 'reasoning'].includes(role)) {
|
||||
if (!['user', 'assistant', 'system', 'tool', 'reasoning', 'usage'].includes(role)) {
|
||||
throw new Error('Invalid role');
|
||||
}
|
||||
const message = input.message != null ? String(input.message) : '';
|
||||
|
||||
Reference in New Issue
Block a user