chore: refactor not to use warnings.warn (#5730)
* refactor not to use warnings.warn * temp circular import fix maybe unecessary/bnad * fix Deprecation warning * fix deprecation warning and mcp thing? * revert changes to mcp server test * fix deprecation warning
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
# Import constants from settings to avoid circular import
|
||||
# (settings.py imports from this module indirectly through log.py)
|
||||
# Import this here to avoid circular dependency at module level
|
||||
from letta.local_llm.llm_chat_completion_wrappers.chatml import ChatMLInnerMonologueWrapper
|
||||
from letta.settings import DEFAULT_WRAPPER_NAME, INNER_THOUGHTS_KWARG
|
||||
|
||||
DEFAULT_WRAPPER = ChatMLInnerMonologueWrapper
|
||||
DEFAULT_WRAPPER_NAME = "chatml"
|
||||
|
||||
INNER_THOUGHTS_KWARG = "thinking"
|
||||
INNER_THOUGHTS_KWARG_VERTEX = "thinking"
|
||||
VALID_INNER_THOUGHTS_KWARGS = ("thinking", "inner_thoughts")
|
||||
INNER_THOUGHTS_KWARG_DESCRIPTION = "Deep inner monologue private to you only."
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import json
|
||||
import re
|
||||
import warnings
|
||||
|
||||
from letta.log import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
from letta.errors import LLMJSONParsingError
|
||||
from letta.helpers.json_helpers import json_loads
|
||||
@@ -83,7 +86,7 @@ def clean_and_interpret_send_message_json(json_string):
|
||||
|
||||
kwarg = model_settings.inner_thoughts_kwarg
|
||||
if kwarg not in VALID_INNER_THOUGHTS_KWARGS:
|
||||
warnings.warn(f"INNER_THOUGHTS_KWARG is not valid: {kwarg}")
|
||||
logger.warning(f"INNER_THOUGHTS_KWARG is not valid: {kwarg}")
|
||||
kwarg = INNER_THOUGHTS_KWARG
|
||||
|
||||
# If normal parsing fails, attempt to clean and extract manually
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import os
|
||||
import warnings
|
||||
from typing import List, Union
|
||||
|
||||
import requests
|
||||
@@ -84,11 +83,11 @@ def num_tokens_from_functions(functions: List[dict], model: str = "gpt-4"):
|
||||
function_tokens = len(encoding.encode(function["name"]))
|
||||
if function["description"]:
|
||||
if not isinstance(function["description"], str):
|
||||
warnings.warn(f"Function {function['name']} has non-string description: {function['description']}")
|
||||
logger.warning(f"Function {function['name']} has non-string description: {function['description']}")
|
||||
else:
|
||||
function_tokens += len(encoding.encode(function["description"]))
|
||||
else:
|
||||
warnings.warn(f"Function {function['name']} has no description, function: {function}")
|
||||
logger.warning(f"Function {function['name']} has no description, function: {function}")
|
||||
|
||||
if "parameters" in function:
|
||||
parameters = function["parameters"]
|
||||
|
||||
Reference in New Issue
Block a user