Skip to content

Commit

Permalink
Fix: LLM API Key Error Handling (#21)
Browse files Browse the repository at this point in the history
* Fix 'NoneType' Object Error in Tool Loading

## What Changed
1. **Local Tool Loading**: Added logic to check and load tools from the local directory first.
2. **Fixed NoneType Error**: Resolved the issue where the version was `None`, causing a `'NoneType' object has no attribute 'replace'` error.
3. **Improved Error Messages**: Enhanced error messages for better clarity and debugging.

## How It Works Now
- **Local First**: The system first checks the local tools folder.
- **Use Local Tool**: If a tool is found locally, it uses that version.
- **Remote Fallback**: If not found locally, it downloads the tool.
- **Version Handling**: Retrieves version from local `config.json` to ensure correct versioning.

## Testing
- Tested with `math_agent` using local `wikipedia` tool.
- Tested with `story_teller` agent.
- Confirmed no NoneType errors occur.

* Fix 'NoneType' Object Error in Tool Loading

## What Changed
1. **Local Tool Loading**: Added logic to check and load tools from the local directory first.
2. **Fixed NoneType Error**: Resolved the issue where the version was `None`, causing a `'NoneType' object has no attribute 'replace'` error.
3. **Improved Error Messages**: Enhanced error messages for better clarity and debugging.

## How It Works Now
- **Local First**: The system first checks the local tools folder.
- **Use Local Tool**: If a tool is found locally, it uses that version.
- **Remote Fallback**: If not found locally, it downloads the tool.
- **Version Handling**: Retrieves version from local `config.json` to ensure correct versioning.

* Fix 'NoneType' Object Error in Tool Loading

## What Changed
1. **Local Tool Loading**: Added logic to check and load tools from the local directory first.
2. **Fixed NoneType Error**: Resolved the issue where the version was `None`, causing a `'NoneType' object has no attribute 'replace'` error.
3. **Improved Error Messages**: Enhanced error messages for better clarity and debugging.

## How It Works Now
- **Local First**: The system first checks the local tools folder.
- **Use Local Tool**: If a tool is found locally, it uses that version.
- **Remote Fallback**: If not found locally, it downloads the tool.
- **Version Handling**: Retrieves version from local `config.json` to ensure correct versioning.

* Fix 'NoneType' Object Error in Tool Loading

## What Changed
1. **Local Tool Loading**: Added logic to check and load tools from the local directory first.
2. **Fixed NoneType Error**: Resolved the issue where the version was `None`, causing a `'NoneType' object has no attribute 'replace'` error.
3. **Improved Error Messages**: Enhanced error messages for better clarity and debugging.

## How It Works Now
- **Local First**: The system first checks the local tools folder.
- **Use Local Tool**: If a tool is found locally, it uses that version.
- **Remote Fallback**: If not found locally, it downloads the tool.
- **Version Handling**: Retrieves version from local `config.json` to ensure correct versioning.

* Fix

* Create python-package-conda.yml

* Update python-package-conda.yml

* Update python-package-conda.yml

* Update python-package-conda.yml

* Update python-package-conda.yml

* Update python-package-conda.yml

* Update python-package-conda.yml

* Update python-package-conda.yml

* Update python-package-conda.yml

* fix: improve agent loading and error handling

- Add debug logs to track agent loading
- Fix config handling in agent manager
- Update seeact_demo_agent config format

The code now:
- Shows better error messages
- Loads agents more reliably
- Keeps full config when packaging"

* Add Local Agent Support to run-agent

## What's Changed
- Added `--local_agent` flag to support loading agents from local filesystem
- Added path validation for local agent loading
- Simplified agent execution logic

* Refactor Configuration Management for URLs

This PR refactors the configuration management for Cerebrum by moving the URLs for the Agent and Tool Managers into a centralized configuration file (default.yaml). This change allows for easier management and customization of these URLs across different environments.
Changes:
Added agent_hub_url and tool_hub_url to default.yaml.
2. Updated AutoAgent and AutoTool classes to use URLs from the configuration file.

* Revert "Add Local Agent Support to run-agent"

This reverts commit 1324ed1.

* Reapply "Add Local Agent Support to run-agent"

* Revert "Refactor Configuration Management for URLs"

This reverts commit 53fd503.

* Update run_agent.py

* Update run_agent.py

* fix: LLM API Key Error Handling

## What's Changed
- Added proper error handling for invalid API keys
- Fixed response parsing for LiteLLM completion calls
- Added HTTP status codes for different error types:
  - 402 for API key issues
  - 500 for other errors

* Update
  • Loading branch information
XiangZhang-zx authored Jan 20, 2025
1 parent 12cdcc6 commit bf89343
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions cerebrum/llm/communication.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,17 @@ class Response(BaseModel):
Response class represents the output structure after performing actions.
Attributes:
response_message (Optional[str]): The generated response message. Default is None.
tool_calls (Optional[List[Dict[str, Any]]]): An optional list of JSON-like objects (dictionaries)
representing the tool calls made during processing. Default is None.
response_message (Optional[str]): The generated response message.
tool_calls (Optional[List[Dict[str, Any]]]): Tool calls made during processing.
finished (bool): Whether the processing is complete.
error (Optional[str]): Error message if any.
status_code (int): HTTP status code of the response.
"""
response_message: Optional[str] = None # The generated response message, default is None.
tool_calls: Optional[List[Dict[str, Any]]] = None # List of JSON-like objects representing tool calls, default is None.
finished: bool
response_message: Optional[str] = None
tool_calls: Optional[List[Dict[str, Any]]] = None
finished: bool = False
error: Optional[str] = None
status_code: int = 200

class Config:
arbitrary_types_allowed = True # Allows arbitrary types in validation.
arbitrary_types_allowed = True

0 comments on commit bf89343

Please sign in to comment.