|
| 1 | +import os |
| 2 | + |
| 3 | +from dotenv import load_dotenv |
1 | 4 | from gen_ai_hub.proxy.core.proxy_clients import set_proxy_version |
2 | 5 | from gen_ai_hub.proxy.langchain.init_models import ( |
3 | 6 | init_llm, init_embedding_model) |
|
10 | 13 | from langchain_community.document_loaders import DirectoryLoader |
11 | 14 | from langchain_community.vectorstores import FAISS |
12 | 15 |
|
| 16 | + |
| 17 | +# load env variables |
| 18 | +load_dotenv() |
| 19 | +AGENT_MODEL = os.environ.get('AGENT_MODEL', 'gpt-4') |
| 20 | +EMBEDDING_MODEL = os.environ.get('EMBEDDING_MODEL', 'text-embedding-ada-002') |
13 | 21 | # Use models deployed in SAP AI Core |
14 | 22 | set_proxy_version('gen-ai-hub') |
15 | 23 |
|
|
29 | 37 | ############################################################################### |
30 | 38 | # SAP-compliant embedding models |
31 | 39 | # https://github.tools.sap/AI-Playground-Projects/llm-commons#embedding-models |
32 | | -underlying_embeddings = init_embedding_model('text-embedding-ada-002') |
| 40 | +underlying_embeddings = init_embedding_model(EMBEDDING_MODEL) |
33 | 41 | # Initialize local cache for faster loading of subsequent executions |
34 | 42 | fs = LocalFileStore('./cache') |
35 | 43 | # Link the embedding and the local cache system, and define a namespace |
@@ -131,7 +139,7 @@ def get_retriever(document_path: str, |
131 | 139 |
|
132 | 140 | # Initialize the LLM model to use, among the ones provided by SAP |
133 | 141 | # The max token count needs to be increased so that responses are not cut off. |
134 | | -llm = init_llm(model_name='gpt-4', max_tokens=1024) |
| 142 | +llm = init_llm(model_name=AGENT_MODEL, max_tokens=4096) |
135 | 143 |
|
136 | 144 | # Chain |
137 | 145 | # https://python.langchain.com/docs/modules/chains |
|
0 commit comments