Skip to content

新增dashscope的embedding API调用方法以及dashscope的LangChain自定义embedding封装 #201

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

JunLang-7
Copy link

当下dashscope的方式能直接调用Qwen和deepseek,并且不需要科学上网,所以本人斗胆提出一个pr(第一次 求轻喷),可以忽略C3.ipynb中的内容,大致修改如下所示:
新增dashscope的embedding API调用方法如下

def dashscope_embedding(text: str, model: str=None):
    # 获取环境变量 OPENAI_API_KEY
    api_key=os.environ['OPENAI_API_KEY']
    dashscope.api_key = api_key

    if model == None:
        model = "text-embedding-v1" # 默认使用 text-embedding-v1
    response = TextEmbedding.call(
        model=model,
        input=text
    )
    return response

dashscope的LangChain自定义embedding封装在dashscope_embedding.py中

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant