Skip to content

Commit 415dc73

Browse files
Fix Langchain Tests (#1287)
* Fix issue with document ID changing content of request * Add temperature explicitly as an argument to openai client --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent d13cf32 commit 415dc73

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

tests/mlmodel_langchain/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ def openai_clients(openai_version, MockExternalOpenAIServer): # noqa: F811
7373
chat = ChatOpenAI(
7474
base_url=f"http://localhost:{server.port}",
7575
api_key="NOT-A-REAL-SECRET",
76+
temperature=0.7,
7677
)
7778
embeddings = OpenAIEmbeddings(
7879
openai_api_key="NOT-A-REAL-SECRET", openai_api_base=f"http://localhost:{server.port}"

tests/mlmodel_langchain/test_chain.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@
525525
"vendor": "langchain",
526526
"ingest_source": "Python",
527527
"virtual_llm": True,
528-
"content": "{'input': 'math', 'context': [Document(metadata={}, page_content='What is 2 + 4?')]}",
528+
"content": "{'input': 'math', 'context': [Document(id='1234', metadata={}, page_content='What is 2 + 4?')]}",
529529
},
530530
],
531531
[
@@ -557,7 +557,7 @@
557557
"ingest_source": "Python",
558558
"is_response": True,
559559
"virtual_llm": True,
560-
"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```'}",
560+
"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```'}",
561561
},
562562
],
563563
]
@@ -1814,7 +1814,7 @@ def _test():
18141814
@background_task()
18151815
def test_retrieval_chains(set_trace_info, retrieval_chain_prompt, embedding_openai_client, chat_openai_client):
18161816
set_trace_info()
1817-
documents = [langchain_core.documents.Document(page_content="What is 2 + 4?")]
1817+
documents = [langchain_core.documents.Document(id="1234", page_content="What is 2 + 4?")]
18181818
vectordb = FAISS.from_documents(documents=documents, embedding=embedding_openai_client)
18191819
retriever = vectordb.as_retriever()
18201820
question_answer_chain = create_stuff_documents_chain(

0 commit comments

Comments
 (0)