You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromfastapiimportFastAPIfrompydanticimportBaseModelfromsemantic_splitimportSimilarSentenceSplitter, SentenceTransformersSimilarity, SpacySentenceSplitterapp=FastAPI()
classTextRequest(BaseModel):
text: strmax_tokens: int=8192# Default value for max_tokens@app.post("/split")asyncdefsplit_text(request: TextRequest):
# Initialize the splitter with the specified max_tokensmodel=SentenceTransformersSimilarity()
sentence_splitter=SpacySentenceSplitter()
splitter=SimilarSentenceSplitter(model, sentence_splitter, max_tokens=request.max_tokens) # Pass max_tokens here# Perform the semantic splitres=splitter.split(request.text)
# Return the result as JSONreturn {"result": res}
# Run the serverif__name__=="__main__":
importuvicornuvicorn.run(app, host="192.168.1.68", port=8887)
I am running it as above, but I need way to limit the token number, is there any way?
The text was updated successfully, but these errors were encountered:
fromfastapiimportFastAPIfrompydanticimportBaseModelfromsemantic_splitimportSimilarSentenceSplitter, SentenceTransformersSimilarity, SpacySentenceSplitterapp=FastAPI()
classTextRequest(BaseModel):
text: strmax_sentences: int=20# Default value for max_sentences@app.post("/split")asyncdefsplit_text(request: TextRequest):
# Initialize the splitter with the specified max_tokensmodel=SentenceTransformersSimilarity()
sentence_splitter=SpacySentenceSplitter()
splitter=SimilarSentenceSplitter(model, sentence_splitter)
# Perform the semantic splitres=splitter.split(request.text, group_max_sentences=request.max_sentences) # Pass group_max_sentences here# Return the result as JSONreturn {"result": res}
# Run the serverif__name__=="__main__":
importuvicornuvicorn.run(app, host="192.168.1.68", port=8887)
I am running it as above, but I need way to limit the token number, is there any way?
The text was updated successfully, but these errors were encountered: