-
Couldn't load subscription status.
- Fork 2.1k
Visual and customization improvements #2858
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
base: main
Are you sure you want to change the base?
Changes from all commits
76f1712
8475748
081e15a
64ff784
304b2f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -232,8 +232,14 @@ def tear_down_observer(observer: Observer, _: AdkWebServer): | |
| ) | ||
|
|
||
| if web: | ||
| BASE_DIR = Path(__file__).parent.resolve() | ||
| ANGULAR_DIST_PATH = BASE_DIR / "browser" | ||
| # Default to the pre-packaged UI, but allow overriding for local development. | ||
| if adk_web_dir_override := os.environ.get("ADK_WEB_DIR"): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd like to stick to the command-line flag. When the CLI flag is not set adk web should use current folder. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A CLI flag is interesting but couldn't find one that's used to specify the web directory, can you tell me which one? the ADK_WEB_DIR env var is another option to support where developers want to build a customized version of the adk-web UI and need to serve it with the adk-web command for testing and demos. |
||
| ANGULAR_DIST_PATH = Path(adk_web_dir_override) | ||
| logger.info("Serving ADK web UI from: %s", ANGULAR_DIST_PATH) | ||
| else: | ||
| BASE_DIR = Path(__file__).parent.resolve() | ||
| ANGULAR_DIST_PATH = BASE_DIR / "browser" | ||
| logger.info("Serving pre-packaged ADK web UI.") | ||
| extra_fast_api_args.update( | ||
| web_assets_dir=ANGULAR_DIST_PATH, | ||
| ) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,37 +40,56 @@ class FunctionTool(BaseTool): | |
| """ | ||
|
|
||
| def __init__( | ||
| self, func: Callable[..., Any], *, require_confirmation: bool = False | ||
| self, | ||
| func: Callable[..., Any], | ||
| *, | ||
| name: Optional[str] = None, | ||
| description: Optional[str] = None, | ||
| displayName: Optional[str] = None, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't want to change the core interface just for display purposes. We want the adk web to show the exact name so it's easier for developers to map what they see in the UI with the code. |
||
| require_confirmation: bool = False, | ||
| ): | ||
| """Initializes the FunctionTool. Extracts metadata from a callable object. | ||
| """Initializes the FunctionTool. | ||
|
|
||
| Args: | ||
| func: The function to wrap. | ||
| require_confirmation: Whether the tool call requires user confirmation. | ||
| func: The callable to be wrapped as a tool. | ||
| name: Optional. The internal name of the tool. If None, it's inferred | ||
| from the function. | ||
| description: Optional. A description of what the tool does. If None, | ||
| it's inferred from the function's docstring. | ||
| displayName: Optional. A user-friendly name for display purposes. If | ||
| None, the internal name might be used as a fallback by consumers. | ||
| require_confirmation: If true, the tool requires user's confirmation before | ||
| execution. | ||
| """ | ||
| name = '' | ||
| doc = '' | ||
| inferred_name = '' | ||
| inferred_description = '' | ||
| # Handle different types of callables | ||
| if hasattr(func, '__name__'): | ||
| # Regular functions, unbound methods, etc. | ||
| name = func.__name__ | ||
| inferred_name = func.__name__ | ||
| elif hasattr(func, '__class__'): | ||
| # Callable objects, bound methods, etc. | ||
| name = func.__class__.__name__ | ||
| inferred_name = func.__class__.__name__ | ||
|
|
||
| # Get documentation (prioritize direct __doc__ if available) | ||
| if hasattr(func, '__doc__') and func.__doc__: | ||
| doc = inspect.cleandoc(func.__doc__) | ||
| inferred_description = inspect.cleandoc(func.__doc__) | ||
| elif ( | ||
| hasattr(func, '__call__') | ||
| and hasattr(func.__call__, '__doc__') | ||
| and func.__call__.__doc__ | ||
| ): | ||
| # For callable objects, try to get docstring from __call__ method | ||
| doc = inspect.cleandoc(func.__call__.__doc__) | ||
| inferred_description = inspect.cleandoc(func.__call__.__doc__) | ||
|
|
||
| tool_name = name if name is not None else inferred_name | ||
| tool_description = ( | ||
| description if description is not None else inferred_description | ||
| ) | ||
|
|
||
| super().__init__(name=name, description=doc) | ||
| super().__init__(name=tool_name, description=tool_description) | ||
| self.func = func | ||
| self.displayName = displayName | ||
| self._ignore_params = ['tool_context', 'input_stream'] | ||
| self._require_confirmation = require_confirmation | ||
|
|
||
|
|
||
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.
Could you attach a screenshot?
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.
attaching before and after