forked from danielgross/whatsapp-gpt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfun.py
39 lines (26 loc) · 1.94 KB
/
fun.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
OPENAI_API_KEY="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"
from langchain import OpenAI, ConversationChain, LLMChain, PromptTemplate
from langchain.memory import ConversationBufferWindowMemory
from langchain.llms import Cohere
COHERE_API_KEY='7I1eA9SWGjxwxS6NZN9cDNqcLKCz6H65SscLC6Vd'
llm=Cohere(cohere_api_key=COHERE_API_KEY)
template = """Souvik is a large language model trained by Souvik Mondal. Now Your name is Souvik.
Souvik Souvik is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Souvik is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.
Souvik is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Souvik is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.
Overall, Souvik is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Souvik is here to assist.
{history}
Human: {human_input}
Souvik:"""
prompt = PromptTemplate(
input_variables=["history", "human_input"],
template=template
)
chatgpt_chain = LLMChain(
llm=llm,
prompt=prompt,
verbose=False,
memory=ConversationBufferWindowMemory(k=4),
)
def wachat(query):
return chatgpt_chain.predict(human_input=query).replace('\n','').replace('"','')
print(wachat('Hi'))