跳到内容

Novita

NovitaAI #

基础类: OpenAILike

NovitaAI LLM。

Novita AI & LlamaIndex 集成指南 轻松将 Novita AI 与 LlamaIndex 集成,构建智能数据驱动型应用。

LlamaIndex 专为优化索引和检索而设计,在需要精确快速数据访问的应用中表现出卓越的高效率。通过将 Novita AI 与 LlamaIndex 结合,您将获得诸多关键优势,例如卓越的数据检索准确性、无与伦比的可伸缩性以及高成本效益的性能。本指南将引导您了解如何基于 OpenAl APl 使用 LlamaIndex 与 Novita AI,提供更智能、可伸缩且高效的 AI 解决方案,从而推动创新并为开发人员带来卓越成果。

如何将 Novita AI API 与 LlamaIndex 集成 步骤1:访问 Novita AI 上的模型库,并选择您感兴趣的模型。images/Step1VisitModelLibraryonNovitaAIandselectamodelofinterest.png

导航至所选模型的演示页面,点击右侧的 Code 按钮。

images/Step2NavigatetothedemopageofthechosenmodelandclicktheCodebuttonontheright.png

复制模型名称并记录下来。

images/Step3Copythemodel’snameandmakeanoteofit.png

登录 Novita 平台。

images/Step4LogintotheNovitaplatform.png

登录后,前往平台的设置页面

images/Step5Afterloggingin,gototheplatform’ssettingspage.png

创建一个新的API 密钥,并复制用于服务认证。

images/Step6CreateanewAPIkeyandcopyitforserviceauthentication.png

运行以下命令安装 llama_index 和相关 Python 库

images/Step7Installllama_indexandrelatedPythonlibrariesbyrunning.png

编写 Python 代码,并在 NovitaAI 类中将模型名称和 API 密钥设置为参数。

images/Step8WritePythoncodeandsetthemodelnameandAPIkeyasparametersintheNovitaAIclass.png

运行代码获取输出。

images/Step9Runthecodetogettheoutput.png

更多示例请参考文档:llama_index/llama-index-integrations/llms/llama-index-llms-novita at main · run-llama/llama_index

源代码路径:llama-index-integrations/llms/llama-index-llms-novita/llama_index/llms/novita/base.py
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
48
49
50
51
52
53
54
55
56
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
class NovitaAI(OpenAILike):
    """
    NovitaAI LLM.

    Novita AI & LlamaIndex Integration Guide
    Effortlessly integrate Novita AI with LlamaIndex to build intelligent, data-powered applications.

    Designed for optimal indexing and retrieval, LlamaIndex excels in delivering high efficiency for applications requiring precise and fast data access. By combining [Novita AI](https://novita.ai/) with LlamaIndex, you will unlock key benefits such as superior data retrieval accuracy, unmatched scalability, and cost-effective performance.
    This guide will walk you through how to use LlamaIndex with Novita AI based on the OpenAl APl, offering smarter, scalable, and highly efficient AI solutions that drive innovation and deliver exceptional results for developers.

    How to Integrate Novita AI API with LlamaIndex
    Step 1: Visit [Model Library](https://novita.ai/llm-api) on Novita AI and select a model of interest.
      ![images/Step1VisitModelLibraryonNovitaAIandselectamodelofinterest.png](https://mintlify.s3.us-west-1.amazonaws.com/novitaai/images/Step1VisitModelLibraryonNovitaAIandselectamodelofinterest.png)

    Step 2: Navigate to the demo page of the chosen model and click the `Code` button on the right.
      ![images/Step2NavigatetothedemopageofthechosenmodelandclicktheCodebuttonontheright.png](https://mintlify.s3.us-west-1.amazonaws.com/novitaai/images/Step2NavigatetothedemopageofthechosenmodelandclicktheCodebuttonontheright.png)

    Step 3: Copy the model’s name and make a note of it.
      ![images/Step3Copythemodel’snameandmakeanoteofit.png](https://mintlify.s3.us-west-1.amazonaws.com/novitaai/images/Step3Copythemodel%E2%80%99snameandmakeanoteofit.png)

    Step 4: [Log in ](https://novita.ai/user/login)to the Novita platform.
      ![images/Step4LogintotheNovitaplatform.png](https://mintlify.s3.us-west-1.amazonaws.com/novitaai/images/Step4LogintotheNovitaplatform.png)

    Step 5: After logging in, go to the platform’s [settings page](https://novita.ai/settings).
      ![images/Step5Afterloggingin,gototheplatform’ssettingspage.png](https://mintlify.s3.us-west-1.amazonaws.com/novitaai/images/Step5Afterloggingin,gototheplatform%E2%80%99ssettingspage.png)

    Step 6: Create a new [API key](https://novita.ai/settings/key-management) and copy it for service authentication.
      ![images/Step6CreateanewAPIkeyandcopyitforserviceauthentication.png](https://mintlify.s3.us-west-1.amazonaws.com/novitaai/images/Step6CreateanewAPIkeyandcopyitforserviceauthentication.png)

    Step 7: Install `llama_index` and related Python libraries by running:
      ![images/Step7Installllama_indexandrelatedPythonlibrariesbyrunning.png](https://mintlify.s3.us-west-1.amazonaws.com/novitaai/images/Step7Installllama_indexandrelatedPythonlibrariesbyrunning.png)

    Step 8: Write Python code and set the model name and API key as parameters in the NovitaAI class.
      ![images/Step8WritePythoncodeandsetthemodelnameandAPIkeyasparametersintheNovitaAIclass.png](https://mintlify.s3.us-west-1.amazonaws.com/novitaai/images/Step8WritePythoncodeandsetthemodelnameandAPIkeyasparametersintheNovitaAIclass.png)

    Step 9: Run the code to get the output.
      ![images/Step9Runthecodetogettheoutput.png](https://mintlify.s3.us-west-1.amazonaws.com/novitaai/images/Step9Runthecodetogettheoutput.png)

    For more examples, refer to the documentation: [llama_index/llama-index-integrations/llms/llama-index-llms-novita at main · run-llama/llama_index](https://github.com/run-llama/llama_index/tree/main/llama-index-integrations/llms/llama-index-llms-novita).

    """

    def __init__(
        self,
        model: str = DEFAULT_MODEL,
        api_key: Optional[str] = None,
        temperature: float = 0.95,
        max_tokens: int = 1024,
        is_chat_model: bool = True,
        additional_kwargs: Optional[Dict[str, Any]] = None,
        **kwargs: Any,
    ) -> None:
        additional_kwargs = additional_kwargs or {}
        api_base = get_from_param_or_env(
            "api_base", DEFAULT_API_BASE, "NOVITA_API_BASE"
        )
        api_key = get_from_param_or_env("api_key", api_key, "NOVITA_API_KEY")

        super().__init__(
            api_base=api_base,
            api_key=api_key,
            model=model,
            temperature=temperature,
            max_tokens=max_tokens,
            is_chat_model=is_chat_model,
            is_function_calling_model=is_function_calling_model(model),
            additional_kwargs=additional_kwargs,
            **kwargs,
        )

    @classmethod
    def class_name(cls) -> str:
        """Get class name."""
        return "NovitaAI"

class_name classmethod #

class_name() -> str

获取类名。

源代码路径:llama-index-integrations/llms/llama-index-llms-novita/llama_index/llms/novita/base.py
92
93
94
95
@classmethod
def class_name(cls) -> str:
    """Get class name."""
    return "NovitaAI"