can you fix this error in my code:
File "/home/rz1/venvs/python_env/lib/python3.12/site-packages/sklearn/decomposition/_pca.py", line 547, in _fit
    return self._fit_full(X, n_components, xp, is_array_api_compliant)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rz1/venvs/python_env/lib/python3.12/site-packages/sklearn/decomposition/_pca.py", line 561, in _fit_full
    raise ValueError(
ValueError: n_components=3 must be between 0 and min(n_samples, n_features)=2 with svd_solver='full'
127.0.0.1 - - [25/Sep/2024 14:15:08] "POST /compute HTTP/1.1" 500 -

mycode:
import os
from flask import Flask, request, jsonify
from openai import OpenAI
import numpy as np
from sklearn.decomposition import PCA
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import io
import base64

app = Flask(__name__)

client = OpenAI()

def get_embedding(text, model="text-embedding-ada-002"):
    text = text.replace("\n", " ")
    response = client.embeddings.create(input=[text], model=model)
    return response.data[0].embedding

@app.route('/')
def index():
    html = '''
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>3D Vector Visualizer</title>
        <style>
            body {
                font-family: Arial, sans-serif;
                display: flex;
                flex-direction: column;
                align-items: center;
                justify-content: center;
                height: 100vh;
                background-color: #f8f9fa;
            }
            .container {
                text-align: center;
                margin-top: 50px;
            }
            .input-box {
                margin: 10px;
            }
            #result {
                margin-top: 30px;
            }
        </style>
    </head>
    <body>
    <div class="container">
        <h1>3D Vector Visualizer</h1>
        <div class="input-box">
            <label for="string1">Input String 1:</label>
            <input type="text" id="string1" name="string1">
        </div>
        <div class="input-box">
            <label for="string2">Input String 2:</label>
            <input type="text" id="string2" name="string2">
        </div>
        <button onclick="submitStrings()">Submit</button>
        <div id="result"></div>
    </div>
    
    <script>
        async function submitStrings() {
            const string1 = document.getElementById('string1').value;
            const string2 = document.getElementById('string2').value;
    
            const response = await fetch('/compute', {
                method: 'POST',
                headers: { 'Content-Type': 'application/json' },
                body: JSON.stringify({ string1, string2 })
            });
    
            const result = await response.json();
            const img = document.createElement('img');
            img.src = 'data:image/png;base64,' + result.img;
            img.alt = '3D Plot';
            document.getElementById('result').innerHTML = '';
            document.getElementById('result').appendChild(img);
        }
    </script>
    </body>
    </html>
    '''
    return html

@app.route('/compute', methods=['POST'])
def compute():
    data = request.json
    string1 = data['string1']
    string2 = data['string2']
    
    # Get embeddings from OpenAI
    embeddings1 = get_embedding(string1)
    embeddings2 = get_embedding(string2)
    
    combined_embeddings = np.array([embeddings1, embeddings2])
    
    # Adjust n_components dynamically
    n_components = min(3, combined_embeddings.shape[0], combined_embeddings.shape[1])
    pca = PCA(n_components=n_components)
    reduced_embeddings = pca.fit_transform(combined_embeddings)
    
    img = plot_3d(reduced_embeddings, [string1, string2])
    
    return jsonify({'img': img})

def plot_3d(points, labels):
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    
    xs, ys, zs = points[:, 0], points[:, 1], points[:, 2] if points.shape[1] > 2 else (points[:, 0], points[:, 1], np.zeros(points.shape[0]))
    
    ax.scatter(xs, ys, zs, c='r', marker='o')
    
    for i, label in enumerate(labels):
        ax.text(xs[i], ys[i], zs[i], '%s' % (label), size=20, zorder=1, color='k')
    
    ax.set_xlabel('X')
    ax.set_ylabel('Y')
    ax.set_zlabel('Z')
    
    img = io.BytesIO()
    plt.savefig(img, format='png')
    plt.close(fig)
    img.seek(0)
    
    plot_url = base64.b64encode(img.getvalue()).decode()
    
    return plot_url

if __name__ == '__main__':
    app.run(port=5005)