mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
refactor: remove uneccessary references to proxybaseurl in ui code - reduce potential for errors
This commit is contained in:
parent
a10844f358
commit
330b6ab437
16 changed files with 27 additions and 80 deletions
|
|
@ -2,6 +2,7 @@ import openai from "openai";
|
|||
import { ChatCompletionMessageParam } from "openai/resources/chat/completions";
|
||||
import { message } from "antd";
|
||||
import { TokenUsage } from "../ResponseMetrics";
|
||||
import { getProxyBaseUrl } from "@/components/networking";
|
||||
|
||||
export async function makeOpenAIChatCompletionRequest(
|
||||
chatHistory: { role: string; content: string }[],
|
||||
|
|
@ -23,10 +24,7 @@ export async function makeOpenAIChatCompletionRequest(
|
|||
console.log = function () {};
|
||||
}
|
||||
console.log("isLocal:", isLocal);
|
||||
const proxyBaseUrl = isLocal
|
||||
? "http://localhost:4000"
|
||||
: window.location.origin;
|
||||
|
||||
const proxyBaseUrl = getProxyBaseUrl()
|
||||
// Prepare headers with tags and trace ID
|
||||
const headers: Record<string, string> = {};
|
||||
if (tags && tags.length > 0) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import openai from "openai";
|
||||
import { message } from "antd";
|
||||
import { getProxyBaseUrl } from "@/components/networking";
|
||||
|
||||
export async function makeOpenAIImageEditsRequest(
|
||||
imageFile: File,
|
||||
|
|
@ -16,9 +17,7 @@ export async function makeOpenAIImageEditsRequest(
|
|||
console.log = function () {};
|
||||
}
|
||||
console.log("isLocal:", isLocal);
|
||||
const proxyBaseUrl = isLocal
|
||||
? "http://localhost:4000"
|
||||
: window.location.origin;
|
||||
const proxyBaseUrl = getProxyBaseUrl()
|
||||
|
||||
const client = new openai.OpenAI({
|
||||
apiKey: accessToken,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import openai from "openai";
|
||||
import { message } from "antd";
|
||||
import { getProxyBaseUrl } from "@/components/networking";
|
||||
|
||||
export async function makeOpenAIImageGenerationRequest(
|
||||
prompt: string,
|
||||
|
|
@ -15,9 +16,7 @@ export async function makeOpenAIImageGenerationRequest(
|
|||
console.log = function () {};
|
||||
}
|
||||
console.log("isLocal:", isLocal);
|
||||
const proxyBaseUrl = isLocal
|
||||
? "http://localhost:4000"
|
||||
: window.location.origin;
|
||||
const proxyBaseUrl = getProxyBaseUrl()
|
||||
const client = new openai.OpenAI({
|
||||
apiKey: accessToken,
|
||||
baseURL: proxyBaseUrl,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import openai from "openai";
|
|||
import { message } from "antd";
|
||||
import { MessageType } from "../types";
|
||||
import { TokenUsage } from "../ResponseMetrics";
|
||||
import { getProxyBaseUrl } from "@/components/networking";
|
||||
|
||||
export async function makeOpenAIResponsesRequest(
|
||||
messages: MessageType[],
|
||||
|
|
@ -27,10 +28,7 @@ export async function makeOpenAIResponsesRequest(
|
|||
console.log = function () {};
|
||||
}
|
||||
|
||||
const proxyBaseUrl = isLocal
|
||||
? "http://localhost:4000"
|
||||
: window.location.origin;
|
||||
|
||||
const proxyBaseUrl = getProxyBaseUrl()
|
||||
// Prepare headers with tags and trace ID
|
||||
const headers: Record<string, string> = {};
|
||||
if (tags && tags.length > 0) {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import {
|
|||
modelAvailableCall,
|
||||
invitationCreateCall,
|
||||
getProxyUISettings,
|
||||
getProxyBaseUrl,
|
||||
} from "./networking";
|
||||
import BulkCreateUsers from "./bulk_create_users_button";
|
||||
const { Option } = Select;
|
||||
|
|
@ -61,10 +62,7 @@ const Createuser: React.FC<CreateuserProps> = ({
|
|||
useState(false);
|
||||
const [invitationLinkData, setInvitationLinkData] =
|
||||
useState<InvitationLink | null>(null);
|
||||
const router = useRouter();
|
||||
const isLocal = process.env.NODE_ENV === "development";
|
||||
|
||||
const [baseUrl, setBaseUrl] = useState("http://localhost:4000");
|
||||
const baseUrl = getProxyBaseUrl();
|
||||
// get all models
|
||||
useEffect(() => {
|
||||
const fetchData = async () => {
|
||||
|
|
@ -100,14 +98,6 @@ const Createuser: React.FC<CreateuserProps> = ({
|
|||
fetchData(); // Call the function to fetch model data when the component mounts
|
||||
}, []); // Empty dependency array to run only once
|
||||
|
||||
useEffect(() => {
|
||||
if (!router) {
|
||||
return;
|
||||
}
|
||||
|
||||
const base = new URL("/", window.location.href);
|
||||
setBaseUrl(base.toString());
|
||||
}, [router]);
|
||||
const handleOk = () => {
|
||||
setIsModalVisible(false);
|
||||
form.resetFields();
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import Link from "next/link";
|
|||
import React, { useState, useEffect } from "react";
|
||||
import type { MenuProps } from "antd";
|
||||
import { Dropdown } from "antd";
|
||||
import { Organization } from "@/components/networking";
|
||||
import { getProxyBaseUrl, Organization } from "@/components/networking";
|
||||
import { defaultOrg } from "@/components/common_components/default_org";
|
||||
import {
|
||||
UserOutlined,
|
||||
|
|
@ -30,8 +30,8 @@ const Navbar: React.FC<NavbarProps> = ({
|
|||
setProxySettings,
|
||||
accessToken,
|
||||
}) => {
|
||||
const isLocal = process.env.NODE_ENV === "development";
|
||||
const imageUrl = isLocal ? "http://localhost:4000/get_image" : "/get_image";
|
||||
const baseUrl = getProxyBaseUrl();
|
||||
const imageUrl = baseUrl + "/get_image";
|
||||
const [logoutUrl, setLogoutUrl] = useState("");
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,10 @@ export const updateProxyBaseUrl = (serverRootPath: string) => {
|
|||
proxyBaseUrl += serverRootPath;
|
||||
};
|
||||
|
||||
export const getProxyBaseUrl = () => {
|
||||
return proxyBaseUrl;
|
||||
};
|
||||
|
||||
const HTTP_REQUEST = {
|
||||
GET: "GET",
|
||||
POST: "POST",
|
||||
|
|
|
|||
|
|
@ -12,11 +12,7 @@ interface RequestAccessProps {
|
|||
accessToken: string;
|
||||
userID: string;
|
||||
}
|
||||
const isLocal = process.env.NODE_ENV === "development";
|
||||
const proxyBaseUrl = isLocal ? "http://localhost:4000" : null;
|
||||
if (isLocal != true) {
|
||||
console.log = function() {};
|
||||
}
|
||||
|
||||
function onRequestAccess(formData: Record<string, any>): void {
|
||||
// This function does nothing for now
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,11 +35,7 @@ import { Modal, Typography, Form, Input, Select, Button as Button2, message } fr
|
|||
import EmailSettings from "./email_settings";
|
||||
|
||||
const { Title, Paragraph } = Typography;
|
||||
const isLocal = process.env.NODE_ENV === "development";
|
||||
const proxyBaseUrl = isLocal ? "http://localhost:4000" : null;
|
||||
if (isLocal != true) {
|
||||
console.log = function() {};
|
||||
}
|
||||
|
||||
import {
|
||||
getCallbacksCall,
|
||||
setCallbacksCall,
|
||||
|
|
|
|||
|
|
@ -60,11 +60,7 @@ import AvailableTeamsPanel from "@/components/team/available_teams";
|
|||
import VectorStoreSelector from "./vector_store_management/VectorStoreSelector";
|
||||
import PremiumVectorStoreSelector from "./common_components/PremiumVectorStoreSelector";
|
||||
import type { KeyResponse, Team } from "./key_team_helpers/key_list";
|
||||
const isLocal = process.env.NODE_ENV === "development";
|
||||
const proxyBaseUrl = isLocal ? "http://localhost:4000" : null;
|
||||
if (isLocal != true) {
|
||||
console.log = function() {};
|
||||
}
|
||||
|
||||
interface TeamProps {
|
||||
teams: Team[] | null;
|
||||
searchParams: any;
|
||||
|
|
|
|||
|
|
@ -41,11 +41,6 @@ import {
|
|||
import { start } from "repl";
|
||||
import TopKeyView from "./top_key_view";
|
||||
console.log("process.env.NODE_ENV", process.env.NODE_ENV);
|
||||
const isLocal = process.env.NODE_ENV === "development";
|
||||
const proxyBaseUrl = isLocal ? "http://localhost:4000" : null;
|
||||
if (isLocal !== true) {
|
||||
console.log = function() {};
|
||||
}
|
||||
|
||||
interface UsagePageProps {
|
||||
accessToken: string | null;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@ import {
|
|||
Organization,
|
||||
organizationListCall,
|
||||
DEFAULT_ORGANIZATION,
|
||||
keyInfoCall
|
||||
keyInfoCall,
|
||||
getProxyBaseUrl
|
||||
} from "./networking";
|
||||
import { fetchTeams } from "./common_components/fetch_teams";
|
||||
import { Grid, Col, Card, Text, Title } from "@tremor/react";
|
||||
|
|
@ -23,12 +24,6 @@ import { Team } from "./key_team_helpers/key_list";
|
|||
import { jwtDecode } from "jwt-decode";
|
||||
import { Typography } from "antd";
|
||||
import { clearTokenCookies } from "@/utils/cookieUtils";
|
||||
const isLocal = process.env.NODE_ENV === "development";
|
||||
if (isLocal != true) {
|
||||
console.log = function() {};
|
||||
}
|
||||
console.log("isLocal:", isLocal);
|
||||
const proxyBaseUrl = isLocal ? "http://localhost:4000" : null;
|
||||
|
||||
export interface ProxySettings {
|
||||
PROXY_BASE_URL: string | null;
|
||||
|
|
@ -326,10 +321,12 @@ const UserDashboard: React.FC<UserDashboardProps> = ({
|
|||
// Clear token cookies using the utility function
|
||||
clearTokenCookies();
|
||||
|
||||
console.log("proxyBaseUrl:", proxyBaseUrl);
|
||||
const baseUrl = getProxyBaseUrl();
|
||||
|
||||
console.log("proxyBaseUrl:", baseUrl);
|
||||
|
||||
const url = proxyBaseUrl
|
||||
? `${proxyBaseUrl}/litellm/sso/key/generate`
|
||||
const url = baseUrl
|
||||
? `${baseUrl}/sso/key/generate`
|
||||
: `/sso/key/generate`;
|
||||
|
||||
console.log("Full URL:", url);
|
||||
|
|
|
|||
|
|
@ -73,12 +73,6 @@ import { AllKeysTable } from "./all_keys_table";
|
|||
import { Team } from "./key_team_helpers/key_list";
|
||||
import { Setter } from "@/types";
|
||||
|
||||
const isLocal = process.env.NODE_ENV === "development";
|
||||
const proxyBaseUrl = isLocal ? "http://localhost:4000" : null;
|
||||
if (isLocal != true) {
|
||||
console.log = function () {};
|
||||
}
|
||||
|
||||
interface EditKeyModalProps {
|
||||
visible: boolean;
|
||||
onCancel: () => void;
|
||||
|
|
|
|||
|
|
@ -23,11 +23,6 @@ import {
|
|||
} from "@tremor/react";
|
||||
import { Statistic } from "antd"
|
||||
import { spendUsersCall, modelAvailableCall } from "./networking";
|
||||
const isLocal = process.env.NODE_ENV === "development";
|
||||
const proxyBaseUrl = isLocal ? "http://localhost:4000" : null;
|
||||
if (isLocal != true) {
|
||||
console.log = function() {};
|
||||
}
|
||||
|
||||
// Define the props type
|
||||
interface UserSpendData {
|
||||
|
|
|
|||
|
|
@ -21,11 +21,6 @@ import {
|
|||
} from "@tremor/react";
|
||||
import { Statistic } from "antd"
|
||||
import { modelAvailableCall } from "./networking";
|
||||
const isLocal = process.env.NODE_ENV === "development";
|
||||
const proxyBaseUrl = isLocal ? "http://localhost:4000" : null;
|
||||
if (isLocal != true) {
|
||||
console.log = function() {};
|
||||
}
|
||||
|
||||
interface ViewUserTeamProps {
|
||||
userID: string | null;
|
||||
|
|
|
|||
|
|
@ -55,11 +55,6 @@ interface FilterState {
|
|||
sort_order: 'asc' | 'desc';
|
||||
}
|
||||
|
||||
const isLocal = process.env.NODE_ENV === "development";
|
||||
const proxyBaseUrl = isLocal ? "http://localhost:4000" : null;
|
||||
if (isLocal != true) {
|
||||
console.log = function() {};
|
||||
}
|
||||
|
||||
const DEFAULT_PAGE_SIZE = 25;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue