mirror of
https://github.com/open-compass/opencompass.git
synced 2025-05-30 16:03:24 +08:00
Support LightllmApi input_format (#888)
This commit is contained in:
parent
08133e060a
commit
b6e21ece38
@ -14,6 +14,7 @@ models = [
|
|||||||
abbr='LightllmAPI',
|
abbr='LightllmAPI',
|
||||||
type=LightllmAPI,
|
type=LightllmAPI,
|
||||||
url='http://localhost:8080/generate',
|
url='http://localhost:8080/generate',
|
||||||
|
input_format='<input_text_to_replace>',
|
||||||
max_seq_len=2048,
|
max_seq_len=2048,
|
||||||
batch_size=32,
|
batch_size=32,
|
||||||
generation_kwargs=dict(
|
generation_kwargs=dict(
|
||||||
|
@ -20,6 +20,7 @@ class LightllmAPI(BaseAPIModel):
|
|||||||
self,
|
self,
|
||||||
path: str = 'LightllmAPI',
|
path: str = 'LightllmAPI',
|
||||||
url: str = 'http://localhost:8080/generate',
|
url: str = 'http://localhost:8080/generate',
|
||||||
|
input_format: str = '<input_text_to_replace>',
|
||||||
max_seq_len: int = 2048,
|
max_seq_len: int = 2048,
|
||||||
meta_template: Optional[Dict] = None,
|
meta_template: Optional[Dict] = None,
|
||||||
retry: int = 2,
|
retry: int = 2,
|
||||||
@ -33,6 +34,7 @@ class LightllmAPI(BaseAPIModel):
|
|||||||
generation_kwargs=generation_kwargs)
|
generation_kwargs=generation_kwargs)
|
||||||
self.logger = get_logger()
|
self.logger = get_logger()
|
||||||
self.url = url
|
self.url = url
|
||||||
|
self.input_format = input_format
|
||||||
self.generation_kwargs = generation_kwargs
|
self.generation_kwargs = generation_kwargs
|
||||||
self.max_out_len = self.generation_kwargs.get('max_new_tokens', 1024)
|
self.max_out_len = self.generation_kwargs.get('max_new_tokens', 1024)
|
||||||
|
|
||||||
@ -62,6 +64,8 @@ class LightllmAPI(BaseAPIModel):
|
|||||||
self.wait()
|
self.wait()
|
||||||
header = {'content-type': 'application/json'}
|
header = {'content-type': 'application/json'}
|
||||||
try:
|
try:
|
||||||
|
input = self.input_format.replace('<input_text_to_replace>',
|
||||||
|
input)
|
||||||
data = dict(inputs=input, parameters=self.generation_kwargs)
|
data = dict(inputs=input, parameters=self.generation_kwargs)
|
||||||
raw_response = requests.post(self.url,
|
raw_response = requests.post(self.url,
|
||||||
headers=header,
|
headers=header,
|
||||||
@ -114,6 +118,8 @@ class LightllmAPI(BaseAPIModel):
|
|||||||
self.wait()
|
self.wait()
|
||||||
header = {'content-type': 'application/json'}
|
header = {'content-type': 'application/json'}
|
||||||
try:
|
try:
|
||||||
|
input = self.input_format.replace('<input_text_to_replace>',
|
||||||
|
input)
|
||||||
data = dict(inputs=input, parameters=self.generation_kwargs)
|
data = dict(inputs=input, parameters=self.generation_kwargs)
|
||||||
raw_response = requests.post(self.url,
|
raw_response = requests.post(self.url,
|
||||||
headers=header,
|
headers=header,
|
||||||
|
Loading…
Reference in New Issue
Block a user