Closed jsbryaniv closed 10 months ago
@dosu-beta what is the process for integrating this into the core of LangChain? Is there a process for strategizing with a more experienced person?
I also think that this is more related to prompts than agents.
π€
Hello,
Thank you for your interest in adding a decision tree/flow chart-like prompt architecture to LangChain. This is a great idea and can indeed improve the chatbot workflows.
Based on your description, it seems like you want to add a new type of action that represents a decision node in your flow chart. This can be done by modifying the prompt.py
file to include a new action type. Here's an example of how you might modify the FORMAT_INSTRUCTIONS
string to include a new "Decision Node" action:
FORMAT_INSTRUCTIONS = """Use a json blob to specify a tool by providing an action key (tool name) and an action_input key (tool input).
Valid "action" values: "Final Answer", "Decision Node" or {tool_names}
Provide only ONE action per $JSON_BLOB, as shown:
{{{{ "action": $TOOL_NAME, "action_input": $INPUT }}}}
For a "Decision Node", the action_input should be another json blob that specifies the condition and the actions for each outcome:
{{{{ "action": "Decision Node", "action_input": {{{{ "condition": $CONDITION, "true_action": $TRUE_ACTION, "false_action": $FALSE_ACTION }}}} }}}}
Follow this format:
Question: input question to answer
Thought: consider previous and subsequent steps
Action:
$JSON_BLOB
Observation: action result
... (repeat Thought/Action/Observation N times)
Thought: I know what to respond
Action:
{{{{ "action": "Final Answer", "action_input": "Final response to human" }}}}
In this example, $CONDITION
is a string that represents the condition for the decision, and $TRUE_ACTION
and $FALSE_ACTION
are json blobs that represent the actions to take if the condition is true or false, respectively. These actions can be any valid action, including another "Decision Node".
Please note that you will also need to modify the code that processes the actions to handle the new "Decision Node" action type. This will likely involve writing a function that evaluates the condition and executes the appropriate action.
As for where this should belong in the object hierarchy, it would be best to place this new functionality within the prompt.py
file, as it directly relates to how prompts are processed and handled.
I hope this helps! If you have any further questions or need more clarification, please don't hesitate to ask.
Best, Dosu
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.
@dosu-bot I meant is there a guideline for how to talk to a human more experienced than me about how I can contribute? I saw the first step is to open an issue, which is what I did here, but what is the next step? Do I just fork and push the proposed change? I would prefer to talk to someone ahead to time to make sure I do it right.
π€
Hello,
Thank you for your interest in contributing to LangChain. Your proposed feature sounds interesting and potentially very useful.
After opening an issue, the next step is indeed to fork the repository and start working on your proposed changes. However, it's understandable that you might want to discuss your ideas with a more experienced person before proceeding.
In the LangChain project, we encourage open discussion and collaboration. You can start a conversation about your proposed feature in the issue you've opened. This way, maintainers and other contributors can provide feedback and guidance. You can also directly contact a maintainer or send an email to hello@langchain.dev for more in-depth discussions.
When you're ready to submit your changes, please follow the "fork and pull request" workflow. Make sure your pull request follows the checked-in pull request template and passes the formatting, linting, and testing checks. If you're adding a feature, please also add a demo notebook in docs/modules
and add unit and integration tests.
If you encounter any difficulties or have any questions about the process, don't hesitate to reach out. We're here to help and we appreciate your contribution to LangChain.
Best, Dosu
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.
@dosu-bot How do I find a "maintainer" to contact about my feature proposal?
π€
Hello,
Thank you for your interest in contributing to the LangChain project. Your feature proposal for a decision tree/flow chart-like prompt architecture sounds intriguing and could potentially add significant value to the project.
To discuss your feature proposal with someone experienced, you can directly contact the maintainers of the LangChain project. Based on the information provided, the current maintainers are:
You can mention them in the issue you opened by using their GitHub usernames preceded by the "@" symbol. This will notify them about your message. You can also directly send them a message through GitHub.
Please make sure to provide as much detail as possible about your proposed feature, including the sample script you mentioned. This will help the maintainers understand your proposal better and provide more constructive feedback.
Remember, it's important to be patient as maintainers often have many responsibilities and it may take some time for them to respond.
I hope this helps and I look forward to seeing your feature proposal implemented in LangChain!
Best, Dosu
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.
cross referencing: https://github.com/langchain-ai/langchain/discussions/10010
Hello, I wanted to know if this idea mentioned in this post would be something that would be helpful for LangChain, and if so what the steps would be to contribute to include something like this in the core of LangChain. I have never contributed to open source code before so I dont know how to get started. @aronweiler @howtodoml @eyurtsev @agola11 @hwchase17
Hi, @jsbryaniv,
I'm helping the LangChain team manage their backlog and am marking this issue as stale. From what I understand, you opened this issue to request functionality for a decision tree/flow chart-like prompt architecture to be incorporated into LangChain. Detailed instructions on how to modify the prompt.py
file to include the new feature have been provided, and collaboration has been encouraged. Additionally, it was suggested to contact the maintainers, including @hwchase17, @agola11, and @eyurtsev, to discuss the proposal.
Could you please confirm if this issue is still relevant to the latest version of the LangChain repository? If it is, please let the LangChain team know by commenting on the issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days.
Thank you for your understanding and cooperation.
Hi, any update on this feature?
+1 any update on this? Looking forward to the integration.
Also looking forward to this. Any update here?
@AumeshMisra , @tomdzh , @melon-husk thanks for the interest in this feature! I have code to implement this functionality, but I have no experience with open source or integrating custom features into existing codebases. So right now I just have everything local on my machine. If any of you have experience with open source codebases and can help I would be willing to work together
Feature request
I want to request functionality for decision tree / flow chart like prompt architecture. The idea is that there would be a Prompt Tree that starts on a specific branch then allows the LLM to select new branches as part of its toolkit. Each branch would have its own prompts meaning that the AI does not need to be given all the information up front and instead can break down its commands into bite sized chunks that it sees at each branch in the tree.
Motivation
This would help chatbot workflows by limiting the amount of information the LLM sees at each point in time, it can collect variables through different branches of the tree that it will use later, and it would improve reliability with LLM outputs because it would be easier to implement checks. It also could eliminate the need for a scratchpad, which can become costly if abused by the LLM.
Also, this is a feature that is available in other systems such as LLMFlows and Amazon Lex. And from what I have seen it is frequently on message boards here.
Your contribution
I have made a simple example script to show how this could work in principle. However, I do not have experience contributing to open source projects so I am not sure what formatting mistakes I may be making, nor where exactly in the object heirarchy this should belong (is this a type of Prompt? Or Agent?). I would love to learn about what is needed to incorporate this into the LangChain functionality.
In my example I make a PromptTree class which stores the state and can access the current prompt. Inside the tree are a variety of branches which point to eachother according to a dictionary. Each branch produces a tool which allows the AI to switch branches by updating the prompttree.
While this may not be a perfect way to go about things, it does demonstrate that with a relatively small amount of code we can work with existing LangChain arcitecture to implement a toy model. I think that with a little bit of work this could be made into something very useful.
I would love to learn more about if/how I can help contribute to incorporate this.