BerriAI / litellm

Python SDK, Proxy Server (LLM Gateway) to call 100+ LLM APIs in OpenAI format - [Bedrock, Azure, OpenAI, VertexAI, Cohere, Anthropic, Sagemaker, HuggingFace, Replicate, Groq]
https://docs.litellm.ai/docs/
Other
13.03k stars 1.53k forks source link

[Bug]: support custom models #1164

Closed spacex-3 closed 10 months ago

spacex-3 commented 10 months ago

What happened?

repo:iuiaoin/wechat-gptbot I used the above project to integrate with the WeChat bot, but I need to used the 'gpt-4-mobile' or 'gpt-4-s model' from PandoraNext. Currently, it seems that the inability to use it is due to the lack of support for such custom models by LITellm.

Relevant log output

[INFO][2023-12-17 17:22:19][wechat.py:90] - message received: Message(room_id=None, sender_id=***, sender_name=***, receiver_id=***, receiver_name=pika, content=pika 你好, type=1, is_group=False, create_time=2023-12-17 17:22:19, is_at=False)
[INFO][2023-12-17 17:22:19][chatgpt.py:26] - [LiteLLMChatGPTBot] Query=你好
[ERROR][2023-12-17 17:22:19][litellm.py:63] - [LiteLLMChatGPTBot] Exception: No valid completion model args passed in - {'model': 'gpt-4-mobile', 'messages': [{'role': 'system', 'content': '你是一个人工智能助手,主要作用是协助回答人们各种各样的问题。'}, {'role': 'user', 'content': '你好'}], 'functions': [], 'function_call': '', 'temperature': 0.9, 'top_p': 1.0, 'n': 1, 'stream': False, 'stop': None, 'max_tokens': inf, 'presence_penalty': 0.0, 'frequency_penalty': 0.0, 'logit_bias': {}, 'user': '', 'deployment_id': None, 'return_async': False, 'api_key': None, 'force_timeout': 60, 'azure': False, 'logger_fn': None, 'verbose': False, 'hugging_face': False, 'replicate': False, 'model_response': {'choices': [{'finish_reason': 'stop', 'index': 0, 'message': {'role': 'assistant'}}]}, 'optional_params': {'temperature': 0.9}}
Traceback (most recent call last):
  File "C:\Users\kayson\dalle-3-wechat-gptbot-update litellm\bot\litellm.py", line 35, in reply_text
    response = completion(
  File "C:\Users\kayson\AppData\Local\Programs\Python\Python310\lib\site-packages\litellm\utils.py", line 131, in wrapper
    raise e
  File "C:\Users\kayson\AppData\Local\Programs\Python\Python310\lib\site-packages\litellm\utils.py", line 120, in wrapper
    result = original_function(*args, **kwargs)
  File "C:\Users\kayson\AppData\Local\Programs\Python\Python310\lib\site-packages\litellm\timeout.py", line 44, in wrapper
    result = future.result(timeout=local_timeout_duration)
  File "C:\Users\kayson\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\_base.py", line 458, in result
    return self.__get_result()
  File "C:\Users\kayson\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\_base.py", line 403, in __get_result
    raise self._exception
  File "C:\Users\kayson\AppData\Local\Programs\Python\Python310\lib\site-packages\litellm\timeout.py", line 35, in async_func
    return func(*args, **kwargs)
  File "C:\Users\kayson\AppData\Local\Programs\Python\Python310\lib\site-packages\litellm\main.py", line 332, in completion
    raise exception_type(model=model, original_exception=e)
  File "C:\Users\kayson\AppData\Local\Programs\Python\Python310\lib\site-packages\litellm\utils.py", line 511, in exception_type
    raise original_exception
  File "C:\Users\kayson\AppData\Local\Programs\Python\Python310\lib\site-packages\litellm\utils.py", line 502, in exception_type
    raise original_exception # base case - return the original exception
  File "C:\Users\kayson\AppData\Local\Programs\Python\Python310\lib\site-packages\litellm\main.py", line 326, in completion
    raise ValueError(f"No valid completion model args passed in - {args}")
ValueError: No valid completion model args passed in - {'model': 'gpt-4-mobile', 'messages': [{'role': 'system', 'content': '你是一个人工智能助手,主要作用是协助回答人们各种各样的问题。'}, {'role': 'user', 'content': '你好'}], 'functions': [], 'function_call': '', 'temperature': 0.9, 'top_p': 1.0, 'n': 1, 'stream': False, 'stop': None, 'max_tokens': inf, 'presence_penalty': 0.0, 'frequency_penalty': 0.0, 'logit_bias': {}, 'user': '', 'deployment_id': None, 'return_async': False, 'api_key': None, 'force_timeout': 60, 'azure': False, 'logger_fn': None, 'verbose': False, 'hugging_face': False, 'replicate': False, 'model_response': {'choices': [{'finish_reason': 'stop', 'index': 0, 'message': {'role': 'assistant'}}]}, 'optional_params': {'temperature': 0.9}}
[INFO][2023-12-17 17:22:19][chatgpt.py:33] - [LiteLLMChatGPTBot] Response=Please ask me again
[INFO][2023-12-17 17:22:20][wechat.py:83] - message sent successfully

Twitter / LinkedIn details

No response

ishaan-jaff commented 10 months ago

assuming your models are OpenAI compatible, this is possible. You need to add openai/ as a prefix to the model name

set model = openai/gpt-4-mobile

ishaan-jaff commented 10 months ago

@spacex-3 does this fix your problem ?

spacex-3 commented 10 months ago

@spacex-3 does this fix your problem ? My models are OpenAI compatible, such as gpt-4-abc But it's ok I transfer the model name to the Openai campatible one.

Thanks!