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

Core: Added partial functionality to PipelinePromptTemplate #28377

Closed
wants to merge 6 commits into from

Conversation

Aarya2004
Copy link

@Aarya2004 Aarya2004 commented Nov 27, 2024

Description: Added extra logic in the PipelinePromptTemplate to support partial assignments primarily by overriding the partial method from BasePromptTemplate
Issue: Fixes issue #27868
Dependencies: No dependencies required or new dependencies added

Add tests
Added test in test_pipeline_prompt.py to check for this case.

Lint and test: Done

Copy link

vercel bot commented Nov 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Visit Preview Nov 27, 2024 5:33pm

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. Ɑ: core Related to langchain-core labels Nov 27, 2024
@Aarya2004
Copy link
Author

Hello @efriis! Sorry for the ping, but you had reviewed a PR related to Prompt Templates recently (#28011) so I was hoping you would be able to review this too. Let me know if you have any questions, thank you!

@efriis efriis self-assigned this Dec 9, 2024
Copy link
Member

@efriis efriis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is ok. Quickly discussing with team to see what we want to do with PipelinePromptTemplate because it's not that intuitive of an abstraction, and it might make sense to just implement as a RunnableSequence of RunnableAssigns instead...

i.e. I think this does the same thing from my understanding:

keys_and_prompts: list[tuple[str, PromptTemplate]] = ...


chain = RunnablePassthrough()
for key, prompt in keys_and_prompts:
  chain = chain | RunnablePassthrough.assign(key, prompt)

chain = chain | lambda x: x[keys_and_prompts[-1][0]]

@Aarya2004
Copy link
Author

Sounds good, I wasn't sure if this complied with how PipelinePromptTemplate is 'supposed' to be used but I thought it made sense as a functionality given that the PromptTemplate class implements this function (and PipelinePromptTemplate used a list of these PromptTemplates for its functionality) but I do see how it makes sense through your code. Thanks for taking a look at the code, let me know what you and the team decide!

@efriis
Copy link
Member

efriis commented Dec 10, 2024

Are you using it personally? If so could you check if the code snippet solves your use case?

@Aarya2004
Copy link
Author

No I'm not, I'm just trying to fix the issue #27868

@efriis
Copy link
Member

efriis commented Dec 10, 2024

got it. I can respond there, and I'll close this because it introduces a new bug, where partial implements a different interface (stateful mutation instead of stateless wrap)

@efriis efriis closed this Dec 10, 2024
@Aarya2004
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ɑ: core Related to langchain-core size:M This PR changes 30-99 lines, ignoring generated files.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants