PermissionError while executing langchain with AzureOpenAI

7uzetpgm  于 2023-08-07  发布在  其他
关注(0)|答案(1)|浏览(117)

我正在使用AzureOpenAI和langchain,经常被PermissionError击中。这主要是由于代理,但有人可以请检查代码--

from langchain.llms import OpenAI, AzureOpenAI
from langchain.prompts import PromptTemplate
from langchain.chains import LLMChain

llm = AzureOpenAI(openai_api_type="", openai_api_base="", deployment_name="", model_name="", openai_api_key="", openai_api_version="")

template = """"
Translate the following text from {source_lang} to {dest_lang}: {source_text}
"""

prompt_name = PromptTemplate(input_variables=["source_lang", "dest_lang", "source_text"], template=template)
chain = LLMChain(llm=llm, prompt=prompt_name)

chain.predict(source_lang="English", dest_lang="Spanish", source_text="How are you?")

chain(inputs={"source_lang": "English", "dest_lang": "Spanish", "source_text": "How are you"})

字符串
我还尝试了额外的openai_proxy参数,但运气不佳。

to94eoyn

to94eoyn1#

x1c 0d1x的数据
你的代码运行顺利!下面是我的LLM配置。其他变量用.env设置

llm=AzureChatOpenAI(
    deployment_name=AZURE_OPENAI_CHATGPT_DEPLOYMENT,
    temperature=0.0,
)

字符串

相关问题