ℹ️ The code was modified to handle a case where the `template` attribute is not present in the `PromptVertex` class. If the `template` attribute is not found, the code checks if the `prompt` attribute is present and uses its `template` attribute instead. This change ensures that the code does not break when the `template` attribute is missing.
🐛 fix(base.py): change the error message when _built_object is None to provide more specific information and handle the case when _built_object is an instance of UnbuiltObject
🐛 fix(directory_reader.py): return False if code is not valid Python to prevent false positives
🐛 fix(directory_reader.py): fix method name from is_type_hint_used_but_not_imported to _is_type_hint_used_in_args for consistency
🐛 fix(directory_reader.py): fix method name from is_type_hint_imported to _is_type_hint_imported for consistency
🐛 fix(directory_reader.py): fix return value of _is_type_hint_used_in_args method to return False if type hint is used but not imported
✨ feat(OpenAIConversationalAgent.py): add support for return_intermediate_steps parameter in AgentExecutor constructor to enable returning intermediate steps during conversation
This commit adds a new file `ConversationalAgent.py` to the `src/backend/langflow/components/agents` directory. The `ConversationalAgent` class is a custom component that represents a conversational agent capable of using OpenAI's function calling API.
The `ConversationalAgent` class has the following features:
- It inherits from the `CustomComponent` class.
- It has a `display_name` attribute set to "OpenaAI Conversational Agent".
- It has a `description` attribute set to "Conversational Agent that can use OpenAI's function calling API".
- It implements the `build_config` method to define the configuration options for the agent.
- It implements the `build` method to create an instance of the `AgentExecutor` class, which represents the agent's execution environment.
- The `build` method takes several parameters, including `model_name`, `tools`, `memory`, `system_message`, and `max_token_limit`.
- It uses the `ChatOpenAI` class from the `langchain.chat_models` module to create an instance of the OpenAI language model.
- It uses the `ConversationTokenBufferMemory` class from the `langchain.memory.token_buffer` module to handle conversation history and token buffering.
- It uses the `OpenAIFunctionsAgent` class from the `langchain.agents.openai_functions_agent.base` module to create an instance of the OpenAI functions agent.
- It returns an instance of the `AgentExecutor` class with the agent, tools, memory, verbose, and return_intermediate_steps parameters set.
📝 feat(__init__.py): add empty __init__.py file to the agents directory
This commit adds an empty `__init__.py` file to the `src/backend/langflow/components/agents` directory. The `__init__.py` file is necessary to make the `agents` directory a Python package.
📝 WHY: The addition of BaseMemory to LANGCHAIN_BASE_TYPES allows for the customization of the memory component in the Langchain interface. This enables users to implement their own memory functionality according to their specific needs.
🐛 fix(test_custom_component.py): update assertion to expect return_type as a list instead of a string
🐛 fix(test_vectorstore_template.py): update assertion to check if all vectorstores in settings are present in the response
🔧 chore(Metaphor.py): update search method to use the provided parameters for use_autoprompt and search_num_results
🔧 chore(Metaphor.py): update find_similar method to use the provided parameter for similar_num_results
🐛 fix(Metaphor.py): ignore type error for returning a list with mixed types
🐛 fix(Vectara.py): add condition to check if documents and embedding are not None before creating Vectara instance
🐛 fix(CustomComponent.py): change return type of get_function_entrypoint_return_type to List[str] to match the actual return value
The MetaphorToolkit component is added to the langflow toolkit. It provides functionality for searching metaphors using the Metaphor API. The component includes three tools: search, get_contents, and find_similar. The search tool allows users to search for metaphors using a query. The get_contents tool retrieves the contents of a webpage based on the ids returned from the search tool. The find_similar tool finds search results similar to a given URL returned from the search tool.
The MetaphorToolkit component is still in beta and requires a Metaphor API key to function. The API key is stored securely and can be configured in the field_config of the component. For more information, refer to the documentation: [Metaphor Toolkit Documentation](https://python.langchain.com/docs/integrations/tools/metaphor_search)
✨ feat(Vectara.py): add VectaraComponent to implement Vector Store using Vectara
🔧 chore(vectorstores): add empty __init__.py file to the vectorstores directory