Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: 不能自定义model #14633

Open
qyj19920704 opened this issue Jul 8, 2024 · 1 comment
Open

[Bug]: 不能自定义model #14633

qyj19920704 opened this issue Jul 8, 2024 · 1 comment
Labels
bug Something isn't working triage Issue needs to be triaged/prioritized

Comments

@qyj19920704
Copy link

Bug Description

OpenAI(
api_key=openai_api_key,
api_base=openai_api_base,
model=model_name,
temperature=0.1,
request_timeout=20,
max_retries=5
)

model不能自定义,限制住了,这是不应该的呀

Version

0.10.20

Steps to Reproduce

知识图谱的功能

Relevant Logs/Tracbacks

只允许gpt相关的模型,不能自定义
@qyj19920704 qyj19920704 added bug Something isn't working triage Issue needs to be triaged/prioritized labels Jul 8, 2024
Copy link

dosubot bot commented Jul 8, 2024

@qyj19920704 你好!我是Dosu,我是一个能帮助你解决错误、回答问题并成为贡献者的机器人。在等待人类维护者的过程中,我可以为你提供帮助。

你无法自定义OpenAI API中的模型,并且模型参数仅限于GPT相关模型,这是因为实现是专��为OpenAI的GPT模型设计的。代码中包含了默认模型设置(DEFAULT_OPENAI_MODEL = "gpt-3.5-turbo")和各种方法,这些方法专门处理GPT模型,例如使用tiktoken包进行标记化以及特定处理OpenAI的API响应。

然而,LlamaIndex提供了一个名为OpenAILike的类,它是OpenAI模型的一个薄包装,使其与提供OpenAI兼容API的第三方工具兼容。这个类允许一些自定义,同时仍然需要设置OPENAI_BASE_APIOPENAI_API_KEY环境变量或构造函数参数:

class OpenAILike(OpenAI):
    """OpenAILike LLM.

    OpenAILike是OpenAI模型的一个薄包装,使其与提供OpenAI兼容API的第三方工具兼容。

    目前,llama_index阻止使用自定义模型,因为他们需要能够从模型名称推断一些元数据。

    注意:你仍然需要设置OPENAI_BASE_API和OPENAI_API_KEY环境变量或api_key和api_base构造函数参数。
    在这种情况下,OPENAI_API_KEY/api_key通常可以设置为任何值,但这取决于你使用的工具。

    示例:
        `pip install llama-index-llms-openai-like`

        ```python
        from llama_index.llms.openai_like import OpenAILike

        llm = OpenAILike(model="my model", api_base="https://hostname.com/v1", api_key="fake")

        response = llm.complete("Hello World!")
        print(str(response))
        ```
    """

这个类允许在使用自定义模型时保持与OpenAI API结构的兼容性[1][2].

To continue talking to Dosu, mention @dosu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage Issue needs to be triaged/prioritized
1 participant