open-notebook/frontend/src/lib/api/chat.ts
Luis Novo b7e656a319
Version 1 (#160)
New front-end
Launch Chat API
Manage Sources
Enable re-embedding of all contents
Sources can be added without a notebook now
Improved settings
Enable model selector on all chats
Background processing for better experience
Dark mode
Improved Notes

Improved Docs: 
- Remove all Streamlit references from documentation
- Update deployment guides with React frontend setup
- Fix Docker environment variables format (SURREAL_URL, SURREAL_PASSWORD)
- Update docker image tag from :latest to :v1-latest
- Change navigation references (Settings → Models to just Models)
- Update development setup to include frontend npm commands
- Add MIGRATION.md guide for users upgrading from Streamlit
- Update quick-start guide with correct environment variables
- Add port 5055 documentation for API access
- Update project structure to reflect frontend/ directory
- Remove outdated source-chat documentation files
2025-10-18 12:46:22 -03:00

71 lines
1.8 KiB
TypeScript

import apiClient from './client'
import {
NotebookChatSession,
NotebookChatSessionWithMessages,
CreateNotebookChatSessionRequest,
UpdateNotebookChatSessionRequest,
SendNotebookChatMessageRequest,
NotebookChatMessage,
BuildContextRequest,
BuildContextResponse,
} from '@/lib/types/api'
export const chatApi = {
// Session management
listSessions: async (notebookId: string) => {
const response = await apiClient.get<NotebookChatSession[]>(
`/chat/sessions`,
{ params: { notebook_id: notebookId } }
)
return response.data
},
createSession: async (data: CreateNotebookChatSessionRequest) => {
const response = await apiClient.post<NotebookChatSession>(
`/chat/sessions`,
data
)
return response.data
},
getSession: async (sessionId: string) => {
const response = await apiClient.get<NotebookChatSessionWithMessages>(
`/chat/sessions/${sessionId}`
)
return response.data
},
updateSession: async (sessionId: string, data: UpdateNotebookChatSessionRequest) => {
const response = await apiClient.put<NotebookChatSession>(
`/chat/sessions/${sessionId}`,
data
)
return response.data
},
deleteSession: async (sessionId: string) => {
await apiClient.delete(`/chat/sessions/${sessionId}`)
},
// Messaging (synchronous, no streaming)
sendMessage: async (data: SendNotebookChatMessageRequest) => {
const response = await apiClient.post<{
session_id: string
messages: NotebookChatMessage[]
}>(
`/chat/execute`,
data
)
return response.data
},
buildContext: async (data: BuildContextRequest) => {
const response = await apiClient.post<BuildContextResponse>(
`/chat/context`,
data
)
return response.data
},
}
export default chatApi