Skip to content

Commit 8e7db29

Browse files
author
xusenlin
committed
Fix internlm2 template
1 parent 5b45f34 commit 8e7db29

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

api/adapter/template.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -721,11 +721,13 @@ def template(self) -> str:
721721
class InternLMTemplate(BaseTemplate):
722722

723723
name = "internlm"
724-
allow_models = ["internlm"]
725724
stop = {
726725
"strings": ["</s>", "<eoa>"],
727726
}
728727

728+
def match(self, name) -> bool:
729+
return name.startswith("internlm") and not name.startswith("internlm2")
730+
729731
@property
730732
def template(self) -> str:
731733
""" The output should look something like:
@@ -749,7 +751,6 @@ def template(self) -> str:
749751
class InternLM2Template(BaseTemplate):
750752

751753
name = "internlm2"
752-
allow_models = ["internlm2"]
753754
system_prompt = (
754755
"You are an AI assistant whose name is InternLM (书生·浦语).\n"
755756
"- InternLM (书生·浦语) is a conversational language model that is developed by Shanghai AI Laboratory (上海人工智能实验室). It is designed to be helpful, honest, and harmless.\n"
@@ -759,6 +760,9 @@ class InternLM2Template(BaseTemplate):
759760
"strings": ["</s>", "[UNUSED_TOKEN_145]"],
760761
}
761762

763+
def match(self, name) -> bool:
764+
return name.startswith("internlm2")
765+
762766
@property
763767
def template(self) -> str:
764768
return (

libs/langchain_llm/langchain_llm/adapters/template.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -721,11 +721,13 @@ def template(self) -> str:
721721
class InternLMTemplate(BaseTemplate):
722722

723723
name = "internlm"
724-
allow_models = ["internlm"]
725724
stop = {
726725
"strings": ["</s>", "<eoa>"],
727726
}
728727

728+
def match(self, name) -> bool:
729+
return name.startswith("internlm") and not name.startswith("internlm2")
730+
729731
@property
730732
def template(self) -> str:
731733
""" The output should look something like:
@@ -749,7 +751,6 @@ def template(self) -> str:
749751
class InternLM2Template(BaseTemplate):
750752

751753
name = "internlm2"
752-
allow_models = ["internlm2"]
753754
system_prompt = (
754755
"You are an AI assistant whose name is InternLM (书生·浦语).\n"
755756
"- InternLM (书生·浦语) is a conversational language model that is developed by Shanghai AI Laboratory (上海人工智能实验室). It is designed to be helpful, honest, and harmless.\n"
@@ -759,6 +760,9 @@ class InternLM2Template(BaseTemplate):
759760
"strings": ["</s>", "[UNUSED_TOKEN_145]"],
760761
}
761762

763+
def match(self, name) -> bool:
764+
return name.startswith("internlm2")
765+
762766
@property
763767
def template(self) -> str:
764768
return (

0 commit comments

Comments
 (0)