Class peagen.core._llm.GenericLLM
peagen.core._llm.GenericLLM
GenericLLM()
A generic class that provides a unified interface to all supported LLM providers. It dynamically loads and instantiates the appropriate LLM class based on the specified provider.
Supported providers include: - OpenAI/O1 (o1, openai) - Anthropic (anthropic) - Cohere (cohere) - DeepInfra (deepinfra) - LlamaCpp (llamacpp) - Groq (groq) - Gemini/Google (gemini, google) - Mistral (mistral) - DeepSeek (deepseek) - AI21Studio (ai21studio) - Hyperbolic (hyperbolic) - Cerebras (cerebras)
Source code in peagen/core/_llm.py
54 55 |
|
get_llm
get_llm(
provider,
api_key=None,
model_name=None,
timeout=1200.0,
**kwargs,
)
Creates and returns an instance of the specified LLM provider.
PARAMETER | DESCRIPTION |
---|---|
provider
|
The name of the LLM provider (e.g., 'openai', 'anthropic', 'deepinfra')
TYPE:
|
api_key
|
API key for the provider
TYPE:
|
model_name
|
The specific model to use
TYPE:
|
timeout
|
Request timeout in seconds
TYPE:
|
**kwargs
|
Additional arguments to pass to the LLM constructor
DEFAULT:
|
RETURNS | DESCRIPTION |
---|---|
LLMBase
|
An instance of the requested LLM |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If the provider is not supported or no API key is found |
ImportError
|
If the provider module cannot be imported |
Source code in peagen/core/_llm.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
|