Closed mickymics closed 3 weeks ago
Unable to repro. This works for me.
please make sure you're using the latest version of litellm.
Here's my sample config for easy repro.
model_list:
- model_name: my-custom-model
litellm_params:
model: my-custom-llm/my-custom-model
api_key: my-fake-key
litellm_settings:
custom_provider_map:
- {"provider": "my-custom-llm", "custom_handler": .example_config_yaml.custom_handler.my_custom_llm}
Hi I am using the k8s depployment:
apiVersion: apps/v1 kind: Deployment metadata: name: litellm-deployment namespace: litellm spec: replicas: 1 selector: matchLabels: app: litellm template: metadata: labels: app: litellm spec: containers:
name: custom-llm-script-volume configMap: name: custom-llm-script
The KServe LLM Model Inference service reponse structure is:
{"predictions":{"image":"
Can you please let me know where is my mistake?
this could be a cached image? (check version on the swagger)
try running the docker locally to see if it works as expected. on our end this seems to be working fine.
if you can share your server startup logs that might help as well
What happened?
I am trying to invoke custom API Server for image generation LLM. Model stabilityai/stable-diffusion-xl-base-1.0 has been deployed using kserve and expose an URL:
NAME URL READY PREV LATEST PREVROLLEDOUTREVISION LATESTREADYREVISION AGE text2image http://text2image.fm.aac5.amd.com True 100 text2image-predictor-00001 24d
I have defined custom_handler.py
cat custom_handler.py from typing import Optional, Union, Any import litellm import httpx from litellm import CustomLLM from litellm.types.utils import ImageResponse, ImageObject
class ImageGenerationCustomLLM(CustomLLM): async def aimage_generation( self, model: str, prompt: str, api_base: Optional[str], api_key: Optional[str], model_response: ImageResponse, optional_params: dict, logging_obj: Any, timeout: Optional[Union[float, httpx.Timeout]] = None, client: Optional[httpx.AsyncClient] = None, ) -> ImageResponse: try: payload = { "model": model, "prompt": prompt, "api_base": api_base, "api_key": api_key, "num_inference_steps": optional_params.get("num_inference_steps", "20"), "guidance_scale": optional_params.get("guidance_scale", "9.5"), "height": optional_params.get("height", "512"), "width": optional_params.get("width", "512") } response = await litellm.aimage_generation(**payload) return response except Exception as e: raise Exception(f"Error generating image: {str(e)}")
And this is my proxy_config:
apiVersion: v1 data: proxy_config.yaml: | model_list:
I am trying to invoke using curl:
curl -v -H "Content-Type: application/json" http://litellm-service.litellm.svc.cluster.local:4000/images/generations -d@./test.json
test.json contains:
{ "model": "my-custom-model", "prompt": "An astronaut riding a horse on the beach", "num_inference_steps": "20", "guidance_scale": "9.5", "height": "512", "width": "512" }
What is the right way to invoke my llm model deployed in kserve and I need to pass the following payload:
{ "model": "my-custom-model", "prompt": "An astronaut riding a horse on the beach", "num_inference_steps": "20", "guidance_scale": "9.5", "height": "512", "width": "512" }
Relevant log output
Twitter / LinkedIn details
No response