"...git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "7b2407f4d75aaff406caf67808676d205c58d389"
Unverified Commit 05ad2884 authored by lazymio's avatar lazymio
Browse files

Also /chat/completions

parent bf36547f
...@@ -28,13 +28,13 @@ async def chat_completion(request:Request,create:ChatCompletionCreate): ...@@ -28,13 +28,13 @@ async def chat_completion(request:Request,create:ChatCompletionCreate):
if create.stream: if create.stream:
async def inner(): async def inner():
chunk = ChatCompletionChunk(id=id,object='chat.completion.chunk',created=int(time())) chunk = ChatCompletionChunk(id=id,object='chat.completion.chunk',created=int(time()))
async for token in interface.inference(input_message,id): async for token in interface.inference(input_message,id,create.temperature,create.top_p,create.repetition_penalty):
chunk.set_token(token) chunk.set_token(token)
yield chunk yield chunk
return chat_stream_response(request,inner()) return chat_stream_response(request,inner())
else: else:
comp = ChatCompletionObject(id=id,object='chat.completion',created=int(time())) comp = ChatCompletionObject(id=id,object='chat.completion',created=int(time()))
comp.usage = Usage(completion_tokens=1, prompt_tokens=1, total_tokens=2) comp.usage = Usage(completion_tokens=1, prompt_tokens=1, total_tokens=2)
async for token in interface.inference(input_message,id): async for token in interface.inference(input_message,id,create.temperature,create.top_p,create.repetition_penalty):
comp.append_token(token) comp.append_token(token)
return comp return comp
...@@ -25,6 +25,9 @@ class ChatCompletionCreate(BaseModel): ...@@ -25,6 +25,9 @@ class ChatCompletionCreate(BaseModel):
messages: List[Message] messages: List[Message]
model : str model : str
stream : bool = False stream : bool = False
temperature: Optional[float]
top_p: Optional[float]
repetition_penalty: Optional[float]
def get_tokenizer_messages(self): def get_tokenizer_messages(self):
return [m.to_tokenizer_message() for m in self.messages] return [m.to_tokenizer_message() for m in self.messages]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment