GerevAI / gerev

🧠 AI-powered enterprise search engine 🔎
https://app.klu.so/signup?utm_source=github_gerevai
MIT License
2.71k stars 178 forks source link

No image found for data source causes UI bugs #84

Closed Itaykal closed 1 year ago

Itaykal commented 1 year ago

When there's no image for at least one of the data sources the UI wont load any data source. This bug originates in app/api/data_source.py in line 33:

@staticmethod
    def from_data_source_class(name: str, data_source_class: BaseDataSource) -> 'DataSourceTypeDto':
        with open(f"static/data_source_icons/{name}.png", "rb") as file:
            encoded_string = base64.b64encode(file.read())
            image_base64 = f"data:image/png;base64,{encoded_string.decode()}"

        return DataSourceTypeDto(
            name=name,
            display_name=data_source_class.get_display_name(),
            config_fields=data_source_class.get_config_fields(),
            image_base64=image_base64,
            has_prerequisites=data_source_class.has_prerequisites()
        )

The function is lacking error handling, handle the errors and fix it.