Conversation
… a single dappier package
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughThis pull request adds a new Dappier tools module with two tool specifications— Changes
Sequence Diagram(s)Dappier AI Recommendations WorkflowsequenceDiagram
participant User
participant Agent
participant DappierClient
participant DappierAPI
User->>Agent: Request AI recommendations (e.g., sports news)
Agent->>DappierClient: get_sports_news_recommendations(query)
DappierClient->>DappierAPI: Send API request with parameters
DappierAPI-->>DappierClient: Return recommendation data
DappierClient-->>Agent: Return formatted recommendations
Agent-->>User: Deliver recommendations response
Dappier Real-Time Search WorkflowsequenceDiagram
participant User
participant Agent
participant DappierClient
participant DappierAPI
User->>Agent: Request real-time search (e.g., weather update)
Agent->>DappierClient: search_real_time_data(query)
DappierClient->>DappierAPI: Send API request with query
DappierAPI-->>DappierClient: Return search results
DappierClient-->>Agent: Return formatted search result
Agent-->>User: Deliver search response
Possibly related PRs
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 17
🔭 Outside diff range comments (2)
llama-index-integrations/tools/llama-index-tools-dappier/llama_index/tools/dappier/__init__.py (1)
1-12: 🧹 Nitpick (assertive)Module Initialization and Explicit Exports are Correct
The file correctly imports and re-exports the two Dappier tool specification classes. As this is a new integration module, consider adding a module-level docstring to explain the purpose of the module and its contents, which would aid future maintainability and onboarding.docs/docs/api_reference/tools/dappier.md (1)
1-6: 🧹 Nitpick (assertive)Documentation Format Improvement: Add a Top-Level Heading
While the content correctly documents the available members in thellama_index.tools.dappiermodule, it is recommended to include a top-level heading (for example,# Dappier Tools Module) at the start of the file. This change will improve readability and ensure compliance with markdownlint MD041.🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
1-1: First line in a file should be a top-level heading
null(MD041, first-line-heading, first-line-h1)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (21)
docs/docs/api_reference/tools/dappier.md(1 hunks)docs/mkdocs.yml(2 hunks)llama-index-cli/llama_index/cli/upgrade/mappings.json(1 hunks)llama-index-core/llama_index/core/command_line/mappings.json(1 hunks)llama-index-integrations/tools/llama-index-tools-dappier/.gitignore(1 hunks)llama-index-integrations/tools/llama-index-tools-dappier/BUILD(1 hunks)llama-index-integrations/tools/llama-index-tools-dappier/LICENSE(1 hunks)llama-index-integrations/tools/llama-index-tools-dappier/Makefile(1 hunks)llama-index-integrations/tools/llama-index-tools-dappier/README.md(1 hunks)llama-index-integrations/tools/llama-index-tools-dappier/examples/dappier_ai_recommendations.ipynb(1 hunks)llama-index-integrations/tools/llama-index-tools-dappier/examples/dappier_real_time_search.ipynb(1 hunks)llama-index-integrations/tools/llama-index-tools-dappier/llama_index/tools/dappier/BUILD(1 hunks)llama-index-integrations/tools/llama-index-tools-dappier/llama_index/tools/dappier/__init__.py(1 hunks)llama-index-integrations/tools/llama-index-tools-dappier/llama_index/tools/dappier/ai_recommendations/BUILD(1 hunks)llama-index-integrations/tools/llama-index-tools-dappier/llama_index/tools/dappier/ai_recommendations/base.py(1 hunks)llama-index-integrations/tools/llama-index-tools-dappier/llama_index/tools/dappier/real_time_search/BUILD(1 hunks)llama-index-integrations/tools/llama-index-tools-dappier/llama_index/tools/dappier/real_time_search/base.py(1 hunks)llama-index-integrations/tools/llama-index-tools-dappier/pyproject.toml(1 hunks)llama-index-integrations/tools/llama-index-tools-dappier/tests/BUILD(1 hunks)llama-index-integrations/tools/llama-index-tools-dappier/tests/test_tools_dappier_ai_recommendations.py(1 hunks)llama-index-integrations/tools/llama-index-tools-dappier/tests/test_tools_dappier_real_time_search.py(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.py`: Be sure that the code is optimized to enable concurrency, efficient use of threading and follows the standard Python guide, always point out all possible unhandled error...
**/*.py: Be sure that the code is optimized to enable concurrency, efficient use of threading and follows the standard Python guide, always point out all possible unhandled error case and suggest code snippets to improve key areas such as:
- Logic
- Security
- Performance
- Data races
- Consistency
- Error handling
- Maintainability
- Modularity
- Complexity
- Optimization
- Best practices: DRY, SOLID, KISS
llama-index-integrations/tools/llama-index-tools-dappier/tests/test_tools_dappier_ai_recommendations.pyllama-index-integrations/tools/llama-index-tools-dappier/llama_index/tools/dappier/__init__.pyllama-index-integrations/tools/llama-index-tools-dappier/tests/test_tools_dappier_real_time_search.pyllama-index-integrations/tools/llama-index-tools-dappier/llama_index/tools/dappier/real_time_search/base.pyllama-index-integrations/tools/llama-index-tools-dappier/llama_index/tools/dappier/ai_recommendations/base.py
🧬 Code Definitions (3)
llama-index-integrations/tools/llama-index-tools-dappier/tests/test_tools_dappier_ai_recommendations.py (1)
llama-index-integrations/tools/llama-index-tools-dappier/tests/test_tools_dappier_real_time_search.py (1)
test_class(8-10)
llama-index-integrations/tools/llama-index-tools-dappier/llama_index/tools/dappier/__init__.py (2)
llama-index-integrations/tools/llama-index-tools-dappier/llama_index/tools/dappier/ai_recommendations/base.py (1)
DappierAIRecommendationsToolSpec(9-281)llama-index-integrations/tools/llama-index-tools-dappier/llama_index/tools/dappier/real_time_search/base.py (1)
DappierRealTimeSearchToolSpec(9-65)
llama-index-integrations/tools/llama-index-tools-dappier/tests/test_tools_dappier_real_time_search.py (1)
llama-index-integrations/tools/llama-index-tools-dappier/tests/test_tools_dappier_ai_recommendations.py (1)
test_class(5-9)
🪛 markdownlint-cli2 (0.17.2)
docs/docs/api_reference/tools/dappier.md
1-1: First line in a file should be a top-level heading
null
(MD041, first-line-heading, first-line-h1)
🪛 LanguageTool
llama-index-integrations/tools/llama-index-tools-dappier/README.md
[uncategorized] ~15-~15: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ...TV and 9&10 News. ## Key Features ### Real Time Search Tool - Real-Time Web Search...
(EN_COMPOUND_ADJECTIVE_INTERNAL)
[uncategorized] ~44-~44: “Your” (belonging to you) seems less likely than “you”.
Context: ... your API keys for OpenAI and Dappier. Your can go to [here](https://platform.opena...
(AI_HYDRA_LEO_CP_YOUR_YOU)
[uncategorized] ~59-~59: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ... = "dappier_api_key" ``` ## Usage ### Real Time Search Tool This tool has a more exten...
(EN_COMPOUND_ADJECTIVE_INTERNAL)
[uncategorized] ~85-~85: Loose punctuation mark.
Context: ...lable in are: - search_real_time_data: A tool that performs a real-time web se...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~86-~86: Loose punctuation mark.
Context: ..., and more. - search_stock_market_data: A tool that fetches real-time stock mar...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~114-~114: Loose punctuation mark.
Context: ...re: - get_sports_news_recommendations: A tool that fetches real-time news, upd...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~116-~116: Loose punctuation mark.
Context: ... - get_lifestyle_news_recommendations: A tool that fetches Real-time updates, ...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~118-~118: Loose punctuation mark.
Context: ...oof. - get_iheartdogs_recommendations: A tool that fetches articles on health,...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~120-~120: Loose punctuation mark.
Context: ....com - get_iheartcats_recommendations: A tool that fetches articles on health,...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~122-~122: Loose punctuation mark.
Context: ...om - get_greenmonster_recommendations: A tool that fetches guides to making co...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~124-~124: Loose punctuation mark.
Context: ... planet. - get_wishtv_recommendations: A tool that fetches politics, breaking ...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~126-~126: Loose punctuation mark.
Context: ... get_nine_and_ten_news_recommendations: A tool that fetches up-to-date local ne...
(UNLIKELY_OPENING_PUNCTUATION)
🪛 Ruff (0.8.2)
llama-index-integrations/tools/llama-index-tools-dappier/tests/test_tools_dappier_real_time_search.py
13-13: Use @pytest.fixture over @pytest.fixture()
Remove parentheses
(PT001)
18-18: Use @pytest.fixture over @pytest.fixture()
Remove parentheses
(PT001)
llama-index-integrations/tools/llama-index-tools-dappier/llama_index/tools/dappier/real_time_search/base.py
15-18: Multi-line docstring summary should start at the second line
Insert line break and indentation after opening quotes
(D213)
🔇 Additional comments (23)
llama-index-integrations/tools/llama-index-tools-dappier/LICENSE (1)
1-22: MIT License File Looks SolidThe LICENSE file correctly includes the full MIT License text. It adheres to standard formatting and clearly lays out the permissions, restrictions, and disclaimers. There's no issue with the content, and it sets a proper legal foundation for the new Dappier tools package.
llama-index-integrations/tools/llama-index-tools-dappier/.gitignore (1)
1-154: Comprehensive .gitignore ImplementationThis .gitignore file is very thorough—it covers Python bytecode, build artifacts, environment directories, IDE-specific settings, and several framework-specific files. It ensures that unnecessary files won’t pollute the repository. The organization into sections improves readability and maintainability.
llama-index-integrations/tools/llama-index-tools-dappier/Makefile (1)
1-18: Well-Structured Makefile for Dappier ToolsThe Makefile defines useful targets including help, format, lint, test, and watch-docs. The use of pre-commit hooks for formatting and linting, as well as integrating pytest for testing and sphinx-autobuild for documentation, reflects a robust and developer-friendly workflow. Verify that the paths (e.g.,
docs/,tests/, and$(GIT_ROOT)/llama_index/) are correct within your repository structure, though they look appropriate given the context.llama-index-integrations/tools/llama-index-tools-dappier/BUILD (1)
1-3: Simple and Correct BUILD File DeclarationThis BUILD file adds a minimal
poetry_requirementstarget with the name "poetry". The syntax is correct, and it cleanly introduces the dependency management required for the tool. If a version pin or further configuration is needed later, that can be added as a subsequent improvement.llama-index-integrations/tools/llama-index-tools-dappier/tests/BUILD (1)
1-2: Clean Test BUILD TargetThe new target
python_tests()is a concise way to define test execution within the build system for the new Dappier tool functionalities. It’s key to confirm that all relevant new test files (e.g., those coveringDappierAIRecommendationsToolSpecandDappierRealTimeSearchToolSpec) reside under the tests directory so they get picked up correctly when this target is invoked.llama-index-integrations/tools/llama-index-tools-dappier/llama_index/tools/dappier/BUILD (1)
1-1: Looks good!The
python_sources()function is correctly used to identify Python source files in this directory for the build system. This is a standard pattern in Pants/Bazel build systems.llama-index-integrations/tools/llama-index-tools-dappier/llama_index/tools/dappier/ai_recommendations/BUILD (1)
1-1: Looks good!The
python_sources()function is correctly used to identify Python source files in the AI recommendations subdirectory for the build system. This maintains consistency with the parent directory's BUILD file.llama-index-integrations/tools/llama-index-tools-dappier/llama_index/tools/dappier/real_time_search/BUILD (1)
1-1: Looks good!The
python_sources()function is correctly used to identify Python source files in the real-time search subdirectory for the build system. This maintains consistency with the other Dappier tool subdirectories.llama-index-cli/llama_index/cli/upgrade/mappings.json (1)
551-552: New Mapping Entries for Dappier Tools Added
The new entries
"DappierAIRecommendationsToolSpec": "llama_index.tools.dappier"
"DappierRealTimeSearchToolSpec": "llama_index.tools.dappier"
are correctly added. This update enables the CLI upgrade tool to recognize and correctly map the new Dappier specifications.llama-index-core/llama_index/core/command_line/mappings.json (1)
551-553: New Dappier Tool Entries Integrated
The new mapping entries for"DappierAIRecommendationsToolSpec"and"DappierRealTimeSearchToolSpec"under the key"llama_index.tools.dappier"have been properly integrated into the command-line mappings. This inclusion ensures consistency across the project components and facilitates the recognition of the new tools.docs/mkdocs.yml (2)
1679-1680: New Dappier Tool Documentation Entry Added
A new documentation entry for the Dappier tool has been added here via the reference to./api_reference/tools/dappier.md. Please verify that the corresponding markdown file exists and that its contents appropriately document the new Dappier functionality.
1912-1913: New Integration Paths for Dappier Tools Introduced
Two new paths have been added:
../llama-index-integrations/tools/llama-index-tools-dappier-ai-recommendations../llama-index-integrations/tools/llama-index-tools-dappier-real-time-searchThese entries will incorporate the Dappier Recommendations and Real-Time Search tool specifications into the documentation site. Please double-check that these directories and their documentation files exist and reflect the intended content.
llama-index-integrations/tools/llama-index-tools-dappier/tests/test_tools_dappier_real_time_search.py (3)
34-44: Test looks goodThe test properly verifies that the
search_real_time_datamethod returns the expected response and calls the client with the correct parameters.
45-57: Test looks goodThe test properly verifies that the
search_stock_market_datamethod returns the expected response and calls the client with the correct parameters.
58-63: Tests for error handling look goodThese tests properly verify the behavior when the client returns None, ensuring that appropriate default messages are returned.
Also applies to: 64-69
llama-index-integrations/tools/llama-index-tools-dappier/pyproject.toml (2)
22-22: Python version inconsistencyThere's an inconsistency between the mypy Python version (3.8) and the required Python version (>=3.9). Consider aligning these to ensure type checking matches the targeted Python version.
-python_version = "3.8" +python_version = "3.9"Also applies to: 34-34
5-8: Configuration structure looks goodThe project configuration is well-structured with appropriate sections for build settings, dependencies, development tools, and package metadata. The dependencies are specified with compatible version constraints which is good practice.
Also applies to: 10-16, 18-22, 24-31, 33-36, 38-54, 55-62, 63-65
llama-index-integrations/tools/llama-index-tools-dappier/examples/dappier_ai_recommendations.ipynb (4)
152-157: Secure API key handling looks goodUsing
getpassto securely prompt for API keys is a good security practice.
175-178: Secure API key handling looks goodUsing
getpassfor the Dappier API key is a good security practice.
211-220: Tool initialization and exploration looks goodThe code properly initializes the Dappier tool and explores available methods.
840-858: Notebook metadata looks goodThe notebook metadata is properly structured with appropriate kernelspec and language information.
llama-index-integrations/tools/llama-index-tools-dappier/examples/dappier_real_time_search.ipynb (1)
1-19: Notebook metadata looks good.
This is standard Jupyter notebook metadata with no notable issues.llama-index-integrations/tools/llama-index-tools-dappier/llama_index/tools/dappier/ai_recommendations/base.py (1)
283-314: Good error-checking approach.
The function checksresponse.statusand gracefully returns a user-friendly message when unsuccessful. This straightforward error handling is a solid start.
...-integrations/tools/llama-index-tools-dappier/tests/test_tools_dappier_ai_recommendations.py
Show resolved
Hide resolved
...-integrations/tools/llama-index-tools-dappier/tests/test_tools_dappier_ai_recommendations.py
Show resolved
Hide resolved
| @pytest.fixture() | ||
| def dappier_client(): |
There was a problem hiding this comment.
🧹 Nitpick (assertive)
Consider removing parentheses from pytest fixture decorator
The pytest fixture decorator should be used without parentheses when no arguments are needed.
-@pytest.fixture()
+@pytest.fixture
def dappier_client():📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| @pytest.fixture() | |
| def dappier_client(): | |
| @pytest.fixture | |
| def dappier_client(): |
🧰 Tools
🪛 Ruff (0.8.2)
13-13: Use @pytest.fixture over @pytest.fixture()
Remove parentheses
(PT001)
| @pytest.fixture() | ||
| def tool(dappier_client): |
There was a problem hiding this comment.
🧹 Nitpick (assertive)
Consider removing parentheses from pytest fixture decorator
The pytest fixture decorator should be used without parentheses when no arguments are needed.
-@pytest.fixture()
+@pytest.fixture
def tool(dappier_client):📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| @pytest.fixture() | |
| def tool(dappier_client): | |
| @pytest.fixture | |
| def tool(dappier_client): |
🧰 Tools
🪛 Ruff (0.8.2)
18-18: Use @pytest.fixture over @pytest.fixture()
Remove parentheses
(PT001)
| class TestDappierRealTimeSearchTool: | ||
| def test_init_without_api_key_raises_value_error(self, monkeypatch): | ||
| monkeypatch.delenv("DAPPIER_API_KEY", raising=False) | ||
| dappier_client = MagicMock() | ||
| with patch("dappier.Dappier", return_value=dappier_client): | ||
| with pytest.raises(ValueError) as excinfo: | ||
| DappierRealTimeSearchToolSpec() | ||
| assert "API key is required" in str(excinfo.value) | ||
|
|
There was a problem hiding this comment.
🧹 Nitpick (assertive)
Make API key test more resilient
The test for initialization without an API key relies on the environment state. Consider using a more deterministic approach by mocking the os.environ object directly.
def test_init_without_api_key_raises_value_error(self, monkeypatch):
- monkeypatch.delenv("DAPPIER_API_KEY", raising=False)
+ # Mock os.environ to ensure deterministic behavior
+ monkeypatch.setattr("os.environ.get", lambda key, default=None: None if key == "DAPPIER_API_KEY" else default)
dappier_client = MagicMock()
with patch("dappier.Dappier", return_value=dappier_client):
with pytest.raises(ValueError) as excinfo:
DappierRealTimeSearchToolSpec()
assert "API key is required" in str(excinfo.value)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| class TestDappierRealTimeSearchTool: | |
| def test_init_without_api_key_raises_value_error(self, monkeypatch): | |
| monkeypatch.delenv("DAPPIER_API_KEY", raising=False) | |
| dappier_client = MagicMock() | |
| with patch("dappier.Dappier", return_value=dappier_client): | |
| with pytest.raises(ValueError) as excinfo: | |
| DappierRealTimeSearchToolSpec() | |
| assert "API key is required" in str(excinfo.value) | |
| class TestDappierRealTimeSearchTool: | |
| def test_init_without_api_key_raises_value_error(self, monkeypatch): | |
| - monkeypatch.delenv("DAPPIER_API_KEY", raising=False) | |
| + # Mock os.environ to ensure deterministic behavior | |
| + monkeypatch.setattr("os.environ.get", lambda key, default=None: None if key == "DAPPIER_API_KEY" else default) | |
| dappier_client = MagicMock() | |
| with patch("dappier.Dappier", return_value=dappier_client): | |
| with pytest.raises(ValueError) as excinfo: | |
| DappierRealTimeSearchToolSpec() | |
| assert "API key is required" in str(excinfo.value) |
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "a33051ce", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "from llama_index.core.agent import FunctionCallingAgent\n", | ||
| "from llama_index.llms.openai import OpenAI\n", | ||
| "\n", | ||
| "agent = FunctionCallingAgent.from_tools(\n", | ||
| " dappier_tool_list,\n", | ||
| " llm=OpenAI(model=\"gpt-4o\"),\n", | ||
| ")" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "5bcaa33f006b4fb9", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "from llama_index.core.agent import FunctionCallingAgent\n", | ||
| "from llama_index.llms.openai import OpenAI\n", | ||
| "\n", | ||
| "agent = FunctionCallingAgent.from_tools(\n", | ||
| " dappier_tool_list,\n", | ||
| " llm=OpenAI(model=\"gpt-4o\"),\n", | ||
| ")" | ||
| ] |
There was a problem hiding this comment.
🧹 Nitpick (assertive)
Avoid code duplication for agent initialization.
The agent initialization is repeated. Consolidate creation in one place to reduce repetition and simplify updates.
- agent = FunctionCallingAgent.from_tools(
- dappier_tool_list,
- llm=OpenAI(model="gpt-4o"),
- )
...
- agent = FunctionCallingAgent.from_tools(
- dappier_tool_list,
- llm=OpenAI(model="gpt-4o"),
- )
+ def create_dappier_agent(tools, model="gpt-4o"):
+ return FunctionCallingAgent.from_tools(tools, llm=OpenAI(model=model))
# Then call:
+ agent = create_dappier_agent(dappier_tool_list)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "id": "a33051ce", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "from llama_index.core.agent import FunctionCallingAgent\n", | |
| "from llama_index.llms.openai import OpenAI\n", | |
| "\n", | |
| "agent = FunctionCallingAgent.from_tools(\n", | |
| " dappier_tool_list,\n", | |
| " llm=OpenAI(model=\"gpt-4o\"),\n", | |
| ")" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "id": "5bcaa33f006b4fb9", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "from llama_index.core.agent import FunctionCallingAgent\n", | |
| "from llama_index.llms.openai import OpenAI\n", | |
| "\n", | |
| "agent = FunctionCallingAgent.from_tools(\n", | |
| " dappier_tool_list,\n", | |
| " llm=OpenAI(model=\"gpt-4o\"),\n", | |
| ")" | |
| ] | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "id": "a33051ce", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "from llama_index.core.agent import FunctionCallingAgent\n", | |
| "from llama_index.llms.openai import OpenAI\n", | |
| "\n", | |
| "def create_dappier_agent(tools, model=\"gpt-4o\"):\n", | |
| " return FunctionCallingAgent.from_tools(tools, llm=OpenAI(model=model))\n", | |
| "\n", | |
| "agent = create_dappier_agent(dappier_tool_list)\n" | |
| ] | |
| } |
|
|
||
| ## Usage | ||
|
|
||
| ### Real Time Search Tool |
There was a problem hiding this comment.
🧹 Nitpick (assertive)
Consistently use hyphenated form “Real-Time.”
For consistency, use “Real-Time Search Tool” if it’s functioning as a compound adjective.
-### Real Time Search Tool
+### Real-Time Search Tool📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ### Real Time Search Tool | |
| ### Real-Time Search Tool |
🧰 Tools
🪛 LanguageTool
[uncategorized] ~59-~59: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ... = "dappier_api_key" ``` ## Usage ### Real Time Search Tool This tool has a more exten...
(EN_COMPOUND_ADJECTIVE_INTERNAL)
|
|
||
| ## Key Features | ||
|
|
||
| ### Real Time Search Tool |
There was a problem hiding this comment.
🧹 Nitpick (assertive)
Use a hyphen for compound adjective.
“Real-Time” (with a hyphen) is the conventional form when used as an adjective before the noun “Search Tool.”
-### Real Time Search Tool
+### Real-Time Search Tool📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ### Real Time Search Tool | |
| ### Real-Time Search Tool |
🧰 Tools
🪛 LanguageTool
[uncategorized] ~15-~15: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ...TV and 9&10 News. ## Key Features ### Real Time Search Tool - Real-Time Web Search...
(EN_COMPOUND_ADJECTIVE_INTERNAL)
| ## Setup | ||
|
|
||
| You'll need to set up your API keys for OpenAI and Dappier. | ||
|
|
There was a problem hiding this comment.
🧹 Nitpick (assertive)
Fix grammatical error.
Replace “Your” with “You.”
-Your can go to [here](https://platform.openai.com/settings/organization/api-keys) to get API Key
+You can go to [here](https://platform.openai.com/settings/organization/api-keys) to get API Key📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| You can go to [here](https://platform.openai.com/settings/organization/api-keys) to get API Key |
🧰 Tools
🪛 LanguageTool
[uncategorized] ~44-~44: “Your” (belonging to you) seems less likely than “you”.
Context: ... your API keys for OpenAI and Dappier. Your can go to [here](https://platform.opena...
(AI_HYDRA_LEO_CP_YOUR_YOU)
| class DappierAIRecommendationsToolSpec(BaseToolSpec): | ||
| """ | ||
| Dappier AI Recommendations tool spec. | ||
|
|
||
| Provides AI-powered recommendations across various domains such as Sports News, | ||
| Lifestyle News, iHeartDogs, iHeartCats, GreenMonster, WISH-TV and 9 and 10 News. | ||
| """ | ||
|
|
||
| spec_functions = [ | ||
| "get_sports_news_recommendations", | ||
| "get_lifestyle_news_recommendations", | ||
| "get_iheartdogs_recommendations", | ||
| "get_iheartcats_recommendations", | ||
| "get_greenmonster_recommendations", | ||
| "get_wishtv_recommendations", | ||
| "get_nine_and_ten_news_recommendations", | ||
| ] |
There was a problem hiding this comment.
🧹 Nitpick (assertive)
Consider consolidating similar methods.
All methods differ primarily by their data_model_id, which can be defined in a single shared method or dictionary to reduce duplication.
def get_recommendations(
self,
domain_key: str,
query: str,
similarity_top_k: int = 10,
ref: Optional[str] = None,
num_articles_ref: int = 0,
search_algorithm: Literal["most_recent", "semantic", "most_recent_semantic", "trending"] = "most_recent"
):
- data_model_id = <some ID>
+ domain_map = {
+ "sports": "dm_01j0pb465keqmatq9k83dthx34",
+ "lifestyle": "dm_01j0q82s4bfjmsqkhs3ywm3x6y",
+ ...
+ }
+ data_model_id = domain_map[domain_key]
response = self.client.get_ai_recommendations(
query=query,
data_model_id=data_model_id,
similarity_top_k=similarity_top_k,
ref=ref,
num_articles_ref=num_articles_ref,
search_algorithm=search_algorithm,
)
return format_results(response)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| class DappierAIRecommendationsToolSpec(BaseToolSpec): | |
| """ | |
| Dappier AI Recommendations tool spec. | |
| Provides AI-powered recommendations across various domains such as Sports News, | |
| Lifestyle News, iHeartDogs, iHeartCats, GreenMonster, WISH-TV and 9 and 10 News. | |
| """ | |
| spec_functions = [ | |
| "get_sports_news_recommendations", | |
| "get_lifestyle_news_recommendations", | |
| "get_iheartdogs_recommendations", | |
| "get_iheartcats_recommendations", | |
| "get_greenmonster_recommendations", | |
| "get_wishtv_recommendations", | |
| "get_nine_and_ten_news_recommendations", | |
| ] | |
| def get_recommendations( | |
| self, | |
| domain_key: str, | |
| query: str, | |
| similarity_top_k: int = 10, | |
| ref: Optional[str] = None, | |
| num_articles_ref: int = 0, | |
| search_algorithm: Literal["most_recent", "semantic", "most_recent_semantic", "trending"] = "most_recent" | |
| ): | |
| domain_map = { | |
| "sports": "dm_01j0pb465keqmatq9k83dthx34", | |
| "lifestyle": "dm_01j0q82s4bfjmsqkhs3ywm3x6y", | |
| # Add additional domain mappings as needed. | |
| } | |
| data_model_id = domain_map[domain_key] | |
| response = self.client.get_ai_recommendations( | |
| query=query, | |
| data_model_id=data_model_id, | |
| similarity_top_k=similarity_top_k, | |
| ref=ref, | |
| num_articles_ref=num_articles_ref, | |
| search_algorithm=search_algorithm, | |
| ) | |
| return format_results(response) |
Description
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
Fixes # (issue)
New Package?
Did I fill in the
tool.llamahubsection in thepyproject.tomland provide a detailed README.md for my new integration or package?Version Bump?
Did I bump the version in the
pyproject.tomlfile of the package I am updating? (Except for thellama-index-corepackage)Type of Change
Please delete options that are not relevant.
How Has This Been Tested?
Your pull-request will likely not be merged unless it is covered by some form of impactful unit testing.
Suggested Checklist:
make format; make lintto appease the lint godsSummary by CodeRabbit
dappiermodule, including detailed specifications and usage examples.