Skip to content

Commit

Permalink
Merge pull request #1285 from newrelic/develop-tests
Browse files Browse the repository at this point in the history
Merge develop-tests into main
  • Loading branch information
TimPansino authored Jan 18, 2025
2 parents e4ff798 + 415dc73 commit 9dd76a8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
4 changes: 3 additions & 1 deletion newrelic/hooks/framework_starlette.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,9 @@ def instrument_starlette_middleware_exceptions(module):
def instrument_starlette_exceptions(module):
# ExceptionMiddleware was moved to starlette.middleware.exceptions, need to check
# that it isn't being imported through a deprecation and double wrapped.
if not hasattr(module, "__deprecated__"):

# After v0.45.0, the import proxy for ExceptionMiddleware was removed from starlette.exceptions
if not hasattr(module, "__deprecated__") and hasattr(module, "ExceptionMiddleware"):

wrap_function_wrapper(module, "ExceptionMiddleware.__call__", error_middleware_wrapper)

Expand Down
1 change: 1 addition & 0 deletions tests/mlmodel_langchain/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def openai_clients(openai_version, MockExternalOpenAIServer): # noqa: F811
chat = ChatOpenAI(
base_url=f"http://localhost:{server.port}",
api_key="NOT-A-REAL-SECRET",
temperature=0.7,
)
embeddings = OpenAIEmbeddings(
openai_api_key="NOT-A-REAL-SECRET", openai_api_base=f"http://localhost:{server.port}"
Expand Down
6 changes: 3 additions & 3 deletions tests/mlmodel_langchain/test_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@
"vendor": "langchain",
"ingest_source": "Python",
"virtual_llm": True,
"content": "{'input': 'math', 'context': [Document(metadata={}, page_content='What is 2 + 4?')]}",
"content": "{'input': 'math', 'context': [Document(id='1234', metadata={}, page_content='What is 2 + 4?')]}",
},
],
[
Expand Down Expand Up @@ -557,7 +557,7 @@
"ingest_source": "Python",
"is_response": True,
"virtual_llm": True,
"content": "{'input': 'math', 'context': [Document(metadata={}, page_content='What is 2 + 4?')], 'answer': '```html\\n<!DOCTYPE html>\\n<html>\\n<head>\\n <title>Math Quiz</title>\\n</head>\\n<body>\\n <h2>Math Quiz Questions</h2>\\n <ol>\\n <li>What is the result of 5 + 3?</li>\\n <ul>\\n <li>A) 7</li>\\n <li>B) 8</li>\\n <li>C) 9</li>\\n <li>D) 10</li>\\n </ul>\\n <li>What is the product of 6 x 7?</li>\\n <ul>\\n <li>A) 36</li>\\n <li>B) 42</li>\\n <li>C) 48</li>\\n <li>D) 56</li>\\n </ul>\\n <li>What is the square root of 64?</li>\\n <ul>\\n <li>A) 6</li>\\n <li>B) 7</li>\\n <li>C) 8</li>\\n <li>D) 9</li>\\n </ul>\\n <li>What is the result of 12 / 4?</li>\\n <ul>\\n <li>A) 2</li>\\n <li>B) 3</li>\\n <li>C) 4</li>\\n <li>D) 5</li>\\n </ul>\\n <li>What is the sum of 15 + 9?</li>\\n <ul>\\n <li>A) 22</li>\\n <li>B) 23</li>\\n <li>C) 24</li>\\n <li>D) 25</li>\\n </ul>\\n </ol>\\n</body>\\n</html>\\n```'}",
"content": "{'input': 'math', 'context': [Document(id='1234', metadata={}, page_content='What is 2 + 4?')], 'answer': '```html\\n<!DOCTYPE html>\\n<html>\\n<head>\\n <title>Math Quiz</title>\\n</head>\\n<body>\\n <h2>Math Quiz Questions</h2>\\n <ol>\\n <li>What is the result of 5 + 3?</li>\\n <ul>\\n <li>A) 7</li>\\n <li>B) 8</li>\\n <li>C) 9</li>\\n <li>D) 10</li>\\n </ul>\\n <li>What is the product of 6 x 7?</li>\\n <ul>\\n <li>A) 36</li>\\n <li>B) 42</li>\\n <li>C) 48</li>\\n <li>D) 56</li>\\n </ul>\\n <li>What is the square root of 64?</li>\\n <ul>\\n <li>A) 6</li>\\n <li>B) 7</li>\\n <li>C) 8</li>\\n <li>D) 9</li>\\n </ul>\\n <li>What is the result of 12 / 4?</li>\\n <ul>\\n <li>A) 2</li>\\n <li>B) 3</li>\\n <li>C) 4</li>\\n <li>D) 5</li>\\n </ul>\\n <li>What is the sum of 15 + 9?</li>\\n <ul>\\n <li>A) 22</li>\\n <li>B) 23</li>\\n <li>C) 24</li>\\n <li>D) 25</li>\\n </ul>\\n </ol>\\n</body>\\n</html>\\n```'}",
},
],
]
Expand Down Expand Up @@ -1814,7 +1814,7 @@ def _test():
@background_task()
def test_retrieval_chains(set_trace_info, retrieval_chain_prompt, embedding_openai_client, chat_openai_client):
set_trace_info()
documents = [langchain_core.documents.Document(page_content="What is 2 + 4?")]
documents = [langchain_core.documents.Document(id="1234", page_content="What is 2 + 4?")]
vectordb = FAISS.from_documents(documents=documents, embedding=embedding_openai_client)
retriever = vectordb.as_retriever()
question_answer_chain = create_stuff_documents_chain(
Expand Down
4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ envlist =
python-framework_graphql-py37-graphql{0301,0302},
python-framework_pyramid-{py37,py38,py39,py310,py311,py312,py313,pypy310}-Pyramidlatest,
python-framework_pyramid-{py37,py38,py39,py310,py311,py312,py313,pypy310}-Pyramid0110-cornice,
python-framework_sanic-{py37,py38,py39,py310,py311,py312,py313,pypy310}-saniclatest,
python-framework_sanic-{py37,py38}-sanic2406,
python-framework_sanic-{py39,py310,py311,py312,py313,pypy310}-saniclatest,
python-framework_sanic-{py38,pypy310}-sanic{200904,210300,2109,2112,2203,2290},
python-framework_starlette-{py310,pypy310}-starlette{0014,0015,0019,0028},
python-framework_starlette-{py37,py38,py39,py310,py311,py312,py313,pypy310}-starlettelatest,
Expand Down Expand Up @@ -359,6 +360,7 @@ deps =
framework_sanic-sanic2112: sanic<21.13
framework_sanic-sanic2203: sanic<22.4
framework_sanic-sanic2290: sanic<22.9.1
framework_sanic-sanic2406: sanic<24.07
framework_sanic-saniclatest: sanic
framework_sanic-sanic{200904,210300,2109,2112,2203,2290}: websockets<11
; For test_exception_in_middleware test, anyio is used:
Expand Down

0 comments on commit 9dd76a8

Please sign in to comment.