-
Notifications
You must be signed in to change notification settings - Fork 175
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
Global Config #1045
Global Config #1045
Conversation
Codecov ReportAttention: Patch coverage is 📢 Thoughts on this report? Let us know! |
e7cf26b
to
4220e0f
Compare
50caaec
to
0f19385
Compare
fc518f7
to
daa1710
Compare
can you write up the motivation for these changes and an example? hard to look at 123 files that seems like mostly small config changes and formatting |
@vachillo updated the PR description with more context |
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.
Couple of comments, but they can be addressed in another PR if at all. No more revisions on this plz
|
||
### Changed | ||
- **BREAKING**: Removed all uses of `EventPublisherMixin` in favor of `event_bus`. | ||
- **BREAKING**: Removed `EventPublisherMixin`. | ||
- **BREAKING**: Removed `Pipeline.prompt_driver` and `Workflow.prompt_driver`. `Agent.prompt_driver` has not been removed. |
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.
What's special about Agent.prompt_driver
?
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.
From the PR description:
Note that Agent.prompt_driver and Agent.stream were kept since the purpose of an Agent is to provide a syntactically concise way to create a Structure with either a PromptTask/ToolkitTask. These fields felt consistent with the other helper field: Agent.tools.
Let me know if this is not a sufficient explanation, happy to go into more detail.
|
||
### Changed | ||
- **BREAKING**: Removed all uses of `EventPublisherMixin` in favor of `event_bus`. | ||
- **BREAKING**: Removed `EventPublisherMixin`. | ||
- **BREAKING**: Removed `Pipeline.prompt_driver` and `Workflow.prompt_driver`. `Agent.prompt_driver` has not been removed. | ||
- **BREAKING**: Removed `Pipeline.stream` and `Workflow.stream`. `Agent.stream` has not been removed. |
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.
What's special about Agent.stream
?
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.
Replied above.
Here is how you can override the Embedding Driver that is used by default in Structures. | ||
Here is how you can override the Embedding Driver that is used by default in Structures. | ||
|
||
```python | ||
--8<-- "docs/griptape-framework/drivers/src/embedding_drivers_10.py" |
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.
Separating the snippets from the docs makes proof reading more difficult
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.
Agreed, but the type checking/linting was essential during development.
config.drivers = OpenAiDriverConfig(prompt=OpenAiChatPromptDriver(model="gpt-4o", stream=True)) | ||
|
||
pipeline = Pipeline() |
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.
It seems weird that we are "setting" the stream flag at this level. (like you don't know where it is going to be used yet and it could be used for streaming or not). Is changing that outside of the scope of this PR? If so, let's create a task to change it
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.
Agreed, I just moved the location to a more natural location.
task = ToolkitTask(self.input, tools=self.tools, max_meta_memory_entries=self.max_meta_memory_entries) | ||
task = ToolkitTask( | ||
self.input, | ||
prompt_driver=self.prompt_driver, |
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.
Why not take this from config too?
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.
It does. self.prompt_driver
defaults to config.drivers.prompt
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 guess I mean, why do we need prompt_driver
on agent at all?
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 technically don't, it's just a convenience field to avoid dealing with the configuration object.
else: | ||
task = PromptTask(self.input, max_meta_memory_entries=self.max_meta_memory_entries) | ||
task = PromptTask( | ||
self.input, prompt_driver=self.prompt_driver, max_meta_memory_entries=self.max_meta_memory_entries |
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.
Same here, why not take prompt driver from config?
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.
Good catch, updated stream
to default to config.drivers.prompt.stream
.
1ff7e88
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.
Looks fine, but I replied to some comments
pipeline.add_tasks( | ||
ToolkitTask( | ||
"Based on https://griptape.ai, tell me what griptape is.", | ||
prompt_driver=OpenAiChatPromptDriver(model="gpt-4o", stream=True), |
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 suppose passing stream
in to the driver works, but I think its a little confusing still. I'd expect either pipeline.run(stream=True)
or maybe Pipeline(stream=True)
...
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.
A Pipeline may not contain any Tasks that use Prompt Drivers therefore streaming would be irrelevant. For Agents, it's always either be a Prompt Task or Toolkit Task (unless a user overrides tasks
).
task = ToolkitTask(self.input, tools=self.tools, max_meta_memory_entries=self.max_meta_memory_entries) | ||
task = ToolkitTask( | ||
self.input, | ||
prompt_driver=self.prompt_driver, |
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 guess I mean, why do we need prompt_driver
on agent at all?
6944ba4
to
d179821
Compare
Describe your changes
This change completely refactors how configuration is handled in the framework. Since the beginning we have relied on
Structure
to serve as the source of truth for configuration values. However, as the framework grew in complexity, it became increasingly difficult (and sometimes wrong) to propagate aStructure
reference around in order to access these configuration values.This PR introduces a global singleton,
griptape.config.config
, that stores these configuration values. Today, it stores configuration for drivers (previously calledStructureConfig
), andlogging
. The framework has been updated to pull from this object for default values.Since this configuration now lives in the
config
object, I have removed these configuration values fromStructure
. Note thatAgent.prompt_driver
andAgent.stream
were kept since the purpose of an Agent is to provide a syntactically concise way to create a Structure with either aPromptTask
/ToolkitTask
. These fields felt consistent with the other helper field:Agent.tools
.Overall I really like this change, but you might notice that not all drivers are included in
DriversConfig
. Does it makes sense to provide a default value for something like aWebScraperDriver
? Or should this be left to the specific areas of the framework that require it? We could just provide aNone
default, but this may mask the fact that something like theWebSearch
Tool does actually require one.Changelog
Added:
griptape.config.config
, for setting global configuration defaults.Changed:
Pipeline.prompt_driver
andWorkflow.prompt_driver
.Agent.prompt_driver
has not been removed.Pipeline.stream
andWorkflow.stream
.Agent.stream
has not been removed.Structure.embedding_driver
, set this viagriptape.config.config.drivers.embedding
instead.Structure.custom_logger
andStructure.logger_level
, set these viagriptape.config.config.logger
instead.griptape.config.config.drivers
by default.BaseStructureConfig.merge_config
.StructureConfig
toDriverConfig
, and renamed fields accordingly.Issue ticket number and link
Closes #826 (
merge_config
is removed).📚 Documentation preview 📚: https://griptape--1045.org.readthedocs.build//1045/