Skip to content
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

Fix AttributeError in chat method of OpenAIAgentService #1653

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ticklecatisback
Copy link

Fix the AttributeError: 'SystemMessage' object has no attribute 'role' in the chat method of the OpenAIAgentService class.

  • Update chat method in platform/reworkd_platform/web/api/agent/agent_service/open_ai_agent_service.py

    • Modify the list comprehension to include a conditional check for the role attribute.
    • Handle SystemMessagePromptTemplate objects correctly by checking for the presence of the role attribute before accessing it.
  • Update imports and methods in various files to use ollama

    • Update imports in platform/reworkd_platform/web/api/agent/tools/code.py, platform/reworkd_platform/web/api/agent/tools/image.py, platform/reworkd_platform/web/api/agent/tools/search.py, platform/reworkd_platform/web/api/agent/tools/sidsearch.py, and platform/reworkd_platform/web/api/agent/tools/utils.py to use ollama.
    • Modify methods to use ollama.Client for chat and streaming responses.
  • Add setup.py for package installation

    • Add setup.py to define the package and its dependencies.
  • Update pyproject.toml

    • Change Python version to ^3.10.
    • Add ollama as a dependency.
    • Update build system to use setuptools.
  • Update README.md

    • Add instructions for installing the package using pip.
    • Add examples for using the package in code.
    • Add instructions for using ollama.
    • Add instructions for using Python 3.10.

Fix the `AttributeError: 'SystemMessage' object has no attribute 'role'` in the `chat` method of the `OpenAIAgentService` class.

* **Update `chat` method in `platform/reworkd_platform/web/api/agent/agent_service/open_ai_agent_service.py`**
  - Modify the list comprehension to include a conditional check for the `role` attribute.
  - Handle `SystemMessagePromptTemplate` objects correctly by checking for the presence of the `role` attribute before accessing it.

* **Update imports and methods in various files to use `ollama`**
  - Update imports in `platform/reworkd_platform/web/api/agent/tools/code.py`, `platform/reworkd_platform/web/api/agent/tools/image.py`, `platform/reworkd_platform/web/api/agent/tools/search.py`, `platform/reworkd_platform/web/api/agent/tools/sidsearch.py`, and `platform/reworkd_platform/web/api/agent/tools/utils.py` to use `ollama`.
  - Modify methods to use `ollama.Client` for chat and streaming responses.

* **Add `setup.py` for package installation**
  - Add `setup.py` to define the package and its dependencies.

* **Update `pyproject.toml`**
  - Change Python version to `^3.10`.
  - Add `ollama` as a dependency.
  - Update build system to use `setuptools`.

* **Update `README.md`**
  - Add instructions for installing the package using pip.
  - Add examples for using the package in code.
  - Add instructions for using `ollama`.
  - Add instructions for using Python 3.10.
Copy link

vercel bot commented Nov 11, 2024

@ticklecatisback is attempting to deploy a commit to the reworkd Team on Vercel.

A member of the Team first needs to authorize it.

* **Settings**: Add `ollama_api_key` and `ollama_api_base` attributes to `Settings` class in `platform/reworkd_platform/settings.py`.
* **Model Factory**: Add `ollama_api_key` attribute to `ModelSettings` class and include it in kwargs if present in `platform/reworkd_platform/web/api/agent/model_factory.py`.
* **New Service**: Add `OllamaAgentService` class in `platform/reworkd_platform/web/api/agent/agent_service/ollama_agent_service.py` to handle interactions with the Ollama API.
* **Environment Schema**: Update `next/src/env/schema.mjs` to include `OLLAMA_API_KEY`.
* **Documentation**: Update various README files to reflect recent changes and new features.
* **README.md**
  - Add a new section with an example of initializing the `OpenAIAgentService`, setting up the environment, and running the main function.

* **platform/README.md**
  - Add a new section with an example of initializing the `OpenAIAgentService`, setting up the environment, and running the main function.

* **platform/reworkd_platform/web/api/agent/agent_service/open_ai_agent_service.py**
  - Add logging statements to various methods for better traceability.

* **platform/reworkd_platform/web/api/agent/model_factory.py**
  - Add logging statements to the `create_model` function.

* **platform/reworkd_platform/services/tokenizer/token_service.py**
  - Add logging statements to various methods for better traceability.

* **platform/reworkd_platform/web/api/dependencies.py**
  - Add logging statements to the `get_current_user` function.

* **platform/reworkd_platform/tests/test_token_service.py**
  - Add a new test case for `calculate_max_tokens` when `max_tokens` is `None`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant