First create a new chat:
POST /api/v1/chats/new
Content-Type: application/json
{ "chat": { "id": "", "title": "New Chat", "models":["your_model:latest"], "params": {}, "history": { "messages": {}, "currentId": null }, "messages": [], "tags": [],"timestamp": <current_timestamp> } }
Then add messages:
POST /api/v1/chats/{chat_id}
Content-Type: application/json
{ "chat": { "models": ["your_model:latest"], "messages": [ {"id": "<message_uuid>", "parentId": null, "childrenIds": [], "role": "user", "content": "Your message here", "timestamp":<timestamp>, "models": ["your_model:latest"] } ], "history": { "messages": { "<message_uuid>": { "id": "<message_uuid>", "parentId": null, "childrenIds": [], "role": "user", "content": "Your message here", "timestamp":<timestamp>, "models": ["your_model:latest"] } }, "currentId": "<message_uuid>" } } }
Make a completion request:
POST /api/chat/completions
Content-Type: application/json
{ "stream": true, "model": "your_model:latest", "messages": [{ "role": "user", "content": "Your message here" } ], "params": { "num_ctx": 8192 }, "chat_id": "<chat_id>", "id": "<message_uuid_for_response>" }
And then update the chat:
POST /api/v1/chats/{chat_id}
Content-Type: application/json
{ "chat": { "models": ["your_model:latest"], "messages": [// Previous messages... { "id": "<user_message_uuid>", "parentId": null, "childrenIds": ["<assistant_message_uuid>"],"role": "user", "content": "Your message", "timestamp": <timestamp>, "models": ["your_model:latest"] }, { "id": "<assistant_message_uuid>", "parentId": "<user_message_uuid>", "childrenIds": [], "role": "assistant", "content":"Assistant's response", "model": "your_model:latest", "timestamp": <timestamp> } ], "history": { "messages": { // Include both messages here in the same format }, "currentId": "<assistant_message_uuid>" } } }
Read 122 times, last 5 days ago