Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does anyone created agent with tool which takes "dataframe" and "user_input" as input variables in langchain? #10028

Closed
bmshambu opened this issue Aug 31, 2023 · 3 comments
Labels
Ɑ: agent Related to agents module 🤖:question A specific question about the codebase, product, project, or how to use a feature

Comments

@bmshambu
Copy link

Issue you'd like to raise.

Does anyone created agent with tool which takes "dataframe" and "user_input" as input variables in langchain?
I do not want use dataframe agent which is there already in langchain. As I need pass further instruction in the prompt template.

Suggestion:

No response

@dosubot dosubot bot added Ɑ: agent Related to agents module 🤖:question A specific question about the codebase, product, project, or how to use a feature labels Aug 31, 2023
@dosubot
Copy link

dosubot bot commented Aug 31, 2023

🤖

Hello,

Yes, it is indeed possible to create an agent in LangChain that accepts both a "dataframe" and "user_input" as input variables. You can achieve this by modifying the create_prompt method in the StructuredChatAgent class to include "dataframe" and "user_input" in the input_variables list. Here's how you can do it:

@classmethod
def create_prompt(
    cls,
    tools: Sequence[BaseTool],
    prefix: str = PREFIX,
    suffix: str = SUFFIX,
    human_message_template: str = HUMAN_MESSAGE_TEMPLATE,
    format_instructions: str = FORMAT_INSTRUCTIONS,
    input_variables: Optional[List[str]] = None,
    memory_prompts: Optional[List[BasePromptTemplate]] = None,
) -> BasePromptTemplate:
    # ... existing code ...

    if input_variables is None:
        input_variables = ["dataframe", "user_input", "agent_scratchpad"]

    # ... existing code ...

In the above code, we have modified the input_variables list to include "dataframe" and "user_input". This will allow the agent to accept both a dataframe and user input as input variables.

You can find the StructuredChatAgent class in the LangChain codebase at libs/langchain/langchain/agents/structured_chat/base.py.

Please note that this modification will affect all instances of StructuredChatAgent that do not provide their own input_variables list. If you want to limit this change to a specific agent, you can subclass StructuredChatAgent and override the create_prompt method in your subclass.

I hope this helps! If you have any further questions, feel free to ask.

Best regards,
Dosu

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@bmshambu
Copy link
Author

I have requirement like this I need generate insights from the data frame table where i create two tools
one tool takes df and user input in case user wants to generate insights on Area. i will configure area related prompt inside the tool.
And one more tool takes df and user input in case user user wants to generate insights on Serviceline. i will configure area related prompt inside the tool.

Copy link

dosubot bot commented Nov 30, 2023

Hi, @bmshambu! I'm Dosu, and I'm here to help the LangChain team manage our backlog. I wanted to let you know that we are marking this issue as stale.

From what I understand, you were asking if anyone has created an agent in LangChain that takes a dataframe and user input as input variables. There hasn't been any response or suggestion provided yet, but I have given a helpful response. I explained how to modify the create_prompt method in the StructuredChatAgent class to include the desired input variables. You, as the original author, have also provided additional details about your specific requirements.

If this issue is still relevant to the latest version of the LangChain repository, please let us know by commenting on this issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days.

Thank you for your understanding and contribution to the LangChain project! If you have any further questions or need assistance, feel free to reach out.

@dosubot dosubot bot added the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Nov 30, 2023
@dosubot dosubot bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 7, 2023
@dosubot dosubot bot removed the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ɑ: agent Related to agents module 🤖:question A specific question about the codebase, product, project, or how to use a feature
Projects
None yet
Development

No branches or pull requests

1 participant