Spaces:
Sleeping
Sleeping
Neurolingua
commited on
Update other_function.py
Browse files- other_function.py +7 -7
other_function.py
CHANGED
@@ -31,17 +31,17 @@ def generate_response(query,chat_history):
|
|
31 |
response += chunk.choices[0].delta.content
|
32 |
return response.replace("###", '').replace('\nUser:','')
|
33 |
class ConversationBufferMemory:
|
34 |
-
def __init__(self,
|
35 |
-
self.
|
36 |
-
self.
|
37 |
|
38 |
def add_to_memory(self, interaction):
|
39 |
-
self.
|
|
|
|
|
40 |
|
41 |
def get_memory(self):
|
42 |
-
return
|
43 |
-
|
44 |
-
|
45 |
def predict_pest(filepath):
|
46 |
CLIENT = InferenceHTTPClient(
|
47 |
api_url="https://detect.roboflow.com",
|
|
|
31 |
response += chunk.choices[0].delta.content
|
32 |
return response.replace("###", '').replace('\nUser:','')
|
33 |
class ConversationBufferMemory:
|
34 |
+
def __init__(self, max_size=6):
|
35 |
+
self.memory = []
|
36 |
+
self.max_size = max_size
|
37 |
|
38 |
def add_to_memory(self, interaction):
|
39 |
+
self.memory.append(interaction)
|
40 |
+
if len(self.memory) > self.max_size:
|
41 |
+
self.memory.pop(0) # Remove the oldest interaction
|
42 |
|
43 |
def get_memory(self):
|
44 |
+
return self.memory
|
|
|
|
|
45 |
def predict_pest(filepath):
|
46 |
CLIENT = InferenceHTTPClient(
|
47 |
api_url="https://detect.roboflow.com",
|