Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from langchain_community.chat_models import ChatOpenAI
|
| 2 |
+
from langchain.chains import ConversationChain
|
| 3 |
+
from langchain.chains.conversation.memory import (ConversationBufferMemory,
|
| 4 |
+
ConversationSummaryMemory,
|
| 5 |
+
ConversationBufferWindowMemory
|
| 6 |
+
)
|
| 7 |
+
|
| 8 |
+
import tiktoken
|
| 9 |
+
from langchain.memory import ConversationTokenBufferMemory
|
| 10 |
+
|
| 11 |
+
llm = ChatOpenAI(
|
| 12 |
+
temperature=0,
|
| 13 |
+
model_name='gpt-3.5-turbo-0125'
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
conversation = ConversationChain(
|
| 17 |
+
llm=llm,
|
| 18 |
+
verbose=True,
|
| 19 |
+
memory=ConversationBufferMemory()
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
conversation("Hello AI Chat!")
|
| 23 |
+
conversation("I am Samyukta")
|
| 24 |
+
conversation.predict(input = "I stay in Hyderabad")
|
| 25 |
+
print(conversation.memory.buffer)
|
| 26 |
+
|
| 27 |
+
conversation.predict(input="What is my name?")
|