huggingface / chat-ui

Open source codebase powering the HuggingChat app
https://huggingface.co/chat
Apache License 2.0
7.31k stars 1.06k forks source link

Make the google endpoints use optional dependencies #1467

Open nsarrazin opened 2 weeks ago

nsarrazin commented 2 weeks ago

Most endpoints use the following kind of logic to ensure the app does not break if the package is not installed:

    let BedrockRuntimeClient, InvokeModelWithResponseStreamCommand;
    try {
        ({ BedrockRuntimeClient, InvokeModelWithResponseStreamCommand } = await import(
            "@aws-sdk/client-bedrock-runtime"
        ));
    } catch (error) {
        throw new Error("Failed to import @aws-sdk/client-bedrock-runtime. Make sure it's installed.");
    }

The only exceptions are the GenAI and Vertex endpoints under endpoints/google

This is because of the HarmBlockThreshold enum which is used in our zod schema used to validate the endpoint definition. Not sure what the best way is to deal with this, could we just hardcode the values?