Skip to content

Commit 402ff1a

Browse files
committed
Merge branch 'next'
merge next
2 parents 06a40a7 + 3a4f6cb commit 402ff1a

File tree

5 files changed

+38
-59
lines changed

5 files changed

+38
-59
lines changed

.github/actions/tests/python/action.yml

Lines changed: 16 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ inputs:
1111
description: "The version of Python to use, such as 3.12"
1212
required: true
1313
type: string
14-
openai-api-organization:
15-
description: "The OpenAI API organization"
16-
required: true
17-
type: string
18-
openai-api-key:
19-
description: "The OpenAI API key"
20-
required: true
21-
type: string
22-
pinecone-api-key:
23-
description: "The Pinecone API key"
24-
required: true
25-
type: string
26-
pinecone-environment:
27-
description: "The Pinecone environment"
28-
required: true
29-
type: string
14+
openai-api-organization:
15+
description: "The OpenAI API organization"
16+
required: true
17+
type: string
18+
openai-api-key:
19+
description: "The OpenAI API key"
20+
required: true
21+
type: string
22+
pinecone-api-key:
23+
description: "The Pinecone API key"
24+
required: true
25+
type: string
26+
pinecone-environment:
27+
description: "The Pinecone environment"
28+
required: true
29+
type: string
3030

3131
runs:
3232
using: "composite"
@@ -35,38 +35,6 @@ runs:
3535
id: checkout
3636
uses: actions/checkout@v4
3737

38-
- name: Check for openai in requirements
39-
shell: bash
40-
run: |
41-
if ! grep -q "openai" ./requirements/local.txt; then
42-
echo "openai not found in requirements/local.txt" >&2
43-
exit 1
44-
fi
45-
46-
- name: Check for langchain in requirements
47-
shell: bash
48-
run: |
49-
if ! grep -q "langchain" ./requirements/local.txt; then
50-
echo "langchain not found in requirements/local.txt" >&2
51-
exit 1
52-
fi
53-
54-
- name: Check for langchain-experimental in requirements
55-
shell: bash
56-
run: |
57-
if ! grep -q "langchain-experimental" ./requirements/local.txt; then
58-
echo "langchain-experimental not found in requirements/local.txt" >&2
59-
exit 1
60-
fi
61-
62-
- name: Check for pinecone-client in requirements
63-
shell: bash
64-
run: |
65-
if ! grep -q "pinecone-client" ./requirements/local.txt; then
66-
echo "pinecone-client not found in requirements/local.txt" >&2
67-
exit 1
68-
fi
69-
7038
- name: Cache Python dependencies
7139
uses: actions/cache@v3
7240
with:

models/hybrid_search_retreiver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def prompt_with_template(
121121
) -> str:
122122
"""Prompt with template."""
123123
retval = self.chat.invoke(prompt.format(concept=concept))
124-
return retval.content if retval else "no response"
124+
return str(retval.content) if retval else "no response"
125125

126126
def load(self, filepath: str):
127127
"""Pdf loader."""
@@ -188,4 +188,4 @@ def rag(self, human_message: Union[str, HumanMessage]):
188188
# 2.) get a response from the chat model
189189
response = self.cached_chat_request(system_message=system_message, human_message=human_message)
190190

191-
return response.content
191+
return str(response.content)

models/tests/mock_data/test_load.pdf

87.3 KB
Binary file not shown.

models/tests/test_examples.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
from models.prompt_templates import NetecPromptTemplates
1616

1717

18-
HUMAN_MESSAGE = 'return the word "SUCCESS" in upper case.'
18+
HUMAN_MESSAGE = "this is a test"
19+
SYSTEM_PROMPT = """you are a helpful assistant. If you are prompted,
20+
'this is a test', then return the word 'SUCCESS' in upper case. Return only
21+
this single word, in upper case. Do not embellish. do not further prompt
22+
the user for any reason."""
1923

2024

2125
class TestExamples:
@@ -24,12 +28,13 @@ class TestExamples:
2428
@patch("argparse.ArgumentParser.parse_args")
2529
def test_prompt(self, mock_parse_args):
2630
"""Test prompt example."""
31+
2732
mock_args = MagicMock()
28-
mock_args.system_prompt = "you are a helpful assistant"
33+
mock_args.system_prompt = SYSTEM_PROMPT
2934
mock_args.human_prompt = HUMAN_MESSAGE
3035
mock_parse_args.return_value = mock_args
3136

32-
system_message = SystemMessage(content="you are a helpful assistant")
37+
system_message = SystemMessage(content=SYSTEM_PROMPT)
3338
human_message = HumanMessage(content=HUMAN_MESSAGE)
3439
result = prompt_hrs.cached_chat_request(system_message=system_message, human_message=human_message)
3540
assert result.content == "SUCCESS"
@@ -43,7 +48,8 @@ def test_rag(self, mock_parse_args):
4348

4449
human_message = HumanMessage(content=mock_args.human_message)
4550
result = rag_hsr.rag(human_message=human_message)
46-
assert result == "SUCCESS"
51+
assert isinstance(result, str)
52+
assert len(result) > 0
4753

4854
@patch("argparse.ArgumentParser.parse_args")
4955
def test_training_services(self, mock_parse_args):
@@ -56,7 +62,8 @@ def test_training_services(self, mock_parse_args):
5662
prompt = templates.training_services
5763

5864
result = uofpenn_certification_program.prompt_with_template(prompt=prompt, concept=mock_args.human_message)
59-
assert "SUCCESS" in result
65+
assert isinstance(result, str)
66+
assert len(result) > 0
6067

6168
@patch("argparse.ArgumentParser.parse_args")
6269
def test_oracle_training_services(self, mock_parse_args):
@@ -69,4 +76,5 @@ def test_oracle_training_services(self, mock_parse_args):
6976
prompt = templates.oracle_training_services
7077

7178
result = uofpenn_online_hsr.prompt_with_template(prompt=prompt, concept=mock_args.human_message)
72-
assert "SUCCESS" in result
79+
assert isinstance(result, str)
80+
assert len(result) > 0

models/tests/test_pinecone.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,16 @@ def test_06_create(self):
8686

8787
def test_07_load_pdf(self):
8888
"""Test that we can load a PDF document to the index."""
89-
if not os.path.exists("./data/test_07_load.pdf"):
90-
pytest.skip("File './data/test_07_load.pdf' does not exist")
89+
HERE = os.path.dirname(os.path.abspath(__file__))
90+
test_file = os.path.join(HERE, "mock_data", "test_load.pdf")
91+
92+
if not os.path.exists(test_file):
93+
pytest.skip(f"File {test_file} does not exist")
9194

9295
pinecone = PineconeIndex()
9396
# pylint: disable=broad-except
9497
try:
95-
pinecone.pdf_loader(filepath="./data/test_07_load.pdf")
98+
pinecone.pdf_loader(filepath=test_file)
9699
except Exception as e:
97100
assert False, f"Pinecone.load_pdf() failed with exception: {e}"
98101
pinecone.delete()

0 commit comments

Comments
 (0)