-
Notifications
You must be signed in to change notification settings - Fork 15
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
Kotlin prompt chain #173
Kotlin prompt chain #173
Conversation
val playScore = Play("The power of Zuluastral", "Modern Era") | ||
.chain<Play, Synopsis>(this) { play -> synopsisTemplate(play) } | ||
.chain<Synopsis, Review>(this) { synopsis -> reviewTemplate(synopsis) } | ||
.chain<Review, Score>(this) { review -> scoreTemplate(review) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not entirely sure I understand the benefit over 🤔
val play = Play("The power of Zuluastral", "Modern Era")
val synopsis: Synopsis = prompt(synopsisTemplate(play))
val review: Review = prompt(reviewTemplate(synopsis))
val score: Score = prompt(scoreTemplate(review))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand your point and it has been an ongoing discussion on how much prompt "templating/chaining" adds to the basic functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion we should keep it as it enhances the API for chaining prompts. (but of course we can chain prompts without this new functionality)
Lets try to get more opinions, I'm ok to remove it if we go in the direction of minimum API extensions possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are several issue to consider here from an OSS / Library maintenance point of view.
- Duplicated APIs, cause confusion for users to use 1 way over the other.
- More code results in higher maintenance
- With the current work we're doing in core this brings the question on how we can make this Java friendly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We took a similar decision some time ago, removing chains in favor of being more explicit (or just use function composition!)
Chaining makes more sense in a LangChain-style API, in which you put the results of AI calls under keys in the context. Since all elements of the chain share the context, this is the main way to share data between agents. However, we want a more explicit style, hence the much less powerful design of contexts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the solution discussed in this thread. Although the chain approach had also influenced me, I comprehend and acknowledge the perspectives shared by Alex and Simon. My apologies, @necosta, for the additional effort needed in this matter. 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem. I also understand this goes in a direction that we may not want to take just yet.
I'll close this PR and create a new one removing the Scala logic in this area.
thanks all for your comments.
I need some input on this one, can't find an elegant solution for prompt templating in Kotlin and Scala.See #157 (comment) , initially prompt "chaining" was implemented in Scala, should be both in Scala and Kotlin which is now done in this PR.
I'm unsure how to call the Kotlinchain
method from Scala, there seems to be some limitations on Kotlin, trying to get to the bottom of it.Using loom to call chain method from Kotlin in Scala, removed
PromptTemplate
logic.Ready for review.