(title: string = 'New Chat', model: string = 'llama3.2:latest')
| 146 | } |
| 147 | |
| 148 | async createSession(title: string = 'New Chat', model: string = 'llama3.2:latest'): Promise<ChatSession> { |
| 149 | try { |
| 150 | const response = await fetch(`${API_BASE_URL}/sessions`, { |
| 151 | method: 'POST', |
| 152 | headers: { |
| 153 | 'Content-Type': 'application/json', |
| 154 | }, |
| 155 | body: JSON.stringify({ title, model }), |
| 156 | }); |
| 157 | |
| 158 | if (!response.ok) { |
| 159 | throw new Error(`Failed to create session: ${response.status}`); |
| 160 | } |
| 161 | |
| 162 | const data = await response.json(); |
| 163 | return data.session; |
| 164 | } catch (error) { |
| 165 | console.error('Create session failed:', error); |
| 166 | throw error; |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | async getSession(sessionId: string): Promise<{ session: ChatSession; messages: ChatMessage[] }> { |
| 171 | try { |
no outgoing calls
no test coverage detected