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

Add context to BaseSummaryEngine #907

Closed
wants to merge 1 commit into from
Closed

Conversation

vachillo
Copy link
Member

No description provided.

Copy link

codecov bot commented Jun 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@vachillo vachillo requested a review from a team June 27, 2024 17:52
@@ -9,7 +9,7 @@
class TestPromptSummaryEngine:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would be nice if there was at least one test that used the context in the template too (currently added tests seem to just supply the context init param, but never test that it effects the output).

from griptape.artifacts import TextArtifact, ListArtifact
from griptape.rules import Ruleset


@define
class BaseSummaryEngine(ABC):
context: dict[str, Any] = field(factory=dict, kw_only=True)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm wondering if additional template parameters makes sense in the engine or not. Do you have a specific use case that would make it easier to deduce the requirements on possible solutions? Is the use case dependent on adding the template parameters to the engine? For example, do you need to be able to use the engine with the context outside of a task/structure?

If we do indeed want to supply the additional template parameters in the engine, I think it should at least be named something other than context, to make it less confusing with the existing context in BaseTask.context. This existing context gets consumed (though indirectly) by TextSummaryTask (via BaseTask.full_context and BaseTextInputTask.input).

Copy link
Member

Choose a reason for hiding this comment

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

What if we added a context field to the J2 class instead?

Copy link
Member Author

@vachillo vachillo Jun 28, 2024

Choose a reason for hiding this comment

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

it is meant to mimic the init parameter on BaseTask. yes the use case is custom template rendering. right now in the summary engine (or really any class that uses templates), it is really hard to know what parameters are accessible when overriding a template. see #872.

all of the existing uses of full_context are only for input rendering (which this class does not have), not system/user prompt rendering. i can follow the same context init and full_context property pattern if that would be better here? context field on J2 might make sense too, but that would be a much bigger change.

Copy link
Member

Choose a reason for hiding this comment

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

Is this PR intended to solve #872?

context field on J2 might make sense too, but that would be a much bigger change.

Would it be a big change though? The change would be isolated to J2, and it would benefit all uses of J2 rather than just this Engine.

@vachillo
Copy link
Member Author

vachillo commented Jul 2, 2024

closing to reimplement on J2

@vachillo vachillo closed this Jul 2, 2024
@vachillo vachillo deleted the context_prompt_summary branch July 7, 2024 01:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants