fix: simplify model version handling in proxy functions
Simplify the logic for handling model versions in `openai_chat_completions_proxy` and `openai_completions_proxy` by removing redundant conditions and initializing `local_model` earlier. This makes the code more readable and maintains the same functionality.
This commit is contained in:
parent
34d6abd28b
commit
3ccaf78e5d
1 changed files with 4 additions and 6 deletions
|
|
@ -1732,11 +1732,10 @@ async def openai_chat_completions_proxy(request: Request):
|
||||||
prompt_tok = chunk.usage.prompt_tokens or 0
|
prompt_tok = chunk.usage.prompt_tokens or 0
|
||||||
comp_tok = chunk.usage.completion_tokens or 0
|
comp_tok = chunk.usage.completion_tokens or 0
|
||||||
if prompt_tok != 0 or comp_tok != 0:
|
if prompt_tok != 0 or comp_tok != 0:
|
||||||
|
local_model = model
|
||||||
if not is_ext_openai_endpoint(endpoint):
|
if not is_ext_openai_endpoint(endpoint):
|
||||||
if not ":" in model:
|
if not ":" in model:
|
||||||
local_model = model if ":" in model else model + ":latest"
|
local_model = model if ":" in model else model + ":latest"
|
||||||
else:
|
|
||||||
local_model = model
|
|
||||||
await token_queue.put((endpoint, local_model, prompt_tok, comp_tok))
|
await token_queue.put((endpoint, local_model, prompt_tok, comp_tok))
|
||||||
yield b"data: [DONE]\n\n"
|
yield b"data: [DONE]\n\n"
|
||||||
else:
|
else:
|
||||||
|
|
@ -1850,11 +1849,10 @@ async def openai_completions_proxy(request: Request):
|
||||||
prompt_tok = chunk.usage.prompt_tokens or 0
|
prompt_tok = chunk.usage.prompt_tokens or 0
|
||||||
comp_tok = chunk.usage.completion_tokens or 0
|
comp_tok = chunk.usage.completion_tokens or 0
|
||||||
if prompt_tok != 0 or comp_tok != 0:
|
if prompt_tok != 0 or comp_tok != 0:
|
||||||
|
local_model = model
|
||||||
if not is_ext_openai_endpoint(endpoint):
|
if not is_ext_openai_endpoint(endpoint):
|
||||||
if not ":" in model:
|
if not ":" in model:
|
||||||
local_model = model if ":" in model else model + ":latest"
|
local_model = model if ":" in model else model + ":latest"
|
||||||
else:
|
|
||||||
local_model = model
|
|
||||||
await token_queue.put((endpoint, local_model, prompt_tok, comp_tok))
|
await token_queue.put((endpoint, local_model, prompt_tok, comp_tok))
|
||||||
# Final DONE event
|
# Final DONE event
|
||||||
yield b"data: [DONE]\n\n"
|
yield b"data: [DONE]\n\n"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue