Skip to content

Llava completion

LlavaCompletionPack #

Bases: BaseLlamaPack

Llava完成包。

Source code in llama_index/packs/llava_completion/base.py
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
class LlavaCompletionPack(BaseLlamaPack):
    """Llava完成包。"""

    def __init__(
        self,
        image_url: str,
        **kwargs: Any,
    ) -> None:
        """初始化参数。"""
        import os

        if not os.environ.get("REPLICATE_API_TOKEN", None):
            raise ValueError("Replicate API Token is missing or blank.")

        self.image_url = image_url

        self.llm = Replicate(
            model="yorickvp/llava-13b:2facb4a474a0462c15041b78b1ad70952ea46b5ec6ad29583c0b29dbd4249591",
            image=self.image_url,
        )

    def get_modules(self) -> Dict[str, Any]:
        """获取模块。"""
        return {
            "llm": self.llm,
            "image_url": self.image_url,
        }

    def run(self, *args: Any, **kwargs: Any) -> Any:
        """运行流水线。"""
        return self.llm.complete(*args, **kwargs)

get_modules #

get_modules() -> Dict[str, Any]

获取模块。

Source code in llama_index/packs/llava_completion/base.py
31
32
33
34
35
36
def get_modules(self) -> Dict[str, Any]:
    """获取模块。"""
    return {
        "llm": self.llm,
        "image_url": self.image_url,
    }

run #

run(*args: Any, **kwargs: Any) -> Any

运行流水线。

Source code in llama_index/packs/llava_completion/base.py
38
39
40
def run(self, *args: Any, **kwargs: Any) -> Any:
    """运行流水线。"""
    return self.llm.complete(*args, **kwargs)