Spaces:
Paused
Paused
Create backend/autocomplete.py
Browse files- backend/autocomplete.py +1 -12
backend/autocomplete.py
CHANGED
|
@@ -1,16 +1,5 @@
|
|
| 1 |
from model_router import route_autocomplete
|
| 2 |
-
from pathlib import Path
|
| 3 |
-
import asyncio
|
| 4 |
|
| 5 |
async def generate_autocomplete(req):
|
| 6 |
-
|
| 7 |
-
try:
|
| 8 |
-
file_content = Path(req.filepath).read_text()
|
| 9 |
-
except:
|
| 10 |
-
file_content = ""
|
| 11 |
-
prefix = req.prefix
|
| 12 |
-
suffix = req.suffix
|
| 13 |
-
# If we have file content, we can improve prefix/suffix with more lines
|
| 14 |
-
# For simplicity, pass directly to model
|
| 15 |
-
completion = await route_autocomplete(req.model, prefix, suffix, req.max_tokens)
|
| 16 |
return [{"text": completion}]
|
|
|
|
| 1 |
from model_router import route_autocomplete
|
|
|
|
|
|
|
| 2 |
|
| 3 |
async def generate_autocomplete(req):
|
| 4 |
+
completion = await route_autocomplete(req.model, req.prefix, req.suffix, req.max_tokens)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
return [{"text": completion}]
|