Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,6 +8,11 @@ from fastapi.templating import Jinja2Templates
|
|
| 8 |
from pydantic import BaseModel, Field
|
| 9 |
from rag_util import Create_RAG_Prompt, ProcessDocuments
|
| 10 |
import time
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
class DataModel(BaseModel):
|
| 13 |
data: str
|
|
@@ -44,7 +49,7 @@ async def generate(data: DataModel):
|
|
| 44 |
# input_text = bleach.clean(data.data)
|
| 45 |
history = chat_history[data.chatID] = [] if data.chatID not in chat_history else chat_history[data.chatID]
|
| 46 |
|
| 47 |
-
llm_response = generate_response(prompt=input_text, history=history)
|
| 48 |
|
| 49 |
if data.chatID not in chat_history:
|
| 50 |
chat_history[data.chatID] = []
|
|
@@ -57,7 +62,7 @@ async def generate(data: DataModel):
|
|
| 57 |
# input_text = bleach.clean(data.data)
|
| 58 |
prompt, context = Create_RAG_Prompt(input_text, chatID=data.chatID, history=chat_history[data.chatID] if chat_history[data.chatID] else [])
|
| 59 |
|
| 60 |
-
llm_response = generate_response(prompt=prompt, context=context)
|
| 61 |
|
| 62 |
if data.chatID not in chat_history:
|
| 63 |
chat_history[data.chatID] = []
|
|
|
|
| 8 |
from pydantic import BaseModel, Field
|
| 9 |
from rag_util import Create_RAG_Prompt, ProcessDocuments
|
| 10 |
import time
|
| 11 |
+
import torch
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
torch.set_num_threads(os.cpu_count())
|
| 15 |
+
|
| 16 |
|
| 17 |
class DataModel(BaseModel):
|
| 18 |
data: str
|
|
|
|
| 49 |
# input_text = bleach.clean(data.data)
|
| 50 |
history = chat_history[data.chatID] = [] if data.chatID not in chat_history else chat_history[data.chatID]
|
| 51 |
|
| 52 |
+
llm_response = await generate_response(prompt=input_text, history=history)
|
| 53 |
|
| 54 |
if data.chatID not in chat_history:
|
| 55 |
chat_history[data.chatID] = []
|
|
|
|
| 62 |
# input_text = bleach.clean(data.data)
|
| 63 |
prompt, context = Create_RAG_Prompt(input_text, chatID=data.chatID, history=chat_history[data.chatID] if chat_history[data.chatID] else [])
|
| 64 |
|
| 65 |
+
llm_response = await generate_response(prompt=prompt, context=context)
|
| 66 |
|
| 67 |
if data.chatID not in chat_history:
|
| 68 |
chat_history[data.chatID] = []
|