Spaces:
Configuration error
Configuration error
File size: 2,250 Bytes
447ebeb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
import requests
def get_initial_config():
proxy_base_url = input("Enter your proxy base URL (e.g., http://localhost:4000): ")
master_key = input("Enter your LITELLM_MASTER_KEY ")
return proxy_base_url, master_key
def get_user_input():
model_name = input(
"Enter model_name (this is the 'model' passed in /chat/completions requests):"
)
model = input("litellm_params: Enter model eg. 'azure/<your-deployment-name>': ")
tpm = int(input("litellm_params: Enter tpm (tokens per minute): "))
rpm = int(input("litellm_params: Enter rpm (requests per minute): "))
api_key = input("litellm_params: Enter api_key: ")
api_base = input("litellm_params: Enter api_base: ")
api_version = input("litellm_params: Enter api_version: ")
timeout = int(input("litellm_params: Enter timeout (0 for default): "))
stream_timeout = int(
input("litellm_params: Enter stream_timeout (0 for default): ")
)
max_retries = int(input("litellm_params: Enter max_retries (0 for default): "))
return {
"model_name": model_name,
"litellm_params": {
"model": model,
"tpm": tpm,
"rpm": rpm,
"api_key": api_key,
"api_base": api_base,
"api_version": api_version,
"timeout": timeout,
"stream_timeout": stream_timeout,
"max_retries": max_retries,
},
}
def make_request(proxy_base_url, master_key, data):
url = f"{proxy_base_url}/model/new"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {master_key}",
}
response = requests.post(url, headers=headers, json=data)
print(f"Status Code: {response.status_code}")
print(f"Response from adding model: {response.text}")
def main():
proxy_base_url, master_key = get_initial_config()
while True:
print("Adding new Model to your proxy server...")
data = get_user_input()
make_request(proxy_base_url, master_key, data)
add_another = input("Do you want to add another model? (yes/no): ").lower()
if add_another != "yes":
break
print("Script finished.")
if __name__ == "__main__":
main()
|