Skip to content

Conversation

@OscarCasadoLorenzo
Copy link
Owner

This pull request introduces a conversational AI assistant panel to the PDF viewer application, enabling users to interact with PDF documents through natural language queries. The assistant leverages OpenAI to analyze PDF content, extract structured data, and display relevant information and coordinate-based markers on the document. The changes also add new state management for conversation and structured PDF data, and refactor the UI to accommodate the conversation panel alongside the PDF viewer.

Conversational AI Assistant Integration

  • Added the ConversationPanel component, which provides a chat interface for users to ask questions about the PDF document and receive AI-generated responses. The panel manages conversation state, loading indicators, and user input.
  • Implemented a conversation handler utility (conversationHandler.ts) that interacts with OpenAI, analyzes PDF content, extracts coordinate-based data, and updates OCR markers in response to user queries.
  • Created supporting components for the chat UI, including MessageBubble for displaying messages and TypingIndicator for showing loading states. [1] [2]

State Management Enhancements

  • Added new Jotai atoms for managing conversation messages, input, loading state, OCR markers, and structured PDF data, enabling reactive updates across the application. [1] [2]

Structured PDF Data Support

  • Introduced new types (PDFTextBlock, PDFStructuredData) to represent extracted text blocks and document metadata, facilitating more advanced PDF analysis and interaction.
  • Updated the PDF viewer and related components to utilize the new structured data and state atoms. [1] [2]

UI Layout and Integration

  • Refactored the main App.tsx layout to display the conversation panel alongside the PDF viewer, with improved alignment and spacing for a cohesive user experience. [1] [2] [3]

Module Organization

  • Exported new conversation-related components and types for use throughout the application.…tor components for conversation UI
  • Implemented MessageBubble component to display user and assistant messages with timestamps and avatars. - Created TypingIndicator component to show a typing animation for the assistant. - Updated conversation index to export new components. feat: Define conversation types and utility functions - Added ConversationMessage and ConversationPanelProps interfaces for type safety. - Introduced PDFConversationHandler class for handling messages with PDF context and extracting structured data. feat: Enhance PDF handling in PdfPage component - Extract structured data from rendered text layers and store it in state. - Updated PDF structured data management to include text blocks and metadata. fix: Improve OCRMarkers component to display AI-generated markers - Integrated AI-generated OCR markers into the Markers component. - Added user feedback when no markers are available. docs: Create README for OpenAI integration - Documented setup, usage, and error handling for OpenAI document analysis service. - Provided examples and response structures for clarity. feat: Implement OpenAI document analysis service - Developed OpenAIDocumentService class for analyzing PDF content and extracting structured data. - Added validation for API responses and connection testing functionality.

…nents for conversation UI

- Implemented MessageBubble component to display user and assistant messages with timestamps and avatars. - Created TypingIndicator component to show a typing animation for the assistant. - Updated conversation index to export new components.  feat: Define conversation types and utility functions  - Added ConversationMessage and ConversationPanelProps interfaces for type safety. - Introduced PDFConversationHandler class for handling messages with PDF context and extracting structured data.  feat: Enhance PDF handling in PdfPage component  - Extract structured data from rendered text layers and store it in state. - Updated PDF structured data management to include text blocks and metadata.  fix: Improve OCRMarkers component to display AI-generated markers  - Integrated AI-generated OCR markers into the Markers component. - Added user feedback when no markers are available.  docs: Create README for OpenAI integration  - Documented setup, usage, and error handling for OpenAI document analysis service. - Provided examples and response structures for clarity.  feat: Implement OpenAI document analysis service  - Developed OpenAIDocumentService class for analyzing PDF content and extracting structured data. - Added validation for API responses and connection testing functionality.
@OscarCasadoLorenzo OscarCasadoLorenzo self-assigned this Sep 1, 2025
@OscarCasadoLorenzo OscarCasadoLorenzo linked an issue Sep 1, 2025 that may be closed by this pull request
25 tasks
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request introduces a conversational AI assistant feature to the PDF viewer application, enabling users to interact with PDF documents through natural language queries. The assistant uses OpenAI's structured outputs to analyze PDF content and extract coordinate-based information that integrates with the existing OCR marker system.

  • Integration of OpenAI service for document analysis with structured outputs
  • Addition of conversation UI components including chat panel, message bubbles, and typing indicators
  • Enhanced PDF data extraction to capture structured text blocks with coordinates for improved AI analysis

Reviewed Changes

Copilot reviewed 17 out of 18 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/services/openai/types.ts Defines TypeScript interfaces and schema for OpenAI document analysis API
src/services/openai/documentService.ts Core OpenAI service implementation for PDF document analysis
src/services/openai/README.md Comprehensive documentation for OpenAI integration setup and usage
src/features/conversation/utils/conversationHandler.ts Handler utility for managing AI conversations with PDF context
src/features/conversation/components/ConversationPanel.tsx Main conversation UI component with message handling
src/features/conversation/components/MessageBubble.tsx Individual message display component
src/features/conversation/components/TypingIndicator.tsx Loading animation component for assistant responses
src/features/pdfViewer/components/PdfPage.tsx Enhanced PDF page component to extract structured text data
src/features/pdfViewer/components/ocr-markers/OCRMarkers.tsx Updated markers component to display AI-generated results
src/data/types.ts New type definitions for PDF structured data
src/data/atoms.ts Additional Jotai atoms for conversation and structured data state
src/App.tsx Main application layout integration of conversation panel

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

return
}

console.log('a')
Copy link

Copilot AI Sep 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this debug console.log statement that was likely left in by mistake.

Suggested change
console.log('a')

Copilot uses AI. Check for mistakes.
<EyeIcon color={'primary.700'} />
)}
</InputLeftAddon>
<Input disabled={true} value={ocrMark.text}></Input>
Copy link

Copilot AI Sep 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Use the more idiomatic disabled prop instead of disabled={true} for boolean attributes.

Suggested change
<Input disabled={true} value={ocrMark.text}></Input>
<Input disabled value={ocrMark.text}></Input>

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generate OCRMarkers with AI and provided text

2 participants