fix(main.py): init custom llm provider earlier

This commit is contained in:
Krrish Dholakia 2024-01-11 18:30:10 +05:30
parent bfa26dd5b3
commit 1378190dbf

View file

@ -232,6 +232,9 @@ async def acompletion(
"model_list": model_list, "model_list": model_list,
"acompletion": True, # assuming this is a required parameter "acompletion": True, # assuming this is a required parameter
} }
_, custom_llm_provider, _, _ = get_llm_provider(
model=model, api_base=completion_kwargs.get("base_url", None)
)
try: try:
# Use a partial function to pass your keyword arguments # Use a partial function to pass your keyword arguments
func = partial(completion, **completion_kwargs, **kwargs) func = partial(completion, **completion_kwargs, **kwargs)
@ -240,10 +243,6 @@ async def acompletion(
ctx = contextvars.copy_context() ctx = contextvars.copy_context()
func_with_context = partial(ctx.run, func) func_with_context = partial(ctx.run, func)
_, custom_llm_provider, _, _ = get_llm_provider(
model=model, api_base=completion_kwargs.get("base_url", None)
)
if ( if (
custom_llm_provider == "openai" custom_llm_provider == "openai"
or custom_llm_provider == "azure" or custom_llm_provider == "azure"