Skip to content

armgit / camel

Public Imported from GitHub
0

🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org

fix: Ollama and VLLM api key & url setting (#2316)

Wendong-Fan52132a475037
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
index f96fa51d3..c063a7941 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.yml
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -26,7 +26,7 @@ body:
attributes:
label: What version of camel are you using?
description: Run command `python3 -c 'print(__import__("camel").__version__)'` in your shell and paste the output here.
- placeholder: E.g., 0.2.50
+ placeholder: E.g., 0.2.51
validations:
required: true
diff --git a/camel/__init__.py b/camel/__init__.py
index 570c3adfc..cab70fefd 100644
--- a/camel/__init__.py
+++ b/camel/__init__.py
@@ -14,7 +14,7 @@
from camel.logger import disable_logging, enable_logging, set_log_level
-__version__ = '0.2.50'
+__version__ = '0.2.51'
__all__ = [
'__version__',
diff --git a/camel/models/ollama_model.py b/camel/models/ollama_model.py
index 02f9d2a6d..531155bee 100644
--- a/camel/models/ollama_model.py
+++ b/camel/models/ollama_model.py
@@ -16,10 +16,13 @@ import subprocess
from typing import Any, Dict, Optional, Union
from camel.configs import OLLAMA_API_PARAMS, OllamaConfig
+from camel.logger import get_logger
from camel.models.openai_compatible_model import OpenAICompatibleModel
from camel.types import ModelType
from camel.utils import BaseTokenCounter
+logger = get_logger(__name__)
+
class OllamaModel(OpenAICompatibleModel):
r"""Ollama service interface.
@@ -60,20 +63,22 @@ class OllamaModel(OpenAICompatibleModel):
) -> None:
if model_config_dict is None:
model_config_dict = OllamaConfig().as_dict()
- url = url or os.environ.get("OLLAMA_BASE_URL")
+ self._url = url or os.environ.get("OLLAMA_BASE_URL")
timeout = timeout or float(os.environ.get("MODEL_TIMEOUT", 180))
+ self._model_type = model_type
+
+ if not self._url:
+ self._start_server()
+
super().__init__(
- model_type=model_type,
+ model_type=self._model_type,
model_config_dict=model_config_dict,
- api_key=api_key,
- url=url,
+ api_key="Not_Used",
+ url=self._url,
token_counter=token_counter,
timeout=timeout,
)
- if not self._url:
- self._start_server()
-
def _start_server(self) -> None:
r"""Starts the Ollama server in a subprocess."""
try:
@@ -83,12 +88,12 @@ class OllamaModel(OpenAICompatibleModel):
stderr=subprocess.PIPE,
)
self._url = "http://localhost:11434/v1"
- print(
+ logger.info(
f"Ollama server started on {self._url} "
- f"for {self.model_type} model."
+ f"for {self._model_type} model."
)
except Exception as e:
- print(f"Failed to start Ollama server: {e}.")
+ logger.error(f"Failed to start Ollama server: {e}.")
def check_model_config(self):
r"""Check whether the model configuration contains any
diff --git a/camel/models/vllm_model.py b/camel/models/vllm_model.py
index b6e4ccccb..34bfdf030 100644
--- a/camel/models/vllm_model.py
+++ b/camel/models/vllm_model.py
@@ -16,10 +16,13 @@ import subprocess
from typing import Any, Dict, Optional, Union
from camel.configs import VLLM_API_PARAMS, VLLMConfig
+from camel.logger import get_logger
from camel.models.openai_compatible_model import OpenAICompatibleModel
from camel.types import ModelType
from camel.utils import BaseTokenCounter
+logger = get_logger(__name__)
+
# flake8: noqa: E501
class VLLMModel(OpenAICompatibleModel):
@@ -62,18 +65,21 @@ class VLLMModel(OpenAICompatibleModel):
) -> None:
if model_config_dict is None:
model_config_dict = VLLMConfig().as_dict()
- url = url or os.environ.get("VLLM_BASE_URL")
+ self._url = url or os.environ.get("VLLM_BASE_URL")
timeout = timeout or float(os.environ.get("MODEL_TIMEOUT", 180))
+ self._model_type = model_type
+
+ if not self._url:
+ self._start_server()
+
super().__init__(
- model_type=model_type,
+ model_type=self._model_type,
model_config_dict=model_config_dict,
- api_key=api_key,
- url=url,
+ api_key="Not_Used",
+ url=self._url,
token_counter=token_counter,
timeout=timeout,
)
- if not self._url:
- self._start_server()
def _start_server(self) -> None:
r"""Starts the vllm server in a subprocess."""
@@ -84,12 +90,12 @@ class VLLMModel(OpenAICompatibleModel):
stderr=subprocess.PIPE,
)
self._url = "http://localhost:8000/v1"
- print(
+ logger.info(
f"vllm server started on {self._url} "
- f"for {self.model_type} model."
+ f"for {self._model_type} model."
)
except Exception as e:
- print(f"Failed to start vllm server: {e}.")
+ logger.error(f"Failed to start vllm server: {e}.")
def check_model_config(self):
r"""Check whether the model configuration contains any
diff --git a/docs/conf.py b/docs/conf.py
index 5d64b9e41..f9ac25adf 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -27,7 +27,7 @@ sys.path.insert(0, os.path.abspath('..'))
project = 'CAMEL'
copyright = '2024, CAMEL-AI.org'
author = 'CAMEL-AI.org'
-release = '0.2.50'
+release = '0.2.51'
html_favicon = (
'https://raw.githubusercontent.com/camel-ai/camel/master/misc/favicon.png'
diff --git a/docs/key_modules/loaders.md b/docs/key_modules/loaders.md
index 380a011e8..d4de37472 100644
--- a/docs/key_modules/loaders.md
+++ b/docs/key_modules/loaders.md
@@ -340,14 +340,14 @@ response = jina_reader.read_content("https://docs.camel-ai.org/")
print(response)
```
```markdown
->>>Welcome to CAMEL’s documentation! — CAMEL 0.2.50 documentation
+>>>Welcome to CAMEL’s documentation! — CAMEL 0.2.51 documentation
===============
[Skip to main content](https://docs.camel-ai.org/#main-content)
Back to top Ctrl+K
- [![Image 1](https://raw.githubusercontent.com/camel-ai/camel/master/misc/logo_light.png) ![Image 2](https://raw.githubusercontent.com/camel-ai/camel/master/misc/logo_light.png)CAMEL 0.2.50](https://docs.camel-ai.org/#)
+ [![Image 1](https://raw.githubusercontent.com/camel-ai/camel/master/misc/logo_light.png) ![Image 2](https://raw.githubusercontent.com/camel-ai/camel/master/misc/logo_light.png)CAMEL 0.2.51](https://docs.camel-ai.org/#)
Search Ctrl+K
diff --git a/pyproject.toml b/pyproject.toml
index a9a3d14a3..912ba62a5 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "camel-ai"
-version = "0.2.50"
+version = "0.2.51"
description = "Communicative Agents for AI Society Study"
authors = [{ name = "CAMEL-AI.org" }]
requires-python = ">=3.10,<3.13"
diff --git a/uv.lock b/uv.lock
index 906d092d6..ad69018b6 100644
--- a/uv.lock
+++ b/uv.lock
@@ -539,7 +539,7 @@ wheels = [
[[package]]
name = "camel-ai"
-version = "0.2.50"
+version = "0.2.51"
source = { editable = "." }
dependencies = [
{ name = "colorama" },