22# pylint: disable=too-few-public-methods
33"""Sales Support Model (SSM) for the LangChain project."""
44
5- import os
65from typing import ClassVar , List
76
87import pinecone
9- from dotenv import find_dotenv , load_dotenv
108from langchain .chat_models import ChatOpenAI
119from langchain .embeddings import OpenAIEmbeddings
1210from langchain .llms .openai import OpenAI
1614from langchain .vectorstores .pinecone import Pinecone
1715from pydantic import BaseModel , ConfigDict , Field # ValidationError
1816
17+ from models .const import Credentials
1918
20- # pylint: disable=duplicate-code
21- dotenv_path = find_dotenv ()
22- if os .path .exists (dotenv_path ):
23- load_dotenv (dotenv_path = dotenv_path , verbose = True )
24- OPENAI_API_KEY = os .environ ["OPENAI_API_KEY" ]
25- OPENAI_API_ORGANIZATION = os .environ ["OPENAI_API_ORGANIZATION" ]
26- PINECONE_API_KEY = os .environ ["PINECONE_API_KEY" ]
27- PINECONE_ENVIRONMENT = os .environ ["PINECONE_ENVIRONMENT" ]
28- PINECONE_INDEX_NAME = os .environ ["PINECONE_INDEX_NAME" ]
29- else :
30- raise FileNotFoundError ("No .env file found in root directory of repository" )
3119
3220DEFAULT_MODEL_NAME = "text-davinci-003"
33- pinecone .init (api_key = PINECONE_API_KEY , environment = PINECONE_ENVIRONMENT )
34-
35-
36- class NetecPromptTemplates :
37- """Netec Prompt Templates."""
38-
39- sales_role : str = """You are a helpful sales assistant at Netec who sells
40- specialized training and exam preparation services to existing customers.
41- You provide concise explanations of the services that Netec offers in 100
42- words or less."""
43-
44- @classmethod
45- def get_properties (cls ):
46- """return a list of properties of this class."""
47- return [attr for attr in dir (cls ) if isinstance (getattr (cls , attr ), property )]
48-
49- @property
50- def training_services (self ) -> PromptTemplate :
51- """Get prompt."""
52- template = (
53- self .sales_role
54- + """
55- Explain the training services that Netec offers about {concept}
56- """
57- )
58- return PromptTemplate (input_variables = ["concept" ], template = template )
59-
60- @property
61- def oracle_training_services (self ) -> PromptTemplate :
62- """Get prompt."""
63- template = (
64- self .sales_role
65- + """
66- Note that Netec is the exclusive provide of Oracle training services
67- for the 6 levels of Oracle Certification credentials: Oracle Certified Junior Associate (OCJA),
68- Oracle Certified Associate (OCA), Oracle Certified Professional (OCP),
69- Oracle Certified Master (OCM), Oracle Certified Expert (OCE) and
70- Oracle Certified Specialist (OCS).
71- Summarize their programs for {concept}
72- """
73- )
74- return PromptTemplate (input_variables = ["concept" ], template = template )
21+ pinecone .init (api_key = Credentials .PINECONE_API_KEY , environment = Credentials .PINECONE_ENVIRONMENT )
7522
7623
7724class SalesSupportModel (BaseModel ):
@@ -82,8 +29,8 @@ class SalesSupportModel(BaseModel):
8229 # prompting wrapper
8330 chat : ChatOpenAI = Field (
8431 default_factory = lambda : ChatOpenAI (
85- api_key = OPENAI_API_KEY ,
86- organization = OPENAI_API_ORGANIZATION ,
32+ api_key = Credentials . OPENAI_API_KEY ,
33+ organization = Credentials . OPENAI_API_ORGANIZATION ,
8734 max_retries = 3 ,
8835 model = "gpt-3.5-turbo" ,
8936 temperature = 0.3 ,
0 commit comments