nonhuman commited on
Commit
4a9daf8
1 Parent(s): c406e35

Upload 6 files

Browse files
Files changed (6) hide show
  1. .env +22 -0
  2. .gitignore +21 -0
  3. .pre-commit-config.yaml +8 -0
  4. Dockerfile +30 -0
  5. requirements.txt +19 -0
  6. template.yaml +94 -0
.env ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # OpenAI
2
+ OPENAI_API_KEY = ""
3
+ OPENAI_API_BASE = ""
4
+ # Cohere
5
+ COHERE_API_KEY = ""
6
+ # OpenRouter
7
+ OR_SITE_URL = ""
8
+ OR_APP_NAME = "LiteLLM Example app"
9
+ OR_API_KEY = ""
10
+ # Azure API base URL
11
+ AZURE_API_BASE = ""
12
+ # Azure API version
13
+ AZURE_API_VERSION = ""
14
+ # Azure API key
15
+ AZURE_API_KEY = ""
16
+ # Replicate
17
+ REPLICATE_API_KEY = ""
18
+ REPLICATE_API_TOKEN = ""
19
+ # Anthropic
20
+ ANTHROPIC_API_KEY = ""
21
+ # Infisical
22
+ INFISICAL_TOKEN = ""
.gitignore ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .venv
2
+ .env
3
+ litellm_uuid.txt
4
+ __pycache__/
5
+ *.pyc
6
+ bun.lockb
7
+ **/.DS_Store
8
+ .aider*
9
+ litellm_results.jsonl
10
+ secrets.toml
11
+ .gitignore
12
+ litellm/proxy/litellm_secrets.toml
13
+ litellm/proxy/api_log.json
14
+ .idea/
15
+ router_config.yaml
16
+ litellm_server/config.yaml
17
+ litellm/proxy/_secret_config.yaml
18
+ .aws-sam/
19
+ litellm/tests/aiologs.log
20
+ litellm/tests/exception_data.txt
21
+ litellm/tests/config_*.yaml
.pre-commit-config.yaml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ repos:
2
+ - repo: https://github.com/pycqa/flake8
3
+ rev: 3.8.4 # The version of flake8 to use
4
+ hooks:
5
+ - id: flake8
6
+ exclude: ^litellm/tests/|^litellm/proxy/|^litellm/integrations/
7
+ additional_dependencies: [flake8-print]
8
+ files: litellm/.*\.py
Dockerfile ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Base image
2
+ ARG LITELLM_BASE_IMAGE=python:3.9-slim
3
+
4
+ # allow users to specify, else use python 3.9-slim
5
+ FROM $LITELLM_BASE_IMAGE
6
+
7
+ # Set the working directory to /app
8
+ WORKDIR /app
9
+
10
+ # Install build dependencies
11
+ RUN apt-get update && \
12
+ apt-get install -y gcc python3-dev && \
13
+ rm -rf /var/lib/apt/lists/*
14
+
15
+ # Copy the current directory contents into the container at /app
16
+ COPY . /app
17
+
18
+ # Install any needed packages specified in requirements.txt
19
+ RUN pip wheel --no-cache-dir --wheel-dir=wheels -r requirements.txt
20
+ RUN pip install --no-cache-dir --find-links=wheels -r requirements.txt
21
+
22
+ EXPOSE 4000/tcp
23
+
24
+ # Start the litellm proxy, using the `litellm` cli command https://docs.litellm.ai/docs/simple_proxy
25
+
26
+ # Start the litellm proxy with default options
27
+ CMD ["--port", "4000"]
28
+
29
+ # Allow users to override the CMD when running the container, allows users to pass litellm args
30
+ ENTRYPOINT ["litellm"]
requirements.txt ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # LITELLM PROXY DEPENDENCIES #
2
+ litellm
3
+ openai
4
+ fastapi
5
+ tomli
6
+ appdirs
7
+ tomli_w
8
+ backoff
9
+ pyyaml
10
+ uvicorn
11
+ boto3
12
+ redis
13
+ pyyaml
14
+ rq
15
+ prisma
16
+ celery
17
+ psutil
18
+ mangum
19
+ google-generativeai
template.yaml ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ AWSTemplateFormatVersion: '2010-09-09'
2
+ Transform: AWS::Serverless-2016-10-31
3
+ Description: >
4
+ llmlite-service
5
+
6
+ SAM Template for llmlite-service
7
+
8
+ # More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
9
+ Globals:
10
+ Function:
11
+ Timeout: 600
12
+ MemorySize: 128
13
+ Environment:
14
+ Variables:
15
+ WORKER_CONFIG: !Ref WorkerConfigParameter
16
+
17
+ Parameters:
18
+ AliasParameter:
19
+ Type: String
20
+ Default: live
21
+ WorkerConfigParameter:
22
+ Type: String
23
+ Description: Sample environment variable
24
+ Default: '{"model": null, "alias": null, "api_base": null, "api_version": "2023-07-01-preview", "debug": false, "temperature": null, "max_tokens": null, "request_timeout": 600, "max_budget": null, "telemetry": true, "drop_params": false, "add_function_to_prompt": false, "headers": null, "save": false, "config": null, "use_queue": false}'
25
+
26
+ Resources:
27
+ MyUrlFunctionPermissions:
28
+ Type: AWS::Lambda::Permission
29
+ Properties:
30
+ FunctionName: !Ref URL
31
+ Action: lambda:InvokeFunctionUrl
32
+ Principal: "*"
33
+ FunctionUrlAuthType: NONE
34
+
35
+ Function:
36
+ Type: AWS::Serverless::Function
37
+ Properties:
38
+ FunctionName: !Sub "${AWS::StackName}-function"
39
+ CodeUri: "./litellm"
40
+ Handler: proxy/lambda.handler
41
+ Runtime: python3.11
42
+ AutoPublishAlias: !Ref AliasParameter
43
+ Architectures:
44
+ - x86_64
45
+ DeploymentPreference:
46
+ Type: AllAtOnce
47
+ Alarms:
48
+ - !Ref NewVersionErrorMetricGreaterThanZeroAlarm
49
+
50
+ NewVersionErrorMetricGreaterThanZeroAlarm:
51
+ Type: "AWS::CloudWatch::Alarm"
52
+ Properties:
53
+ AlarmDescription: Lambda Function Error > 0
54
+ ComparisonOperator: GreaterThanThreshold
55
+ Dimensions:
56
+ - Name: Resource
57
+ Value: !Sub "${Function}:live"
58
+ - Name: FunctionName
59
+ Value: !Ref Function
60
+ - Name: ExecutedVersion
61
+ Value: !GetAtt Function.Version.Version
62
+ EvaluationPeriods: 1
63
+ Unit: Count
64
+ MetricName: Errors
65
+ Namespace: AWS/Lambda
66
+ Period: 60
67
+ Statistic: Sum
68
+ Threshold: 0
69
+
70
+ URL:
71
+ Type: AWS::Lambda::Url
72
+ DependsOn: FunctionAliaslive
73
+ Properties:
74
+ AuthType: NONE
75
+ Qualifier: live
76
+ TargetFunctionArn: !GetAtt Function.Arn
77
+
78
+ Outputs:
79
+ FunctionARN:
80
+ Description: "Lambda Function ARN"
81
+ Value: !GetAtt Function.Arn
82
+
83
+ FunctionUrl:
84
+ Description: "Lambda Function URL Endpoint"
85
+ Value:
86
+ Fn::GetAtt: URL.FunctionUrl
87
+
88
+ FunctionVersion:
89
+ Description: "Lambda Function Version"
90
+ Value: !GetAtt Function.Version.Version
91
+
92
+ FunctionNewAlarmARN:
93
+ Description: "Lambda Function New Alarm ARN"
94
+ Value: !GetAtt NewVersionErrorMetricGreaterThanZeroAlarm.Arn