### Visualize ChromaDB Collection Source: https://github.com/mtybadger/chromaviz/blob/main/_autodocs/api-reference/visualize_collection.md This example demonstrates how to create a ChromaDB collection, populate it with data, and then visualize it using the `visualize_collection` function. Ensure you have chromadb and chromaviz installed. ```python import chromadb from chromaviz import visualize_collection # Create and populate a ChromaDB collection client = chromadb.Client() collection = client.get_or_create_collection(name="my_docs") collection.add( documents=["Hello world", "Goodbye world"], metadatas=[{"source": "greeting"}, {"source": "farewell"}], ids=["id1", "id2"] ) # Visualize the collection visualize_collection(collection, port=5000) ``` -------------------------------- ### Three.js Camera Initial Setup Source: https://github.com/mtybadger/chromaviz/blob/main/_autodocs/configuration.md Configure the initial position of the Three.js camera within the ThreePointViz component. This setup determines the starting viewpoint for the 3D visualization. ```javascript ``` -------------------------------- ### Configuration Options Source: https://github.com/mtybadger/chromaviz/blob/main/_autodocs/REFERENCE_INDEX.md Examples of common configuration parameters for visualization and dimensionality reduction. ```python visualize_collection(col, port=5000) ``` ```python PCA(n_components=50) ``` ```python TSNE(perplexity=40, n_iter=300) ``` ```python AppSettings {showDocuments, ...} ``` -------------------------------- ### Example GET /data Request Source: https://github.com/mtybadger/chromaviz/blob/main/_autodocs/endpoints.md This snippet shows how to make a request to the /data endpoint using curl. No request body or query parameters are required. ```bash curl http://127.0.0.1:5000/data ``` -------------------------------- ### GET / Source: https://github.com/mtybadger/chromaviz/blob/main/_autodocs/REFERENCE_INDEX.md Serves the main application interface. ```APIDOC ## GET / ### Description Serves the main application interface. ### Method GET ### Endpoint / ### Response #### Success Response (200) - Serves the main HTML page for the application. ``` -------------------------------- ### GET / Endpoint Source: https://github.com/mtybadger/chromaviz/blob/main/_autodocs/api-reference/flask_app.md Serves the main HTML interface for the visualization. Loads from 'chromaviz/index.html' using importlib.resources. ```python @app.route("/") def hello_world() ``` ```python response = requests.get("http://127.0.0.1:5000/") # Returns HTML page with 3D visualization interface ``` -------------------------------- ### Start Visualization with Specific Port Source: https://github.com/mtybadger/chromaviz/blob/main/_autodocs/endpoints.md Call this Python function to start the Flask app and open the visualization in a browser. Specify the desired port for the Flask server. ```python visualize_collection(collection, port=5000) ``` -------------------------------- ### Example GET /data Response Structure Source: https://github.com/mtybadger/chromaviz/blob/main/_autodocs/endpoints.md This JSON structure represents a successful response from the /data endpoint. It contains an array of points, each with its 3D position, original document text, metadata, ID, and group assignment. ```json { "points": [ { "position": [0.82, -1.34, 0.56], "document": "The quick brown fox jumps over the lazy dog", "metadata": { "source": "animals.txt", "category": "mammals" }, "id": "doc_001", "group": 5 }, { "position": [-0.45, 0.91, -0.23], "document": "A journey of a thousand miles begins with a single step", "metadata": { "source": "quotes.txt", "author": "Lao Tzu" }, "id": "doc_002", "group": 12 } ] } ``` -------------------------------- ### Basic ChromaViz Visualization Source: https://github.com/mtybadger/chromaviz/blob/main/_autodocs/OVERVIEW.md Visualize a ChromaDB collection using the default settings. Ensure chromadb and chromaviz are installed. ```python import chromadb from chromaviz import visualize_collection client = chromadb.Client() collection = client.get_or_create_collection("documents") # Add documents with embeddings... visualize_collection(collection) ``` -------------------------------- ### App Component Usage Source: https://github.com/mtybadger/chromaviz/blob/main/_autodocs/api-reference/react_components.md Example of how to import and render the App component in a React application using ReactDOM. ```jsx import App from './App.jsx' import ReactDOM from 'react-dom/client' ReactDOM.createRoot(document.getElementById('root')).render() ``` -------------------------------- ### Initialize and Visualize ChromaDB Collection Source: https://github.com/mtybadger/chromaviz/blob/main/_autodocs/OVERVIEW.md Use this snippet to initialize a ChromaDB collection, add documents with embeddings and metadata, and then visualize the collection using ChromaViz. Ensure ChromaDB is installed and accessible. ```python from chromaviz import visualize_collection import chromadb collection = chromadb.Client().get_or_create_collection("docs") collection.add( documents=["text1", "text2"], metadatas=[{"key": "value"}, {}], embeddings=[[...], [...]] # High-dimensional vectors ) visualize_collection(collection, port=5000) ``` -------------------------------- ### Configure ChromaDB Client Settings Source: https://github.com/mtybadger/chromaviz/blob/main/_autodocs/configuration.md Example of configuring ChromaDB client settings, specifically disabling anonymized telemetry. ```python from chromadb.config import Settings settings = Settings( anonymized_telemetry=False # Disable telemetry ) client = chromadb.Client(settings=settings) ``` -------------------------------- ### ButtonGroup Usage Example Source: https://github.com/mtybadger/chromaviz/blob/main/_autodocs/api-reference/react_components.md Shows how to integrate the ButtonGroup component into the application. It expects a 'settings' prop which is a tuple containing the current settings object and a function to update it. ```jsx ``` -------------------------------- ### Footer Component Usage Source: https://github.com/mtybadger/chromaviz/blob/main/_autodocs/api-reference/react_components.md Example of how to use the Footer component in your application, passing the settings state tuple. ```jsx