MCPcopy
hub / github.com/mudler/LocalAI / createChat

Function createChat

core/http/static/chat.js:2319–2342  ·  view source on GitHub ↗
(model, systemPrompt, mcpMode)

Source from the content-addressed store, hash-verified

2317 },
2318
2319 createChat(model, systemPrompt, mcpMode) {
2320 const chatId = generateChatId();
2321 const now = Date.now();
2322 const chat = {
2323 id: chatId,
2324 name: "New Chat",
2325 model: model || getCurrentModel() || "",
2326 history: [],
2327 systemPrompt: systemPrompt || "",
2328 mcpMode: mcpMode || false,
2329 tokenUsage: {
2330 promptTokens: 0,
2331 completionTokens: 0,
2332 totalTokens: 0,
2333 currentRequest: null
2334 },
2335 contextSize: null,
2336 createdAt: now,
2337 updatedAt: now
2338 };
2339 this.chats.push(chat);
2340 this.activeChatId = chatId;
2341 return chat;
2342 },
2343
2344 switchChat(chatId) {
2345 if (this.chats.find(c => c.id === chatId)) {

Callers

nothing calls this directly

Calls 3

generateChatIdFunction · 0.85
getCurrentModelFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected