Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified server_api/chatbot/faiss_index/index.faiss
Binary file not shown.
Binary file modified server_api/chatbot/faiss_index/index.pkl
Binary file not shown.
34 changes: 34 additions & 0 deletions server_api/chatbot/file_summaries/App.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# client/src/App.js

Root component of the PyTC Client application. Wraps the app in context providers and performs cache clearing on boot.

## Structure

```
App
├── ContextWrapper (GlobalContext)
│ └── YamlContextWrapper (YamlContext)
│ └── CacheBootstrapper
│ └── MainContent (Views)
```

## Components

### `CacheBootstrapper`

- Runs `resetFileState()` from `AppContext` on mount
- Clears local cache (files, fileList, etc.) before rendering children
- Renders nothing until cache is cleared; then renders main content

### `MainContent`

- Renders `Views` component (main application layout with tabs)

## Contexts

- **AppContext** — Global state (files, configs, paths, etc.)
- **YamlContext** — YAML-specific state (GPUs, batch size, etc.)

## Usage

Used as the root in `index.js` via `ReactDOM.createRoot`.
55 changes: 55 additions & 0 deletions server_api/chatbot/file_summaries/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# client/src/api.js

Central API client for the PyTC Client frontend. Exposes functions for all backend communication.

## API Base URL

`${REACT_APP_SERVER_PROTOCOL || "http"}://${REACT_APP_SERVER_URL || "localhost:4242"}`

## Exports

### `apiClient`

Axios instance with base URL, `withCredentials: true`. Used for general requests (e.g. `/files`, `/files/upload`).

### Visualization

- **`getNeuroglancerViewer(image, label, scales)`** — Launches Neuroglancer viewer. Accepts file objects or path strings. Uses FormData for browser uploads.

### File Checks

- **`checkFile(file)`** — POST to `/check_files` to detect if file is likely a label (heuristic).

### Generic

- **`makeApiRequest(url, method, data)`** — HTTP request helper with JSON Content-Type.

### Model Training

- **`startModelTraining(trainingConfig, logPath, outputPath)`** — Injects OUTPUT_PATH into YAML config and POSTs to `/start_model_training`
- **`stopModelTraining()`**
- **`getTrainingStatus()`**
- **`getTensorboardURL()`**

### Model Inference

- **`startModelInference(inferenceConfig, outputPath, checkpointPath)`** — Injects OUTPUT_PATH into YAML, sets NUM_GPUS=1, POSTs to `/start_model_inference`
- **`stopModelInference()`**
- **`getInferenceStatus()`**

### Chatbot

- **`queryChatBot(query)`** — POST to `/chat/query`
- **`clearChat()`** — POST to `/chat/clear`

### Config Presets

- **`getConfigPresets()`** — GET `/pytc/configs`
- **`getConfigPresetContent(path)`** — GET `/pytc/config`
- **`getModelArchitectures()`** — GET `/pytc/architectures`

## Helper Functions

- `buildFilePath(file)` — Extracts path from various file object shapes ( Ant Design Upload, folderPath+name, etc.)
- `hasBrowserFile(file)` — Checks if file is a browser File object
- `handleError(error)` — Throws errors with response detail when available
150 changes: 0 additions & 150 deletions server_api/chatbot/file_summaries/backend/main.md

This file was deleted.

70 changes: 15 additions & 55 deletions server_api/chatbot/file_summaries/components/Chatbot.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,25 @@
# Chatbot Component
# client/src/components/Chatbot.js

## Overview

The ChatBot component provides an AI-powered conversational interface for user support and assistance. It integrates with a RAG (Retrieval-Augmented Generation) backend to provide intelligent responses about the PyTorch Connectomics platform.

## Functionality

- **Real-time Chat Interface**: Provides a full-screen chat interface with message history
- **Session Management**: Creates and maintains chat sessions with unique session IDs
- **Message Persistence**: Saves chat history and session data in localStorage
- **AI Integration**: Connects to backend RAG system for intelligent responses
- **User Experience**: Clean, modern UI with message bubbles and typing indicators

## Key Features

- **Session-based Conversations**: Each chat session maintains context and memory
- **Message History**: Persistent storage of conversation history
- **Error Handling**: Graceful error handling for network issues
- **Responsive Design**: Full-height layout with proper scrolling
- **Input Validation**: Prevents empty message sending
AI assistant panel for helping users navigate PyTC Client. Renders a chat UI with message history, Markdown rendering, and server-backed responses.

## Props

- `onClose`: Function to close the chat interface

## State Management

- `messages`: Array of chat messages with user/bot distinction
- `inputValue`: Current text input value
- `sessionId`: Unique identifier for the chat session
- `isSending`: Boolean indicating if a message is being processed

## API Integration

- **createChatSession()**: Creates a new chat session with the backend
- **queryChatBot(sessionId, query)**: Sends user queries to the AI assistant

## User Interactions

1. **Opening Chat**: Click the message icon to open the chat interface
2. **Sending Messages**: Type in the text area and press Enter or click Send
3. **Session Persistence**: Chat history is automatically saved and restored
4. **Closing Chat**: Click the X button to close the interface
- **`onClose`** — Callback when user closes the chat (e.g. drawer)

## Technical Implementation
## Features

- Uses Ant Design components for UI consistency
- Implements proper cleanup with useEffect hooks
- Handles async operations with proper error boundaries
- Manages local storage for data persistence
- **Message persistence** — Saves messages to `localStorage` under `chatMessages`
- **Markdown rendering** — Uses `react-markdown` with `remarkGfm` for lists, tables, code blocks
- **Keyboard shortcut** — Enter (without Shift) sends message
- **Clear chat** — Popconfirm to clear; calls `clearChat()` API and resets to initial greeting

## Use Cases
## API Calls

- **User Support**: Help users navigate the platform and understand features
- **Troubleshooting**: Assist with common issues and error resolution
- **Feature Guidance**: Provide step-by-step instructions for complex workflows
- **Documentation Access**: Answer questions about platform capabilities
- `queryChatBot(query)` — Sends user message, displays response
- `clearChat()` — Clears server-side history and local state

## Integration Points
## UI Layout

- **Global Context**: Accesses shared application state
- **API Layer**: Communicates with backend RAG system
- **Local Storage**: Persists user data across sessions
- **UI Framework**: Integrates with Ant Design component library
- Header: "AI Assistant" title, Clear button, Close button
- Scrollable message list (user messages right-aligned, blue; bot messages left-aligned, gray)
- TextArea + Send button at bottom
Loading
Loading