Add WolframAlphaAPIWrapper with appid configuration

This commit is contained in:
anovazzi1 2024-01-16 00:28:22 -03:00
commit 1c7eb2cf0f

View file

@ -1,7 +1,7 @@
from langflow import CustomComponent
from typing import Callable, Union
from langchain_community.utilities.wolfram_alpha import WolframAlphaAPIWrapper
# Since all the fields in the JSON have show=False, we will only create a basic component
# without any configurable fields.
@ -10,13 +10,9 @@ class WolframAlphaAPIWrapperComponent(CustomComponent):
description = "Wrapper for Wolfram Alpha."
def build_config(self):
# No fields with show=True are available according to the JSON configuration,
# so we return an empty config.
return {}
return {
"appid": {"display_name": "App ID", "type": "str", "password": True}
}
def build(self) -> Union[Callable, object]:
# Since we are not given any specific implementation details or associated classes,
# we will simply return an object that represents the WolframAlphaAPIWrapper without
# initializing any specific fields. In a real scenario, this would be replaced with
# the actual instantiation of the WolframAlphaAPIWrapper class.
return object() # Placeholder for actual WolframAlphaAPIWrapper class instantiation.
def build(self,appid:str) -> Union[Callable, WolframAlphaAPIWrapper]:
return WolframAlphaAPIWrapper(wolfram_alpha_appid=appid)