Skip to content

Commit

Permalink
feat(console): add /api prefix support
Browse files Browse the repository at this point in the history
  • Loading branch information
pyadav committed Mar 1, 2024
1 parent df78aff commit 350baa2
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 10 deletions.
Expand Up @@ -15,7 +15,7 @@ export const useChat = (): (() => Promise<void>) => {
async function chatCompletions() {
try {
const providerResponse = await fetch(
`${BASE_URL}/v1/providers/${provider}`
`${BASE_URL}/api/v1/providers/${provider}`
);
const providerData = await providerResponse.json();
const apikey = pathOr("", ["provider", "config", "auth", "api_key"])(
Expand All @@ -25,7 +25,7 @@ export const useChat = (): (() => Promise<void>) => {
if (!apikey)
return toast.error(`Provide API key for provider - ${provider}`);

const response = await fetch(`${BASE_URL}/v1/chat/completions`, {
const response = await fetch(`${BASE_URL}/api/v1/chat/completions`, {
method: "post",
headers: {
"x-ms-provider": provider,
Expand Down
Expand Up @@ -9,7 +9,7 @@ export function useLogsFetch() {
useEffect(() => {
async function fetchLogs() {
try {
const response = await fetch(`${BASE_URL}/v1/tracking/logs`);
const response = await fetch(`${BASE_URL}/api/v1/tracking/logs`);
const { logs = [] } = await response.json();
setLogs(logs);
} catch (e) {
Expand Down
Expand Up @@ -18,7 +18,7 @@ export function useModelFetch() {
useEffect(() => {
async function fetchModels() {
try {
const response = await fetch(`${BASE_URL}/v1/models`);
const response = await fetch(`${BASE_URL}/api/v1/models`);
const { models } = await response.json();
const fetchedProviders: ModelType[] = Object.keys(models).map(
(key) => ({
Expand Down
Expand Up @@ -66,7 +66,7 @@ export default function SingleProvider() {
try {
const data = getValues();
const response = await fetch(
`${BASE_URL}/v1/providers/${params.providerId}`,
`${BASE_URL}/api/v1/providers/${params.providerId}`,
{
method: "put",
body: JSON.stringify(data),
Expand All @@ -75,7 +75,13 @@ export default function SingleProvider() {
},
}
);
await response.json();
var res = await response.json();
if (!response.ok) {
return toast.error("Something went wrong", {
description: res.message,
});
}

toast.info("Updated", {
description: "Configuration has been updated",
});
Expand Down
Expand Up @@ -15,7 +15,7 @@ export function useProviderFetch(pname: string) {
useEffect(() => {
async function fetchProvider() {
try {
const response = await fetch(`${BASE_URL}/v1/providers/${pname}`);
const response = await fetch(`${BASE_URL}/api/v1/providers/${pname}`);
const { provider } = await response.json();

setProvider(provider);
Expand All @@ -30,7 +30,7 @@ export function useProviderFetch(pname: string) {
async function fetchProviderConfig() {
try {
const response = await fetch(
`${BASE_URL}/v1/providers/${pname}/config`
`${BASE_URL}/api/v1/providers/${pname}/config`
);
const { config } = await response.json();

Expand Down
Expand Up @@ -14,7 +14,7 @@ export function useProvidersFetch() {
useEffect(() => {
async function fetchModels() {
try {
const response = await fetch(`${BASE_URL}/v1/providers`);
const response = await fetch(`${BASE_URL}/api/v1/providers`);
const { providers } = await response.json();

setProviders(providers);
Expand Down
2 changes: 1 addition & 1 deletion frontend/playgrounds/studio/tailwind.config.ts
Expand Up @@ -5,7 +5,7 @@ const config = {
content: [
"./app/**/*.{js,ts,jsx,tsx}",
"./components/**/*.{js,ts,jsx,tsx}",
"../../packages/ui/**/*.{js,ts,jsx,tsx}",
"../../node_modules/@missingstudio/ui/**/*.{js,ts,jsx,tsx}",
],
prefix: "",
theme: {
Expand Down

0 comments on commit 350baa2

Please sign in to comment.