Spaces:
Runtime error
Runtime error
| #Look at integrating with the following: | |
| # Chatbots | |
| #Agents | |
| # Interacting with APIs | |
| # Code Understanding | |
| #import depencdencies | |
| from langchain.llms import OpenAI | |
| from langchain import LLMChain | |
| from langchain.prompts.prompt import PromptTemplate | |
| from langchain.chains.conversation.memory import ConversationBufferMemory | |
| import os | |
| openai_api_key = os.environ.get('OPENAI_API_KEY') | |
| template = ''' | |
| 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. | |
| {chat_histoy} | |
| 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, memory=memory) | |
| llm_chain.predict(human_input='Hello, how are you?') |