Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrates LiteLLM for Unified Access to Multiple LLM Models #5925

Open
wants to merge 10 commits into
base: preview
Choose a base branch
from
45 changes: 19 additions & 26 deletions apiserver/plane/app/views/external/base.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
# Python imports
import requests
# Python import
import os

# Third party imports
from openai import OpenAI
from rest_framework.response import Response
# Third party import
import litellm
import requests

from litellm import completion
from rest_framework import status
from rest_framework.response import Response

# Django imports
# Module import
from plane.app.permissions import ROLE, allow_permission
from plane.app.serializers import (ProjectLiteSerializer,
WorkspaceLiteSerializer)
from plane.db.models import Project, Workspace
from plane.license.utils.instance_value import get_configuration_value

# Module imports
from ..base import BaseAPIView
from plane.app.permissions import allow_permission, ROLE
from plane.db.models import Workspace, Project
from plane.app.serializers import (
ProjectLiteSerializer,
WorkspaceLiteSerializer,
)
from plane.license.utils.instance_value import get_configuration_value


class GPTIntegrationEndpoint(BaseAPIView):
Expand All @@ -32,7 +31,7 @@ def post(self, request, slug, project_id):
},
{
"key": "GPT_ENGINE",
"default": os.environ.get("GPT_ENGINE", "gpt-3.5-turbo"),
"default": os.environ.get("GPT_ENGINE", "gpt-4o-mini"),
},
plane-bot marked this conversation as resolved.
Show resolved Hide resolved
]
)
Expand All @@ -56,11 +55,8 @@ def post(self, request, slug, project_id):

final_text = task + "\n" + prompt

client = OpenAI(
api_key=OPENAI_API_KEY,
)

response = client.chat.completions.create(
litellm.api_key = OPENAI_API_KEY
response = completion(
model=GPT_ENGINE,
messages=[{"role": "user", "content": final_text}],
)
plane-bot marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -95,7 +91,7 @@ def post(self, request, slug):
},
{
"key": "GPT_ENGINE",
"default": os.environ.get("GPT_ENGINE", "gpt-3.5-turbo"),
"default": os.environ.get("GPT_ENGINE", "gpt-4o-mini"),
},
]
)
Expand All @@ -119,11 +115,8 @@ def post(self, request, slug):

final_text = task + "\n" + prompt

client = OpenAI(
api_key=OPENAI_API_KEY,
)

response = client.chat.completions.create(
litellm.api_key = OPENAI_API_KEY
response = completion(
model=GPT_ENGINE,
messages=[{"role": "user", "content": final_text}],
)
Expand Down
2 changes: 1 addition & 1 deletion apiserver/requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ uvicorn==0.29.0
# sockets
channels==4.1.0
# ai
openai==1.25.0
litellm==1.51.0
# slack
slack-sdk==3.27.1
# apm
Expand Down
Loading