MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / __init__

Method __init__

utils/src/llms.py:70–96  ·  view source on GitHub ↗

Initialize the LLM. Args: model (str): The model name. api_base (str): The base URL for the API. use_openai (bool): Whether to use OpenAI. use_batch (bool): Whether to use OpenAI's Batch API, which is single thread only.

(
        self,
        model: str = "gpt-4o-2024-08-06",
        api_base: str = None,
        use_openai: bool = True,
        use_batch: bool = False,
    )

Source from the content-addressed store, hash-verified

68 """
69
70 def __init__(
71 self,
72 model: str = "gpt-4o-2024-08-06",
73 api_base: str = None,
74 use_openai: bool = True,
75 use_batch: bool = False,
76 ) -> None:
77 """
78 Initialize the LLM.
79
80 Args:
81 model (str): The model name.
82 api_base (str): The base URL for the API.
83 use_openai (bool): Whether to use OpenAI.
84 use_batch (bool): Whether to use OpenAI's Batch API, which is single thread only.
85 """
86 if use_openai and "OPENAI_API_KEY" in os.environ:
87 self.client = OpenAI(base_url=api_base)
88 if use_batch and "OPENAI_API_KEY" in os.environ:
89 assert use_openai, "use_batch must be used with use_openai"
90 self.oai_batch = Auto(loglevel=0)
91 if "OPENAI_API_KEY" not in os.environ:
92 print("Warning: no API key found")
93 self.model = model
94 self.api_base = api_base
95 self._use_openai = use_openai
96 self._use_batch = use_batch
97
98 @tenacity
99 def __call__(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected