Skip to content

Commit 84be774

Browse files
committed
chore: add a Config class
1 parent 08d9144 commit 84be774

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
## [1.1.1](https://github.com/lpm0073/netec-llm/compare/v1.1.0...v1.1.1) (2023-12-01)
22

3-
43
### Bug Fixes
54

6-
* had to switch to bm25_encoder so that vector store is searchable ([bad6994](https://github.com/lpm0073/netec-llm/commit/bad699481d217dde81877d85124395529652dabe))
5+
- had to switch to bm25_encoder so that vector store is searchable ([bad6994](https://github.com/lpm0073/netec-llm/commit/bad699481d217dde81877d85124395529652dabe))
76

87
# [1.1.0](https://github.com/lpm0073/netec-llm/compare/v1.0.0...v1.1.0) (2023-12-01)
98

models/const.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,20 @@
1515
OPENAI_API_ORGANIZATION = os.environ["OPENAI_API_ORGANIZATION"]
1616
PINECONE_API_KEY = os.environ["PINECONE_API_KEY"]
1717
PINECONE_ENVIRONMENT = os.environ["PINECONE_ENVIRONMENT"]
18-
PINECONE_INDEX_NAME = os.environ["PINECONE_INDEX_NAME"]
18+
PINECONE_INDEX_NAME = os.environ.get("PINECONE_INDEX_NAME", "hsr")
19+
OPENAI_CHAT_MODEL_NAME = os.environ.get("OPENAI_CHAT_MODEL_NAME", "gpt-3.5-turbo")
20+
OPENAI_PROMPT_MODEL_NAME = os.environ.get("OPENAI_PROMPT_MODEL_NAME", "text-davinci-003")
1921
else:
2022
raise FileNotFoundError("No .env file found in root directory of repository")
2123

2224

25+
class Config:
26+
"""Configuration parameters."""
27+
28+
OPENAI_CHAT_MODEL_NAME = OPENAI_CHAT_MODEL_NAME
29+
OPENAI_PROMPT_MODEL_NAME = OPENAI_PROMPT_MODEL_NAME
30+
31+
2332
class Credentials:
2433
"""Credentials."""
2534

models/hybrid_search_retreiver.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,23 @@
4444
from pinecone_text.sparse import BM25Encoder
4545

4646
# this project
47-
from models.const import Credentials
47+
from models.const import Config, Credentials
4848

4949

5050
###############################################################################
5151
# initializations
5252
###############################################################################
53-
DEFAULT_MODEL_NAME = "text-davinci-003"
53+
DEFAULT_MODEL_NAME = Config.OPENAI_PROMPT_MODEL_NAME
5454
pinecone.init(api_key=Credentials.PINECONE_API_KEY, environment=Credentials.PINECONE_ENVIRONMENT)
5555
set_llm_cache(InMemoryCache())
5656

5757

5858
class TextSplitter:
5959
"""
60-
Custom text splitter that add metadata to the Document object
60+
Custom text splitter that adds metadata to the Document object
6161
which is required by PineconeHybridSearchRetriever.
6262
"""
6363

64-
# ...
65-
6664
def create_documents(self, texts):
6765
"""Create documents"""
6866
documents = []
@@ -74,15 +72,15 @@ def create_documents(self, texts):
7472

7573

7674
class HybridSearchRetriever:
77-
"""Sales Support Model (SSM)."""
75+
"""Hybrid Search Retriever (OpenAI + Pinecone)"""
7876

7977
# prompting wrapper
8078
chat = ChatOpenAI(
8179
api_key=Credentials.OPENAI_API_KEY,
8280
organization=Credentials.OPENAI_API_ORGANIZATION,
8381
cache=True,
8482
max_retries=3,
85-
model="gpt-3.5-turbo",
83+
model=Config.OPENAI_CHAT_MODEL_NAME,
8684
temperature=0.0,
8785
)
8886

@@ -201,9 +199,9 @@ def rag(self, prompt: str):
201199
document_texts = [doc.page_content for doc in documents]
202200
leader = textwrap.dedent(
203201
"""\
204-
You can assume that the following is true,
205-
and you should attempt to incorporate these facts
206-
in your response:
202+
\n\nYou can assume that the following is true.
203+
You should attempt to incorporate these facts
204+
into your response:\n\n
207205
"""
208206
)
209207

0 commit comments

Comments
 (0)