`Groq` Chat large language models API. To use, you should have the environment variable ``GROQ_API_KEY`` set with your API key. Any parameters that are valid to be passed to the groq.create call can be passed in, even if not explicitly saved on this class. Example: ..
| 80 | |
| 81 | |
| 82 | class ChatGroq(BaseChatModel): |
| 83 | """`Groq` Chat large language models API. |
| 84 | |
| 85 | To use, you should have the |
| 86 | environment variable ``GROQ_API_KEY`` set with your API key. |
| 87 | |
| 88 | Any parameters that are valid to be passed to the groq.create call |
| 89 | can be passed in, even if not explicitly saved on this class. |
| 90 | |
| 91 | Example: |
| 92 | .. code-block:: python |
| 93 | |
| 94 | from langchain_groq import ChatGroq |
| 95 | |
| 96 | model = ChatGroq(model_name="mixtral-8x7b-32768") |
| 97 | |
| 98 | Setup: |
| 99 | Install ``langchain-groq`` and set environment variable |
| 100 | ``GROQ_API_KEY``. |
| 101 | |
| 102 | .. code-block:: bash |
| 103 | |
| 104 | pip install -U langchain-groq |
| 105 | export GROQ_API_KEY="your-api-key" |
| 106 | |
| 107 | Key init args — completion params: |
| 108 | model: str |
| 109 | Name of Groq model to use. E.g. "mixtral-8x7b-32768". |
| 110 | temperature: float |
| 111 | Sampling temperature. Ranges from 0.0 to 1.0. |
| 112 | max_tokens: Optional[int] |
| 113 | Max number of tokens to generate. |
| 114 | model_kwargs: Dict[str, Any] |
| 115 | Holds any model parameters valid for create call not |
| 116 | explicitly specified. |
| 117 | |
| 118 | Key init args — client params: |
| 119 | timeout: Union[float, Tuple[float, float], Any, None] |
| 120 | Timeout for requests. |
| 121 | max_retries: int |
| 122 | Max number of retries. |
| 123 | api_key: Optional[str] |
| 124 | Groq API key. If not passed in will be read from env var GROQ_API_KEY. |
| 125 | base_url: Optional[str] |
| 126 | Base URL path for API requests, leave blank if not using a proxy |
| 127 | or service emulator. |
| 128 | custom_get_token_ids: Optional[Callable[[str], List[int]]] |
| 129 | Optional encoder to use for counting tokens. |
| 130 | |
| 131 | See full list of supported init args and their descriptions in the params |
| 132 | section. |
| 133 | |
| 134 | Instantiate: |
| 135 | .. code-block:: python |
| 136 | |
| 137 | from langchain_groq import ChatGroq |
| 138 | |
| 139 | model = ChatGroq( |
no outgoing calls