-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.py
32 lines (26 loc) · 888 Bytes
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Learning LangChain
# in 20234
# (c) Ricky Macharm, MScFE
# https://www.SisengAI.com
#
#
"""This module extracts information from your `.env` file.
"""
from pathlib import Path
from pydantic import BaseSettings
def return_full_path(filename: str = ".env") -> str:
"""Returns the correct path of the `.env` file using the current working directory."""
# Get the current working directory
cwd = Path.cwd()
# Join the current working directory with the filename
full_path = cwd / filename
return str(full_path)
class Settings(BaseSettings):
"""Uses pydantic to define settings for project."""
OPENAI_API_KEY: str
HUGGINGFACEHUB_API_TOKEN: str
class Config:
env_file = return_full_path(".env")
# Create instance of `Settings` class that will be imported
# in lesson notebooks and the other modules for application.
settings = Settings()