From 2f57dc890676f3b07907d412e36c84a58e149d26 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Tue, 17 Oct 2023 13:29:47 -0700 Subject: [PATCH] refactor(proxy_cli.py): code cleanup --- litellm/proxy/proxy_cli.py | 20 ++++----------- litellm/proxy/proxy_server.py | 46 ----------------------------------- pyproject.toml | 4 +-- 3 files changed, 7 insertions(+), 63 deletions(-) diff --git a/litellm/proxy/proxy_cli.py b/litellm/proxy/proxy_cli.py index 6c0afa6956..d63fe0adf7 100644 --- a/litellm/proxy/proxy_cli.py +++ b/litellm/proxy/proxy_cli.py @@ -90,7 +90,6 @@ def is_port_in_use(port): @click.option('--alias', default=None, help='The alias for the model - use this to give a litellm model name (e.g. "huggingface/codellama/CodeLlama-7b-Instruct-hf") a more user-friendly name ("codellama")') @click.option('--add_key', default=None, help='The model name to pass to litellm expects') @click.option('--headers', default=None, help='headers for the API call') -@click.option('--deploy', is_flag=True, type=bool, help='Get a deployed proxy endpoint - api.litellm.ai') @click.option('--save', is_flag=True, type=bool, help='Save the model-specific config') @click.option('--debug', default=False, is_flag=True, type=bool, help='To debug the input') @click.option('--temperature', default=None, type=float, help='Set temperature for the model') @@ -106,17 +105,17 @@ def is_port_in_use(port): @click.option('--test', flag_value=True, help='proxy chat completions url to make a test request to') @click.option('--local', is_flag=True, default=False, help='for local debugging') @click.option('--cost', is_flag=True, default=False, help='for viewing cost logs') -def run_server(host, port, api_base, model, alias, add_key, headers, deploy, save, debug, temperature, max_tokens, drop_params, create_proxy, add_function_to_prompt, config, file, max_budget, telemetry, logs, test, local, cost): +def run_server(host, port, api_base, model, alias, add_key, headers, save, debug, temperature, max_tokens, drop_params, create_proxy, add_function_to_prompt, config, file, max_budget, telemetry, logs, test, local, cost): global feature_telemetry args = locals() if local: - from proxy_server import app, initialize, deploy_proxy, print_cost_logs, usage_telemetry, add_keys_to_config + from proxy_server import app, initialize, print_cost_logs, usage_telemetry, add_keys_to_config debug = True else: try: - from .proxy_server import app, initialize, deploy_proxy, print_cost_logs, usage_telemetry, add_keys_to_config + from .proxy_server import app, initialize, print_cost_logs, usage_telemetry, add_keys_to_config except ImportError as e: - from proxy_server import app, initialize, deploy_proxy, print_cost_logs, usage_telemetry, add_keys_to_config + from proxy_server import app, initialize, print_cost_logs, usage_telemetry, add_keys_to_config feature_telemetry = usage_telemetry if create_proxy == True: repo_url = 'https://github.com/BerriAI/litellm' @@ -158,15 +157,6 @@ def run_server(host, port, api_base, model, alias, add_key, headers, deploy, sav print(f.read()) print("\033[1;32mDone successfully\033[0m") return - if deploy == True: - print(f"\033[32mLiteLLM: Deploying your proxy to api.litellm.ai\033[0m\n") - print(f"\033[32mLiteLLM: Deploying proxy for model: {model}\033[0m\n") - url = deploy_proxy(model, api_base, debug, temperature, max_tokens, telemetry, deploy) - print(f"\033[32mLiteLLM: Deploy Successfull\033[0m\n") - print(f"\033[32mLiteLLM: Your deployed url: {url}\033[0m\n") - - print(f"\033[32mLiteLLM: Test your URL using the following: \"litellm --test {url}\"\033[0m") - return if model and "ollama" in model: run_ollama_serve() if cost == True: @@ -213,7 +203,7 @@ def run_server(host, port, api_base, model, alias, add_key, headers, deploy, sav raise ImportError("Uvicorn needs to be imported. Run - `pip install uvicorn`") print(f"\033[32mLiteLLM: Test your local endpoint with: \"litellm --test\" [In a new terminal tab]\033[0m\n") print(f"\033[32mLiteLLM: View available endpoints for this server on: http://{host}:{port}\033[0m\n") - print(f"\033[32mLiteLLM: Deploy your proxy using the following: \"litellm --model claude-instant-1 --deploy\" Get an https://api.litellm.ai/chat/completions endpoint \033[0m\n") + print(f"\033[32mLiteLLM: Self-host your proxy using the following: https://docs.litellm.ai/docs/proxy_server#deploy-proxy \033[0m\n") if port == 8000 and is_port_in_use(port): port = random.randint(1024, 49152) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 6dbdc8f65c..ad1c433b87 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -282,52 +282,6 @@ def initialize(model, alias, api_base, debug, temperature, max_tokens, max_budge user_telemetry = telemetry usage_telemetry(feature="local_proxy_server") - -def deploy_proxy(model, api_base, debug, temperature, max_tokens, telemetry, deploy): - import requests - # Load .env file - - # Prepare data for posting - data = { - "model": model, - "api_base": api_base, - "temperature": temperature, - "max_tokens": max_tokens, - } - - # print(data) - - # Make post request to the url - url = "https://litellm-api.onrender.com/deploy" - # url = "http://0.0.0.0:4000/deploy" - - with open(".env", "w") as env_file: - for row in data: - env_file.write(f"{row.upper()}='{data[row]}'\n") - env_file.write("\n\n") - for key in os.environ: - value = os.environ[key] - env_file.write(f"{key}='{value}'\n") - # env_file.write(str(os.environ)) - - files = {"file": open(".env", "rb")} - # print(files) - - response = requests.post(url, data=data, files=files) - # print(response) - # Check the status of the request - if response.status_code != 200: - return f"Request to url: {url} failed with status: {response.status_code}" - - # Reading the response - response_data = response.json() - # print(response_data) - url = response_data["url"] - # # Do something with response_data - - return url - - def track_cost_callback( kwargs, # kwargs to completion completion_response, # response from completion diff --git a/pyproject.toml b/pyproject.toml index a54cb0bfb8..161f241f37 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "litellm" -version = "1.0.0" +version = "0.9.0" description = "Library to easily interface with LLM API providers" authors = ["BerriAI"] license = "MIT License" @@ -26,7 +26,7 @@ requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" [tool.commitizen] -version = "1.0.0" +version = "0.9.0" version_files = [ "pyproject.toml:^version" ]