How varunshenoy/graphgpt works
Main Components
• Frontend Application:
• This is the core of the project, implemented in React (files in the src folder like App.js, index.js) along with public assets (index.html, manifest.json, robots.txt).
• Prompts Module:
• Located in the public/prompts directory, these files contain the instructions (few-shot prompts) guiding GPT-3 on how to format the JSON output for graph rendering.
• External Service – OpenAI API:
• Although not directly represented in the file tree, the README describes using the OpenAI API for interpreting natural language input.
• Graph Visualization:
• The use of react-graph-vis indicates that the output from the AI is rendered as a graph through this library component.
• User Interface Components:
• UI interactions such as inputting text queries, viewing demo GIFs, and receiving feedback from the API.
Relationships and Interactions
• User Interaction Layer:
• Users interact with the React frontend (enter text and trigger queries).
• Data flows from user inputs to the core application.
• Application Logic:
• The React app processes the input, triggers a call to the OpenAI API using the provided API key.
• The request payload incorporates one of the predetermined prompts from the public/prompts folder.
• External Communication:
• The application receives the response from the OpenAI API that includes JSON-formatted graph data.
• Graph Rendering:
• The received JSON-fed data is handled by the react-graph-vis component to render the knowledge graph.
• State Management:
• Successive queries either update or create new graph structures, indicating an underlying state management mechanism that tracks the graph's evolution.
Architectural Patterns and Technologies
• Single Page Application (SPA) pattern implemented in React.
• External API Consumption:
• Integration with OpenAI API to process natural language.
• Modular Prompt Configuration:
• Storing and organizing prompt files separately to guide behavior of the API calls.
• Graph Rendering:
• Use of react-graph-vis as a library to isolate visualization from business logic.
• Asynchronous Data Flow:
• Handle API latency (noted as up to 20 seconds) with proper asynchronous calls and UI feedback.
Additional Elements to Capture
• Configuration points (like environment variables or API key input) that affect the system.
• Where the application deals with network latency and error handling.
• On how state is managed, possibly within the React application, to capture successive modifications on the knowledge graph.