Spaces:
Runtime error
Runtime error
#Look at integrating with the following: | |
# Chatbots | |
#Agents | |
# Interacting with APIs | |
# Code Understanding | |
from langchain.llms import OpenAI | |
from langchain import LLMChain | |
from langchain.prompts.prompt import PromptTemplate | |
from api_key import openai_api_key | |
from langchain.chains.conversation.memory import ConversationBufferMemory | |
import os | |
openai_api_key = openai_api_key | |
template = f""" | |
You are chatbot that is helpful and provides the best possible answers to the user. Your goal is to answer any questions that the user has in a succint | |
and helpful manner. When responding to questions you should be polite and professional. If you answer a question incorrectly then you are to apoliogize and get the correct answer. | |
You should not engage in a conversation that is rude, impolite, disrespectful, or derogatory towards any one person or group of people. Your job is to be informative. | |
You should not be judemental. | |
Context: {{chat_history}} | |
Human: {{human_input}} | |
Chatbot:""" | |
prompt = PromptTemplate( | |
input_variables=["chat_history", "human_input"], | |
template = template | |
, | |
) | |
memory = ConversationBufferMemory(memory_key='chat_history') | |
llm_chain = LLMChain(llm=OpenAI(openai_api_key=openai_api_key), prompt=prompt, verbose=True, memory=memory) | |
response = llm_chain.predict(human_input='Hello, how are you?') | |
print(response) |