Skip to content

I'm encountering a persistent TypeError when trying to use the GoogleSearch class from knowledge_storm.rm, even after extensive troubleshooting and a complete rebuild of my environment. The error message is always: #333

Open
@diriftking

Description

@diriftking

This error occurs despite the fact that:

  1. I am using the correct parameter names (api_key and cse_id) in my code, as specified in the knowledge_storm documentation and source code.
  2. I am using an alias when importing GoogleSearch to prevent naming conflicts: from knowledge_storm.rm import GoogleSearch as KStormGoogleSearch.
  3. I have verified that knowledge-storm is installed correctly (version 1.1.0) and that the __init__ method of the GoogleSearch class in the installed library does indeed accept api_key and cse_id.
  4. I have confirmed that the dspy-ai and dspy are not installed.
  5. I have created a minimal test script, that should isolate this error.
  6. I have a fresh VPS instance, using Ubunto 24.
  7. I use a conda environment.

Steps I've Taken (Extensive Troubleshooting):

I have gone through extensive troubleshooting steps, including:

  • Complete VPS Rebuild: I started with a fresh Ubuntu 24.04 VPS instance.
  • Fresh Conda Environment: I created a new conda environment (storm) with Python 3.11.
  • Precise Dependency Installation: I installed specific, known-good versions of all dependencies using a requirements.txt file, including knowledge-storm==1.1.0, and pinned versions of python-telegram-bot, reportlab, tqdm, google-api-python-client, google-generativeai, litellm, numpy, and httpx. I have also tried reinstalling them individually.
  • dspy-ai and dspy Removal: I have completely uninstalled dspy-ai and dspy to eliminate any potential naming conflicts.
  • Cache Clearing: I have cleared the pip cache (pip cache purge) and deleted all .pyc files.
  • Environment Variable Verification: I have confirmed that the necessary environment variables (GOOGLE_API_KEY, GOOGLE_CSE_ID, GEMINI_API_KEY, TELEGRAM_BOT_TOKEN, GOOGLE_APPLICATION_CREDENTIALS) are set correctly in my .bashrc and are accessible within the Python script.
  • Service Account and Permissions: I have created a Google Cloud service account, granted it the "Vertex AI User" role, downloaded the JSON key file, and correctly configured GOOGLE_APPLICATION_CREDENTIALS.
  • Vertex AI API Enabled: I have confirmed that the Vertex AI API is enabled for my Google Cloud project.
  • Code Verification: I have repeatedly verified that my storm_bot.py code uses the correct alias (KStormGoogleSearch) and the correct parameter names (api_key, cse_id).
  • Direct Module Inspection: I have used python -c "import knowledge_storm.rm; print(knowledge_storm.rm.__file__)" to verify that knowledge_storm is being imported from the correct location within the conda environment. I have used nano to inspect the rm.py file directly and confirm that the GoogleSearch class does accept api_key and cse_id.
  • Testing with test_import.py: I created the small testing script provided and the error persists.
  • Tried Different LLMs: I have tried using OpenRouter and DeepSeek as alternative LLMs, to rule out any Gemini-specific issues. The TypeError with GoogleSearch persists regardless of the LLM used.
  • I have reviewed the opened and closed issues, and found no issue related to mine.

Minimal Reproducible Example:

# test_import.py
import os
from knowledge_storm.rm import GoogleSearch as KStormGoogleSearch

# Dummy values (the error occurs even with these)
os.environ["GOOGLE_API_KEY"] = "dummy_key"
os.environ["GOOGLE_CSE_ID"] = "dummy_id"

try:
    rm = KStormGoogleSearch(api_key="dummy_key", cse_id="dummy_id", k=3)
    print("Successfully instantiated KStormGoogleSearch!")
except Exception as e:
    print(f"Error instantiating KStormGoogleSearch: {e}")
Running this script (python /root/storm/test_import.py within the activated storm conda environment) produces the TypeError.

Expected Behavior:

The KStormGoogleSearch class should be instantiated successfully, as the api_key and cse_id parameters are correct for the knowledge_storm.rm.GoogleSearch class.

Actual Behavior:

A TypeError is raised, indicating that the GoogleSearch class being called does not accept api_key. This suggests that, despite all efforts, the wrong GoogleSearch class (likely from a hidden or cached dspy-ai installation) is being used.

Environment:

OS: Ubuntu 24.04 (fresh VPS install)
Python: 3.11
knowledge-storm: 1.1.0
conda: (Miniconda, latest version)
Request:

I am completely stumped as to why this error is persisting. I believe I have eliminated all the usual causes of such an issue.  Could you please investigate this and provide guidance on how to resolve it?  Is there any possibility of a deeply hidden caching issue or a conflict with another installed package that I've missed? Any help would be greatly appreciated.


**Key Improvements in this Issue Report:**

*   **Clear Title:**  Immediately states the core problem.
*   **Concise Summary:**  Quickly explains the error and the key troubleshooting steps.
*   **Reproducible Example:**  Provides a *minimal* script that demonstrates the error, making it easy for the developers to reproduce.
*   **Extensive Troubleshooting List:**  Clearly outlines *all* the steps taken, demonstrating the thoroughness of the troubleshooting.
*   **Environment Details:**  Provides specific information about the environment.
*   **Expected vs. Actual Behavior:**  Clearly states what *should* happen and what *is* happening.
*   **Polite and Respectful Tone:**  Acknowledges the unusual nature of the problem and requests assistance.

**Submitting the Issue:**

1.  Go to the `knowledge-storm` GitHub repository: [https://github.com/stanford-oval/storm](https://www.google.com/search?q=https://www.google.com/url%3Fsa%3DE%26source%3Dgmail%26q%3Dhttps://github.com/stanford-oval/storm)
2.  Click on the "Issues" tab.
3.  Click on the "New issue" button.
4.  Paste the title and body (from above) into the appropriate fields.
5.  Submit the issue.

Hopefully, the developers of `knowledge-storm` will be able to shed some light on this very unusual problem. Good luck!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions