|
@@ -4,9 +4,10 @@ from litellm.exceptions import APIConnectionError, RateLimitError, ServiceUnavai
|
|
|
from functools import partial
|
|
from functools import partial
|
|
|
|
|
|
|
|
from opendevin import config
|
|
from opendevin import config
|
|
|
|
|
+from opendevin.schema.config import ConfigType
|
|
|
from opendevin.logger import llm_prompt_logger, llm_response_logger
|
|
from opendevin.logger import llm_prompt_logger, llm_response_logger
|
|
|
from opendevin.logger import opendevin_logger as logger
|
|
from opendevin.logger import opendevin_logger as logger
|
|
|
-from opendevin.schema import ConfigType
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
DEFAULT_API_KEY = config.get(ConfigType.LLM_API_KEY)
|
|
DEFAULT_API_KEY = config.get(ConfigType.LLM_API_KEY)
|
|
|
DEFAULT_BASE_URL = config.get(ConfigType.LLM_BASE_URL)
|
|
DEFAULT_BASE_URL = config.get(ConfigType.LLM_BASE_URL)
|
|
@@ -15,8 +16,6 @@ DEFAULT_API_VERSION = config.get(ConfigType.LLM_API_VERSION)
|
|
|
LLM_NUM_RETRIES = config.get(ConfigType.LLM_NUM_RETRIES)
|
|
LLM_NUM_RETRIES = config.get(ConfigType.LLM_NUM_RETRIES)
|
|
|
LLM_RETRY_MIN_WAIT = config.get(ConfigType.LLM_RETRY_MIN_WAIT)
|
|
LLM_RETRY_MIN_WAIT = config.get(ConfigType.LLM_RETRY_MIN_WAIT)
|
|
|
LLM_RETRY_MAX_WAIT = config.get(ConfigType.LLM_RETRY_MAX_WAIT)
|
|
LLM_RETRY_MAX_WAIT = config.get(ConfigType.LLM_RETRY_MAX_WAIT)
|
|
|
-LLM_TIMEOUT = config.get(ConfigType.LLM_TIMEOUT)
|
|
|
|
|
-LLM_MAX_RETURN_TOKENS = config.get(ConfigType.LLM_MAX_RETURN_TOKENS)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class LLM:
|
|
class LLM:
|
|
@@ -32,8 +31,6 @@ class LLM:
|
|
|
num_retries=LLM_NUM_RETRIES,
|
|
num_retries=LLM_NUM_RETRIES,
|
|
|
retry_min_wait=LLM_RETRY_MIN_WAIT,
|
|
retry_min_wait=LLM_RETRY_MIN_WAIT,
|
|
|
retry_max_wait=LLM_RETRY_MAX_WAIT,
|
|
retry_max_wait=LLM_RETRY_MAX_WAIT,
|
|
|
- llm_timeout=LLM_TIMEOUT,
|
|
|
|
|
- llm_max_return_tokens=LLM_MAX_RETURN_TOKENS
|
|
|
|
|
):
|
|
):
|
|
|
"""
|
|
"""
|
|
|
Args:
|
|
Args:
|
|
@@ -44,8 +41,6 @@ class LLM:
|
|
|
num_retries (int, optional): The number of retries for API calls. Defaults to LLM_NUM_RETRIES.
|
|
num_retries (int, optional): The number of retries for API calls. Defaults to LLM_NUM_RETRIES.
|
|
|
retry_min_wait (int, optional): The minimum time to wait between retries in seconds. Defaults to LLM_RETRY_MIN_TIME.
|
|
retry_min_wait (int, optional): The minimum time to wait between retries in seconds. Defaults to LLM_RETRY_MIN_TIME.
|
|
|
retry_max_wait (int, optional): The maximum time to wait between retries in seconds. Defaults to LLM_RETRY_MAX_TIME.
|
|
retry_max_wait (int, optional): The maximum time to wait between retries in seconds. Defaults to LLM_RETRY_MAX_TIME.
|
|
|
- llm_timeout (int, optional): The maximum time to wait for a response in seconds. Defaults to LLM_TIMEOUT.
|
|
|
|
|
- llm_max_return_tokens (int, optional): The maximum number of tokens to return. Defaults to LLM_MAX_RETURN_TOKENS.
|
|
|
|
|
|
|
|
|
|
Attributes:
|
|
Attributes:
|
|
|
model_name (str): The name of the language model.
|
|
model_name (str): The name of the language model.
|
|
@@ -59,11 +54,9 @@ class LLM:
|
|
|
self.api_key = api_key
|
|
self.api_key = api_key
|
|
|
self.base_url = base_url
|
|
self.base_url = base_url
|
|
|
self.api_version = api_version
|
|
self.api_version = api_version
|
|
|
- self.llm_timeout = llm_timeout
|
|
|
|
|
- self.llm_max_return_tokens = llm_max_return_tokens
|
|
|
|
|
|
|
|
|
|
self._completion = partial(
|
|
self._completion = partial(
|
|
|
- litellm_completion, model=self.model_name, api_key=self.api_key, base_url=self.base_url, api_version=self.api_version, max_tokens=self.llm_max_return_tokens, timeout=self.llm_timeout)
|
|
|
|
|
|
|
+ litellm_completion, model=self.model_name, api_key=self.api_key, base_url=self.base_url, api_version=self.api_version)
|
|
|
|
|
|
|
|
completion_unwrapped = self._completion
|
|
completion_unwrapped = self._completion
|
|
|
|
|
|