-
Notifications
You must be signed in to change notification settings - Fork 51
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
refactor: clear separation of public and internal packages #39
refactor: clear separation of public and internal packages #39
Conversation
RESUME_MESSAGE = "I see we were interrupted. How can I help you?" | ||
|
||
|
||
def load_provider() -> str: |
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.
deleted this this function as it is not used
return read_config()[name] | ||
|
||
|
||
class SessionNotifier(Notifier): |
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.
moved this class in a separate file
return "openai" | ||
|
||
|
||
def load_profile(name: Optional[str]) -> Profile: |
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.
moved this function in the _internal.profile package
@@ -0,0 +1,18 @@ | |||
from .developer.developer import Developer # noqa: F401 |
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.
use relative imports to shorten the import statement
Hey @lifeizhou-ap! Absolutely agree with your categorization of the three things this package is providing, and we should clarify those throughout the code. However I do consider the majority of the functionality to be "public", and so would avoid the refactor of pushing so much of the content into an Some examples of why I think these are more public than they might seem:
So i'd suggest we revisit this to highlight some of the private methods, especially any place you're running into circular imports! |
Glossary
goose-ai
).Current State
goose-ai
serves as:Plugins depend on
goose-ai
during compile time to extend base classes such asToolkit
. However, at runtime,goose-ai
dynamically loads the plugin’s functions or classes, creating an implicit dependency on the plugin.Problem
Currently,
goose-ai
does not clearly distinguish between publicly accessible classes/functions and those intended for internal use. This lack of separation can lead to unintended use by plugin developers, potentially causing circular dependency issues.Example:
goose-ai
has two functions:load_plugin
andgoose_ai_util
.render_toolkit
, which referencesgoose_ai_util
.When
load_plugin
in Module A callsrender_toolkit
to load an additional toolkit,render_toolkit
in turn callsgoose_ai_util
in Module A. This can trigger a circular dependency problem.Solution
To resolve this issue, restructure the
goose-ai
codebase to clearly delineate:goose-ai
as a command-line application and plugin host.Benefits
Maintainability
Encapsulating internal packages and implementation details makes it easier to refactor or modify
goose-ai
without affecting the users of the library. This ensures backward compatibility and reduces the risk of breaking changes.Clear Interface to Prevent Misuse
Plugins will have a well-defined interface for accessing
goose-ai
functions and classes. This reduces the likelihood of plugin developers inadvertently using internal functions or classes, helping to prevent circular dependency problems.How
In the
src/goose
directory, create three distinct packages:_internal
:pluginbase
: (open to a better name)config
:_internal
can reference thepluginbase
andconfig
. Butpluginbase
andconfig
cannot reference_internal
, we may set some check to prevent this.By organizing the codebase in this manner,
goose-ai
can offer a clear and stable API to its users while safeguarding against issues arising from the unintentional misuse of internal components.Folder structures