Adds Google VertexAI as model provider

This commit is contained in:
Hristo 2024-05-14 15:05:17 -04:00
parent cef75279c5
commit ebbe18ab45
12 changed files with 101 additions and 77 deletions

View file

@ -36,14 +36,11 @@ const useSocket = (url: string) => {
!embeddingModel ||
!embeddingModelProvider
) {
const providers = await clientFetch(
'/models',
{
headers: {
'Content-Type': 'application/json',
},
const providers = await clientFetch('/models', {
headers: {
'Content-Type': 'application/json',
},
).then(async (res) => await res.json());
}).then(async (res) => await res.json());
const chatModelProviders = providers.chatModelProviders;
const embeddingModelProviders = providers.embeddingModelProviders;
@ -103,8 +100,8 @@ const useSocket = (url: string) => {
const secretToken = getAccessKey();
if (secretToken) {
protocols = ["Authorization", `${secretToken}`];
};
protocols = ['Authorization', `${secretToken}`];
}
const ws = new WebSocket(wsURL.toString(), protocols);

View file

@ -34,21 +34,18 @@ const SearchImages = ({
const chatModelProvider = localStorage.getItem('chatModelProvider');
const chatModel = localStorage.getItem('chatModel');
const res = await clientFetch(
'/images',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: query,
chat_history: chat_history,
chat_model_provider: chatModelProvider,
chat_model: chatModel,
}),
const res = await clientFetch('/images', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
);
body: JSON.stringify({
query: query,
chat_history: chat_history,
chat_model_provider: chatModelProvider,
chat_model: chatModel,
}),
});
const data = await res.json();

View file

@ -47,21 +47,18 @@ const Searchvideos = ({
const chatModelProvider = localStorage.getItem('chatModelProvider');
const chatModel = localStorage.getItem('chatModel');
const res = await clientFetch(
'/videos',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: query,
chat_history: chat_history,
chat_model_provider: chatModelProvider,
chat_model: chatModel,
}),
const res = await clientFetch('/videos', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
);
body: JSON.stringify({
query: query,
chat_history: chat_history,
chat_model_provider: chatModelProvider,
chat_model: chatModel,
}),
});
const data = await res.json();

View file

@ -11,11 +11,12 @@ const loadEnv = () => {
GENERAL: {
NEXT_PUBLIC_SUPER_SECRET_KEY: process.env.NEXT_PUBLIC_SUPER_SECRET_KEY!,
NEXT_PUBLIC_API_URL: process.env.NEXT_PUBLIC_API_URL!,
NEXT_PUBLIC_WS_URL: process.env.NEXT_PUBLIC_WS_URL!
NEXT_PUBLIC_WS_URL: process.env.NEXT_PUBLIC_WS_URL!,
},
} as Config;
};
export const getAccessKey = () => loadEnv().GENERAL.NEXT_PUBLIC_SUPER_SECRET_KEY;
export const getAccessKey = () =>
loadEnv().GENERAL.NEXT_PUBLIC_SUPER_SECRET_KEY;
export const getBackendURL = () => loadEnv().GENERAL.NEXT_PUBLIC_API_URL;

View file

@ -1,6 +1,6 @@
import clsx, { ClassValue } from 'clsx';
import { twMerge } from 'tailwind-merge';
import { getAccessKey, getBackendURL } from './config'
import { getAccessKey, getBackendURL } from './config';
export const cn = (...classes: ClassValue[]) => twMerge(clsx(...classes));
@ -29,11 +29,11 @@ export const clientFetch = async (path: string, payload: any): Promise<any> => {
if (secretToken) {
if (headers == null) {
headers = {};
};
}
headers['Authorization'] = `Bearer ${secretToken}`;
payload.headers = headers;
};
}
return await fetch(url, payload);
};