Spaces:
Sleeping
Sleeping
no message
Browse files- main.py +3 -1
- requirements.txt +2 -1
main.py
CHANGED
@@ -5,6 +5,8 @@ from huggingface_hub import InferenceClient
|
|
5 |
import uvicorn
|
6 |
from typing import Generator
|
7 |
import json # Asegúrate de que esta línea esté al principio del archivo
|
|
|
|
|
8 |
|
9 |
app = FastAPI()
|
10 |
|
@@ -34,7 +36,7 @@ def format_prompt(current_prompt, history):
|
|
34 |
def generate_stream(item: Item) -> Generator[bytes, None, None]:
|
35 |
formatted_prompt = format_prompt(f"{item.system_prompt}, {item.prompt}", item.history)
|
36 |
# Estimate token count for the formatted_prompt
|
37 |
-
input_token_count = len(
|
38 |
|
39 |
# Ensure total token count doesn't exceed the maximum limit
|
40 |
max_tokens_allowed = 32768
|
|
|
5 |
import uvicorn
|
6 |
from typing import Generator
|
7 |
import json # Asegúrate de que esta línea esté al principio del archivo
|
8 |
+
import nltk
|
9 |
+
nltk.download('punkt')
|
10 |
|
11 |
app = FastAPI()
|
12 |
|
|
|
36 |
def generate_stream(item: Item) -> Generator[bytes, None, None]:
|
37 |
formatted_prompt = format_prompt(f"{item.system_prompt}, {item.prompt}", item.history)
|
38 |
# Estimate token count for the formatted_prompt
|
39 |
+
input_token_count = len(nltk.word_tokenize(formatted_prompt)) # NLTK tokenization
|
40 |
|
41 |
# Ensure total token count doesn't exceed the maximum limit
|
42 |
max_tokens_allowed = 32768
|
requirements.txt
CHANGED
@@ -2,4 +2,5 @@ fastapi
|
|
2 |
uvicorn
|
3 |
huggingface_hub
|
4 |
pydantic
|
5 |
-
torch==2.0.0
|
|
|
|
2 |
uvicorn
|
3 |
huggingface_hub
|
4 |
pydantic
|
5 |
+
torch==2.0.0
|
6 |
+
nltk
|