Test Upload of chatbot

#1
by SkyNetAIdev - opened
Files changed (1) hide show
  1. MS_Chat_bot_test.py +41 -0
MS_Chat_bot_test.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #Look at integrating with the following:
2
+ # Chatbots
3
+ #Agents
4
+ # Interacting with APIs
5
+ # Code Understanding
6
+
7
+ #import depencdencies
8
+ from langchain.llms import OpenAI
9
+ from langchain import LLMChain, PromptTemplate
10
+ #from langchain.prompts.prompt import PromptTemplate
11
+
12
+ from langchain.chains.conversation.memory import ConversationBufferMemory
13
+ import os
14
+
15
+
16
+ openai_api_key = "Your_API_Key_Here"
17
+ template = f"""
18
+ 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
19
+ 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.
20
+ 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.
21
+ You should not be judemental.
22
+ Context: {{chat_history}}
23
+ Human: {{human_input}}
24
+ Chatbot:"""
25
+
26
+ prompt = PromptTemplate(
27
+ input_variables=["chat_history", "human_input"],
28
+ template = template
29
+ ,
30
+ )
31
+
32
+ #prompt = PromptTemplate.from_template(template)
33
+ #prompt.format(chat_histoy ="chat_histoy")
34
+
35
+ #prompt = PromptTemplate(input_variables=['chat_history', 'human_input'], template=template)
36
+
37
+ memory = ConversationBufferMemory(memory_key='chat_history')
38
+
39
+ llm_chain = LLMChain(llm=OpenAI(openai_api_key=openai_api_key), prompt=prompt, memory=memory)
40
+
41
+ llm_chain.predict(human_input='Hello, how are you?')