-
-
Save zioproto/0f4b198a79a1ac6e44579a06768ed2bc to your computer and use it in GitHub Desktop.
Debugging LangChain chat model AzureChatOpenAI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import sys | |
from dotenv import load_dotenv | |
from dotenv import dotenv_values | |
from langchain.chat_models import AzureChatOpenAI | |
from langchain.agents import initialize_agent | |
from langchain.chains import LLMChain | |
from langchain.prompts import PromptTemplate | |
from langchain.chat_models import ChatOpenAI | |
from langchain.prompts.chat import ( | |
ChatPromptTemplate, | |
HumanMessagePromptTemplate, | |
) | |
load_dotenv() | |
config = dotenv_values(".env") | |
#human_message_prompt = HumanMessagePromptTemplate( | |
# prompt=PromptTemplate( | |
# template="What is a good name for a company that makes {product}?", | |
# input_variables=["product"], | |
# ) | |
# ) | |
#chat_prompt_template = ChatPromptTemplate.from_messages([human_message_prompt]) | |
#chat = AzureChatOpenAI( | |
# deployment_name="gpt-35-turbo", | |
# model_kwargs={ | |
# "api_key": config["OPENAI_API_KEY"], | |
# "api_base": config["OPENAI_API_BASE"], | |
# "api_type": config["OPENAI_API_TYPE"], | |
# "api_version": config["OPENAI_API_VERSION"], | |
# }, | |
#) | |
chat = AzureChatOpenAI( | |
deployment_name="gpt-35-turbo", | |
openai_api_version="2023-03-15-preview", | |
openai_api_key=config["OPENAI_API_KEY"], | |
openai_api_base=config["OPENAI_API_BASE"], | |
openai_api_type=config["OPENAI_API_TYPE"], | |
) | |
prompt=PromptTemplate( | |
template="What is a good name for a company that makes {product}?", | |
input_variables=["product"], | |
) | |
#chain = LLMChain(llm=chat, prompt=chat_prompt_template, verbose=True) | |
chain = LLMChain(llm=chat, prompt=prompt, verbose=True) | |
print(chain) | |
#print(chat) | |
print(chain.run("colorful socks")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment