Spaces:
Sleeping
Sleeping
Commit
·
88c2636
1
Parent(s):
b54d01b
Update main.py
Browse files
main.py
CHANGED
@@ -41,9 +41,8 @@ llms = {
|
|
41 |
|
42 |
#Fast API
|
43 |
app = FastAPI()
|
44 |
-
llm = None
|
45 |
|
46 |
-
def clean_memory():
|
47 |
llm = None
|
48 |
gc.collect()
|
49 |
|
@@ -63,6 +62,5 @@ async def stream(item: dict):
|
|
63 |
|
64 |
prompt = f"{prefix}{user.replace('{prompt}', item['prompt'])}{suffix}"
|
65 |
result = llm(prompt, max_tokens=max_tokens)
|
66 |
-
thread = threading.Thread(target=clean_memory)
|
67 |
-
thread.start()
|
68 |
return result
|
|
|
41 |
|
42 |
#Fast API
|
43 |
app = FastAPI()
|
|
|
44 |
|
45 |
+
def clean_memory(llm):
|
46 |
llm = None
|
47 |
gc.collect()
|
48 |
|
|
|
62 |
|
63 |
prompt = f"{prefix}{user.replace('{prompt}', item['prompt'])}{suffix}"
|
64 |
result = llm(prompt, max_tokens=max_tokens)
|
65 |
+
thread = threading.Thread(target=clean_memory, args=(llm)).start()
|
|
|
66 |
return result
|