小编Meh*_*ssa的帖子

AzureOpenAI 和 LangChain 奇怪,多个答案

我正在使用AzureOpenAI来测试LangChain使用宪法的自我批评。

\n

这一切都有效,除了我得到了多个答案,最奇怪的部分是,它生成随机的、不需要的问题,并回答它们。

\n

这是我的 Python 代码(我用 替换了敏感信息[XXX-XXX]):

\n
import os\nfrom langchain.llms import AzureOpenAI\nfrom langchain.prompts import PromptTemplate\nfrom langchain.chains.llm import LLMChain\n\nfrom langchain.chains.constitutional_ai.base import ConstitutionalChain\nfrom langchain.chains.constitutional_ai.models import ConstitutionalPrinciple\n\nos.environ["OPENAI_API_TYPE"] = "azure"\nos.environ["OPENAI_API_VERSION"] = "2023-03-15-preview"\nos.environ["OPENAI_API_BASE"] = "https://[XXX-XXX].openai.azure.com/"\nos.environ["OPENAI_API_KEY"] = "[XXX-XXX]"\n\nqa_prompt = PromptTemplate(\n    template="""You are a Microsoft specialist and know everything about the software it sells.  Your aim is to help operators and employees when using the software.\n\nQuestion: {question}\n\nAnswer:""",\n    input_variables=["question"],\n)\n\nllm = AzureOpenAI(\n    deployment_name="[XXX-XXX]",\n    model_name="[XXX-XXX]"\n)\n\n\nqa_chain = LLMChain(llm=llm, prompt=qa_prompt)\n\nethical_principle = ConstitutionalPrinciple(\n    name="Ethical Principle",\n    critique_request="The model should only …
Run Code Online (Sandbox Code Playgroud)

python azure openai-api azure-openai langchain

5
推荐指数
1
解决办法
2640
查看次数

标签 统计

azure ×1

azure-openai ×1

langchain ×1

openai-api ×1

python ×1