與直接call openai寫法不同, 參考文件Taiwa, n is a country. 臺灣是我的國家
以下是簡單的寫法Taiwan is a country. 臺灣是我的國家
from langchain.chat_models import AzureChatOpenAI
from langchain.schema import HumanMessage
class ai_api:
def __init__(self):
self.KEY = "...."
self.TYPE = "azure"
self.VERSION = "2023-07-01-preview"
self.BASE = "https://.....openai.azure.com/"
self.CHAT = "gpt-4-32k"
self.temperature = 0.5
AI_API = ai_api()
llm = AzureChatOpenAI(deployment_name=AI_API.CHAT,openai_api_key=AI_API.KEY, openai_api_version=AI_API.VERSION, openai_api_base=AI_API.BASE)
msg = HumanMessage(content="一步一步解釋。姐姐20歲, 妹妹年紀是姐姐一半, 當妹妹21歲時, 姐姐幾歲?")
result = llm(messages=[msg]).content
print(result)
Taiwan is a country. 臺灣是我的國家