Skip to content

Commit 76e7640

Browse files
umaannamalaigithub-actions[bot]
authored andcommitted
[Mega-Linter] Apply linters fixes
1 parent 1c27c2b commit 76e7640

15 files changed

+27
-20
lines changed

newrelic/agent.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ def __asgi_application(*args, **kwargs):
139139
from newrelic.api.html_insertion import verify_body_exists as __verify_body_exists
140140
from newrelic.api.lambda_handler import LambdaHandlerWrapper as __LambdaHandlerWrapper
141141
from newrelic.api.lambda_handler import lambda_handler as __lambda_handler
142+
from newrelic.api.llm_custom_attributes import (
143+
WithLlmCustomAttributes as __WithLlmCustomAttributes,
144+
)
142145
from newrelic.api.message_trace import MessageTrace as __MessageTrace
143146
from newrelic.api.message_trace import MessageTraceWrapper as __MessageTraceWrapper
144147
from newrelic.api.message_trace import message_trace as __message_trace
@@ -156,9 +159,10 @@ def __asgi_application(*args, **kwargs):
156159
from newrelic.api.ml_model import (
157160
record_llm_feedback_event as __record_llm_feedback_event,
158161
)
159-
from newrelic.api.ml_model import set_llm_token_count_callback as __set_llm_token_count_callback
162+
from newrelic.api.ml_model import (
163+
set_llm_token_count_callback as __set_llm_token_count_callback,
164+
)
160165
from newrelic.api.ml_model import wrap_mlmodel as __wrap_mlmodel
161-
from newrelic.api.llm_custom_attributes import WithLlmCustomAttributes as __WithLlmCustomAttributes
162166
from newrelic.api.profile_trace import ProfileTraceWrapper as __ProfileTraceWrapper
163167
from newrelic.api.profile_trace import profile_trace as __profile_trace
164168
from newrelic.api.profile_trace import wrap_profile_trace as __wrap_profile_trace

newrelic/api/llm_custom_attributes.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
import logging
16+
1617
from newrelic.api.transaction import current_transaction
1718

1819
_logger = logging.getLogger(__name__)
@@ -22,7 +23,9 @@ class WithLlmCustomAttributes(object):
2223
def __init__(self, custom_attr_dict):
2324
transaction = current_transaction()
2425
if not custom_attr_dict or not isinstance(custom_attr_dict, dict):
25-
raise TypeError("custom_attr_dict must be a non-empty dictionary. Received type: %s" % type(custom_attr_dict))
26+
raise TypeError(
27+
"custom_attr_dict must be a non-empty dictionary. Received type: %s" % type(custom_attr_dict)
28+
)
2629

2730
# Add "llm." prefix to all keys in attribute dictionary
2831
context_attrs = {k if k.startswith("llm.") else f"llm.{k}": v for k, v in custom_attr_dict.items()}

newrelic/hooks/mlmodel_langchain.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,9 +452,7 @@ def _record_tool_success(
452452
try:
453453
result = str(response)
454454
except Exception:
455-
_logger.debug(
456-
f"Failed to convert tool response into a string.\n{traceback.format_exception(*sys.exc_info())}"
457-
)
455+
_logger.debug(f"Failed to convert tool response into a string.\n{traceback.format_exception(*sys.exc_info())}")
458456
if settings.ai_monitoring.record_content.enabled:
459457
full_tool_event_dict.update(
460458
{

tests/agent_features/test_llm_custom_attributes.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# Copyright 2010 New Relic, Inc.
32
#
43
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,8 +15,8 @@
1615
import pytest
1716

1817
from newrelic.api.background_task import background_task
19-
from newrelic.api.transaction import current_transaction
2018
from newrelic.api.llm_custom_attributes import WithLlmCustomAttributes
19+
from newrelic.api.transaction import current_transaction
2120

2221

2322
@background_task()

tests/external_botocore/test_bedrock_chat_completion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@
5959
)
6060

6161
from newrelic.api.background_task import background_task
62-
from newrelic.api.transaction import add_custom_attribute
6362
from newrelic.api.llm_custom_attributes import WithLlmCustomAttributes
63+
from newrelic.api.transaction import add_custom_attribute
6464
from newrelic.common.object_names import callable_name
6565
from newrelic.hooks.external_botocore import MODEL_EXTRACTORS
6666

tests/external_botocore/test_bedrock_chat_completion_via_langchain.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919
)
2020
from conftest import BOTOCORE_VERSION # pylint: disable=E0611
2121
from testing_support.fixtures import reset_core_stats_engine, validate_attributes
22-
from testing_support.ml_testing_utils import set_trace_info, events_with_context_attrs # noqa: F401
22+
from testing_support.ml_testing_utils import ( # noqa: F401
23+
events_with_context_attrs,
24+
set_trace_info,
25+
)
2326
from testing_support.validators.validate_custom_event import validate_custom_event_count
2427
from testing_support.validators.validate_custom_events import validate_custom_events
2528
from testing_support.validators.validate_transaction_metrics import (

tests/mlmodel_langchain/test_chain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
)
4848

4949
from newrelic.api.background_task import background_task
50-
from newrelic.api.transaction import add_custom_attribute
5150
from newrelic.api.llm_custom_attributes import WithLlmCustomAttributes
51+
from newrelic.api.transaction import add_custom_attribute
5252
from newrelic.common.object_names import callable_name
5353

5454
_test_openai_chat_completion_messages = (

tests/mlmodel_langchain/test_vectorstore.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
)
3737

3838
from newrelic.api.background_task import background_task
39-
from newrelic.api.transaction import add_custom_attribute
4039
from newrelic.api.llm_custom_attributes import WithLlmCustomAttributes
40+
from newrelic.api.transaction import add_custom_attribute
4141
from newrelic.common.object_names import callable_name
4242

4343

tests/mlmodel_openai/test_chat_completion.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434
from testing_support.validators.validate_transaction_metrics import (
3535
validate_transaction_metrics,
3636
)
37+
3738
from newrelic.api.background_task import background_task
38-
from newrelic.api.transaction import add_custom_attribute
3939
from newrelic.api.llm_custom_attributes import WithLlmCustomAttributes
40-
40+
from newrelic.api.transaction import add_custom_attribute
4141

4242
_test_openai_chat_completion_messages = (
4343
{"role": "system", "content": "You are a scientist."},

tests/mlmodel_openai/test_chat_completion_error.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
)
4040

4141
from newrelic.api.background_task import background_task
42-
from newrelic.api.transaction import add_custom_attribute
4342
from newrelic.api.llm_custom_attributes import WithLlmCustomAttributes
43+
from newrelic.api.transaction import add_custom_attribute
4444
from newrelic.common.object_names import callable_name
4545

4646
_test_openai_chat_completion_messages = (

0 commit comments

Comments
 (0)