Skip to content

Commit

Permalink
Merge pull request #150 from abstracta/remove-account-usage-link-azure
Browse files Browse the repository at this point in the history
Remove account usage link when using azure
  • Loading branch information
dotneet committed Sep 20, 2023
2 parents 95261fc + a427a28 commit 7401afe
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
5 changes: 3 additions & 2 deletions components/Chat/ModelSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const ModelSelect = () => {
const [_, conversationsAction] = useConversations();

const {
state: { selectedConversation, models, defaultModelId },
state: { selectedConversation, models, defaultModelId, isAzureOpenAI },
} = useContext(HomeContext);

const handleChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
Expand Down Expand Up @@ -52,7 +52,7 @@ export const ModelSelect = () => {
))}
</select>
</div>
<div className="w-full mt-3 text-left text-neutral-700 dark:text-neutral-400 flex items-center">
{!isAzureOpenAI && <div className="w-full mt-3 text-left text-neutral-700 dark:text-neutral-400 flex items-center">
<a
href="https://platform.openai.com/account/usage"
target="_blank"
Expand All @@ -62,6 +62,7 @@ export const ModelSelect = () => {
{t('View Account Usage')}
</a>
</div>
}
</div>
);
};
2 changes: 2 additions & 0 deletions pages/api/home/home.state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface HomeInitialState {
serverSideApiKeyIsSet: boolean;
serverSidePluginKeysSet: boolean;
stopConversationRef: MutableRefObject<boolean>;
isAzureOpenAI: boolean;
supportEmail: string;
promptSharingEnabled: boolean;
}
Expand Down Expand Up @@ -62,6 +63,7 @@ export const initialState: Partial<HomeInitialState> = {
defaultModelId: undefined,
serverSideApiKeyIsSet: false,
serverSidePluginKeysSet: false,
isAzureOpenAI: false,
supportEmail: '',
promptSharingEnabled: false,
};
10 changes: 7 additions & 3 deletions pages/api/home/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Head from 'next/head';
import { useCreateReducer } from '@/hooks/useCreateReducer';

import { cleanConversationHistory } from '@/utils/app/clean';
import { DEFAULT_SYSTEM_PROMPT, SUPPORT_EMAIL, PROMPT_SHARING_ENABLED } from '@/utils/app/const';
import { DEFAULT_SYSTEM_PROMPT, OPENAI_API_TYPE, PROMPT_SHARING_ENABLED, SUPPORT_EMAIL } from '@/utils/app/const';
import { trpc } from '@/utils/trpc';

import { Conversation } from '@/types/chat';
Expand All @@ -25,14 +25,16 @@ interface Props {
serverSideApiKeyIsSet: boolean;
serverSidePluginKeysSet: boolean;
defaultModelId: OpenAIModelID;
supportEmail: string,
promptSharingEnabled: boolean,
isAzureOpenAI: boolean;
promptSharingEnabled: boolean;
supportEmail: string;
}

const Home = ({
serverSideApiKeyIsSet,
serverSidePluginKeysSet,
defaultModelId,
isAzureOpenAI,
supportEmail,
promptSharingEnabled,
}: Props) => {
Expand All @@ -51,6 +53,7 @@ const Home = ({
initialState: {
...initialState,
stopConversationRef: stopConversationRef,
isAzureOpenAI,
supportEmail,
promptSharingEnabled: promptSharingEnabled,
} as HomeInitialState,
Expand Down Expand Up @@ -278,6 +281,7 @@ export const getServerSideProps: GetServerSideProps = async ({ locale }) => {
props: {
serverSideApiKeyIsSet: !!process.env.OPENAI_API_KEY,
defaultModelId,
isAzureOpenAI: OPENAI_API_TYPE === "azure",
serverSidePluginKeysSet,
supportEmail: SUPPORT_EMAIL,
...(await serverSideTranslations(locale ?? 'en', [
Expand Down

0 comments on commit 7401afe

Please sign in to comment.