Skip to content

Groq

Groq #

Bases: OpenAILike

Groq LLM.

例子

pip install llama-index-llms-groq

from llama_index.llms.groq import Groq

# 使用所需的模型和API密钥设置Groq类
llm = Groq(model="mixtral-8x7b-32768", api_key="your_api_key")

# 使用查询调用complete方法
response = llm.complete("Explain the importance of low latency LLMs")

print(response)
Source code in llama_index/llms/groq/base.py
 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
class Groq(OpenAILike):
    """Groq LLM.

    例子:
        `pip install llama-index-llms-groq`

        ```python
        from llama_index.llms.groq import Groq

        # 使用所需的模型和API密钥设置Groq类
        llm = Groq(model="mixtral-8x7b-32768", api_key="your_api_key")

        # 使用查询调用complete方法
        response = llm.complete("Explain the importance of low latency LLMs")

        print(response)
        ```"""

    def __init__(
        self,
        model: str,
        api_key: Optional[str] = None,
        api_base: str = "https://api.groq.com/openai/v1",
        is_chat_model: bool = True,
        is_function_calling_model: bool = True,
        **kwargs: Any,
    ) -> None:
        api_key = api_key or os.environ.get("GROQ_API_KEY", None)
        super().__init__(
            model=model,
            api_key=api_key,
            api_base=api_base,
            is_chat_model=is_chat_model,
            is_function_calling_model=is_function_calling_model,
            **kwargs,
        )

    @classmethod
    def class_name(cls) -> str:
        """获取类名。"""
        return "Groq"

class_name classmethod #

class_name() -> str

获取类名。

Source code in llama_index/llms/groq/base.py
44
45
46
47
@classmethod
def class_name(cls) -> str:
    """获取类名。"""
    return "Groq"