mirror of
https://github.com/ParisNeo/lollms.git
synced 2024-12-23 06:22:27 +00:00
enhanced
This commit is contained in:
parent
a8ae73d500
commit
ddcf439ffd
@ -49,6 +49,8 @@ def get_generation_status():
|
||||
# ----------------------------------- Generation -----------------------------------------
|
||||
class LollmsTokenizeRequest(BaseModel):
|
||||
prompt: str
|
||||
class LollmsDeTokenizeRequest(BaseModel):
|
||||
tokens: List[int]
|
||||
|
||||
@router.post("/lollms_tokenize")
|
||||
async def lollms_tokenize(request: LollmsTokenizeRequest):
|
||||
@ -63,6 +65,19 @@ async def lollms_tokenize(request: LollmsTokenizeRequest):
|
||||
except Exception as ex:
|
||||
return {"status":False,"error":str(ex)}
|
||||
|
||||
@router.post("/lollms_detokenize")
|
||||
async def lollms_detokenize(request: LollmsDeTokenizeRequest):
|
||||
try:
|
||||
text = elf_server.model.detokenize(request.tokens)
|
||||
named_tokens=[]
|
||||
for token in request.tokens:
|
||||
detoken = elf_server.model.detokenize([token])
|
||||
named_tokens.append([detoken,token])
|
||||
tokens = elf_server.model.tokenize(request.prompt)
|
||||
return {"status":True,"raw_tokens":tokens, "named_tokens":named_tokens, "text":text}
|
||||
except Exception as ex:
|
||||
return {"status":False,"error":str(ex)}
|
||||
|
||||
class LollmsGenerateRequest(BaseModel):
|
||||
prompt: str
|
||||
model_name: Optional[str] = None
|
||||
|
Loading…
Reference in New Issue
Block a user