mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
add supprot for lepton (#1866)
### What problem does this PR solve? add supprot for lepton #1853 ### Type of change - [x] New Feature (non-breaking change which adds functionality) Co-authored-by: Zhedong Cen <cenzhedong2@126.com>
This commit is contained in:
@ -83,7 +83,8 @@ ChatModel = {
|
||||
"NVIDIA": NvidiaChat,
|
||||
"LM-Studio": LmStudioChat,
|
||||
"OpenAI-API-Compatible": OpenAI_APIChat,
|
||||
"cohere": CoHereChat
|
||||
"cohere": CoHereChat,
|
||||
"LeptonAI": LeptonAIChat
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -71,7 +71,7 @@ class Base(ABC):
|
||||
total_tokens
|
||||
+ num_tokens_from_string(resp.choices[0].delta.content)
|
||||
)
|
||||
if not hasattr(resp, "usage")
|
||||
if not hasattr(resp, "usage") or not resp.usage
|
||||
else resp.usage["total_tokens"]
|
||||
)
|
||||
if resp.choices[0].finish_reason == "length":
|
||||
@ -981,3 +981,10 @@ class CoHereChat(Base):
|
||||
yield ans + "\n**ERROR**: " + str(e)
|
||||
|
||||
yield total_tokens
|
||||
|
||||
|
||||
class LeptonAIChat(Base):
|
||||
def __init__(self, key, model_name, base_url=None):
|
||||
if not base_url:
|
||||
base_url = os.path.join("https://"+model_name+".lepton.run","api","v1")
|
||||
super().__init__(key, model_name, base_url)
|
||||
Reference in New Issue
Block a user