CoolFace
Apppublic

miniondenis/Doc_eater

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
model_builder.py41 linesDownload Raw Back to lib
1import os2from langchain_openai import ChatOpenAI3from dotenv import load_dotenv4 5load_dotenv()6VSEGPT_KEY = os.getenv("VSEGPT_KEY")7OPENAI_BASE = os.getenv("OPENAI_BASE")8 9 10class ModelBuilder:11    def createVseGptModel(model, temperature):12        return ChatOpenAI(13            temperature=temperature,14            model_name=model,15            api_key=VSEGPT_KEY,16            base_url=OPENAI_BASE,17        )18 19 20class ModelBuilderV2:21    def __init__(22        self, model_name: str, temperature=0, api_key=VSEGPT_KEY, base_url=OPENAI_BASE23    ):24        self.model_name = model_name25        self.temperature = temperature26        self.api_key = api_key27        self.base_url = base_url28 29    def __enter__(self):30        # Initialize resources31        return ChatOpenAI(32            temperature=self.temperature,33            model_name=self.model_name,34            api_key=VSEGPT_KEY,35            base_url=OPENAI_BASE,36        )37 38    def __exit__(self, exc_type, exc_value, traceback):39        # Cleanup resources if necessary40        pass41