mirror of
https://github.com/ItzCrazyKns/Perplexica.git
synced 2025-09-16 22:31:32 +00:00
Compare commits
3 Commits
v1.10.2
...
6e1e5dd185
Author | SHA1 | Date | |
---|---|---|---|
|
6e1e5dd185 | ||
|
98c185c12e | ||
|
446adbef3f |
@@ -18,6 +18,7 @@ API_KEY = ""
|
|||||||
[MODELS.CUSTOM_OPENAI]
|
[MODELS.CUSTOM_OPENAI]
|
||||||
API_KEY = ""
|
API_KEY = ""
|
||||||
API_URL = ""
|
API_URL = ""
|
||||||
|
TEMPERATURE = 0.7
|
||||||
|
|
||||||
[MODELS.OLLAMA]
|
[MODELS.OLLAMA]
|
||||||
API_URL = "" # Ollama API URL - http://host.docker.internal:11434
|
API_URL = "" # Ollama API URL - http://host.docker.internal:11434
|
||||||
|
@@ -30,6 +30,7 @@ interface Config {
|
|||||||
API_URL: string;
|
API_URL: string;
|
||||||
API_KEY: string;
|
API_KEY: string;
|
||||||
MODEL_NAME: string;
|
MODEL_NAME: string;
|
||||||
|
TEMPERATURE: number;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
API_ENDPOINTS: {
|
API_ENDPOINTS: {
|
||||||
@@ -75,6 +76,9 @@ export const getCustomOpenaiApiUrl = () =>
|
|||||||
export const getCustomOpenaiModelName = () =>
|
export const getCustomOpenaiModelName = () =>
|
||||||
loadConfig().MODELS.CUSTOM_OPENAI.MODEL_NAME;
|
loadConfig().MODELS.CUSTOM_OPENAI.MODEL_NAME;
|
||||||
|
|
||||||
|
export const getCustomOpenaiTemperature = () =>
|
||||||
|
loadConfig().MODELS.CUSTOM_OPENAI.TEMPERATURE;
|
||||||
|
|
||||||
const mergeConfigs = (current: any, update: any): any => {
|
const mergeConfigs = (current: any, update: any): any => {
|
||||||
if (update === null || update === undefined) {
|
if (update === null || update === undefined) {
|
||||||
return current;
|
return current;
|
||||||
|
@@ -8,6 +8,7 @@ import {
|
|||||||
getCustomOpenaiApiKey,
|
getCustomOpenaiApiKey,
|
||||||
getCustomOpenaiApiUrl,
|
getCustomOpenaiApiUrl,
|
||||||
getCustomOpenaiModelName,
|
getCustomOpenaiModelName,
|
||||||
|
getCustomOpenaiTemperature,
|
||||||
} from '../../config';
|
} from '../../config';
|
||||||
import { ChatOpenAI } from '@langchain/openai';
|
import { ChatOpenAI } from '@langchain/openai';
|
||||||
|
|
||||||
@@ -39,6 +40,7 @@ export const getAvailableChatModelProviders = async () => {
|
|||||||
const customOpenAiApiKey = getCustomOpenaiApiKey();
|
const customOpenAiApiKey = getCustomOpenaiApiKey();
|
||||||
const customOpenAiApiUrl = getCustomOpenaiApiUrl();
|
const customOpenAiApiUrl = getCustomOpenaiApiUrl();
|
||||||
const customOpenAiModelName = getCustomOpenaiModelName();
|
const customOpenAiModelName = getCustomOpenaiModelName();
|
||||||
|
const customOpenAiTemperature = getCustomOpenaiTemperature();
|
||||||
|
|
||||||
models['custom_openai'] = {
|
models['custom_openai'] = {
|
||||||
...(customOpenAiApiKey && customOpenAiApiUrl && customOpenAiModelName
|
...(customOpenAiApiKey && customOpenAiApiUrl && customOpenAiModelName
|
||||||
@@ -48,7 +50,7 @@ export const getAvailableChatModelProviders = async () => {
|
|||||||
model: new ChatOpenAI({
|
model: new ChatOpenAI({
|
||||||
openAIApiKey: customOpenAiApiKey,
|
openAIApiKey: customOpenAiApiKey,
|
||||||
modelName: customOpenAiModelName,
|
modelName: customOpenAiModelName,
|
||||||
temperature: 0.7,
|
temperature: customOpenAiTemperature,
|
||||||
configuration: {
|
configuration: {
|
||||||
baseURL: customOpenAiApiUrl,
|
baseURL: customOpenAiApiUrl,
|
||||||
},
|
},
|
||||||
|
@@ -13,6 +13,7 @@ import {
|
|||||||
getCustomOpenaiApiUrl,
|
getCustomOpenaiApiUrl,
|
||||||
getCustomOpenaiApiKey,
|
getCustomOpenaiApiKey,
|
||||||
getCustomOpenaiModelName,
|
getCustomOpenaiModelName,
|
||||||
|
getCustomOpenaiTemperature,
|
||||||
} from '../config';
|
} from '../config';
|
||||||
import logger from '../utils/logger';
|
import logger from '../utils/logger';
|
||||||
|
|
||||||
@@ -60,6 +61,7 @@ router.get('/', async (_, res) => {
|
|||||||
config['customOpenaiApiUrl'] = getCustomOpenaiApiUrl();
|
config['customOpenaiApiUrl'] = getCustomOpenaiApiUrl();
|
||||||
config['customOpenaiApiKey'] = getCustomOpenaiApiKey();
|
config['customOpenaiApiKey'] = getCustomOpenaiApiKey();
|
||||||
config['customOpenaiModelName'] = getCustomOpenaiModelName();
|
config['customOpenaiModelName'] = getCustomOpenaiModelName();
|
||||||
|
config['customOpenaiTemperature'] = getCustomOpenaiTemperature();
|
||||||
|
|
||||||
res.status(200).json(config);
|
res.status(200).json(config);
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
|
@@ -9,6 +9,7 @@ import {
|
|||||||
getCustomOpenaiApiKey,
|
getCustomOpenaiApiKey,
|
||||||
getCustomOpenaiApiUrl,
|
getCustomOpenaiApiUrl,
|
||||||
getCustomOpenaiModelName,
|
getCustomOpenaiModelName,
|
||||||
|
getCustomOpenaiTemperature,
|
||||||
} from '../config';
|
} from '../config';
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
@@ -50,7 +51,7 @@ router.post('/', async (req, res) => {
|
|||||||
llm = new ChatOpenAI({
|
llm = new ChatOpenAI({
|
||||||
modelName: getCustomOpenaiModelName(),
|
modelName: getCustomOpenaiModelName(),
|
||||||
openAIApiKey: getCustomOpenaiApiKey(),
|
openAIApiKey: getCustomOpenaiApiKey(),
|
||||||
temperature: 0.7,
|
temperature: getCustomOpenaiTemperature(),
|
||||||
configuration: {
|
configuration: {
|
||||||
baseURL: getCustomOpenaiApiUrl(),
|
baseURL: getCustomOpenaiApiUrl(),
|
||||||
},
|
},
|
||||||
|
@@ -14,6 +14,7 @@ import {
|
|||||||
getCustomOpenaiApiKey,
|
getCustomOpenaiApiKey,
|
||||||
getCustomOpenaiApiUrl,
|
getCustomOpenaiApiUrl,
|
||||||
getCustomOpenaiModelName,
|
getCustomOpenaiModelName,
|
||||||
|
getCustomOpenaiTemperature,
|
||||||
} from '../config';
|
} from '../config';
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
@@ -23,6 +24,7 @@ interface chatModel {
|
|||||||
model: string;
|
model: string;
|
||||||
customOpenAIKey?: string;
|
customOpenAIKey?: string;
|
||||||
customOpenAIBaseURL?: string;
|
customOpenAIBaseURL?: string;
|
||||||
|
customOpenAITemperature?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface embeddingModel {
|
interface embeddingModel {
|
||||||
@@ -87,7 +89,9 @@ router.post('/', async (req, res) => {
|
|||||||
modelName: body.chatModel?.model || getCustomOpenaiModelName(),
|
modelName: body.chatModel?.model || getCustomOpenaiModelName(),
|
||||||
openAIApiKey:
|
openAIApiKey:
|
||||||
body.chatModel?.customOpenAIKey || getCustomOpenaiApiKey(),
|
body.chatModel?.customOpenAIKey || getCustomOpenaiApiKey(),
|
||||||
temperature: 0.7,
|
temperature:
|
||||||
|
body.chatModel?.customOpenAITemperature ||
|
||||||
|
getCustomOpenaiTemperature(),
|
||||||
configuration: {
|
configuration: {
|
||||||
baseURL:
|
baseURL:
|
||||||
body.chatModel?.customOpenAIBaseURL || getCustomOpenaiApiUrl(),
|
body.chatModel?.customOpenAIBaseURL || getCustomOpenaiApiUrl(),
|
||||||
|
@@ -9,6 +9,7 @@ import {
|
|||||||
getCustomOpenaiApiKey,
|
getCustomOpenaiApiKey,
|
||||||
getCustomOpenaiApiUrl,
|
getCustomOpenaiApiUrl,
|
||||||
getCustomOpenaiModelName,
|
getCustomOpenaiModelName,
|
||||||
|
getCustomOpenaiTemperature,
|
||||||
} from '../config';
|
} from '../config';
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
@@ -49,7 +50,7 @@ router.post('/', async (req, res) => {
|
|||||||
llm = new ChatOpenAI({
|
llm = new ChatOpenAI({
|
||||||
modelName: getCustomOpenaiModelName(),
|
modelName: getCustomOpenaiModelName(),
|
||||||
openAIApiKey: getCustomOpenaiApiKey(),
|
openAIApiKey: getCustomOpenaiApiKey(),
|
||||||
temperature: 0.7,
|
temperature: getCustomOpenaiTemperature(),
|
||||||
configuration: {
|
configuration: {
|
||||||
baseURL: getCustomOpenaiApiUrl(),
|
baseURL: getCustomOpenaiApiUrl(),
|
||||||
},
|
},
|
||||||
|
@@ -9,6 +9,7 @@ import {
|
|||||||
getCustomOpenaiApiKey,
|
getCustomOpenaiApiKey,
|
||||||
getCustomOpenaiApiUrl,
|
getCustomOpenaiApiUrl,
|
||||||
getCustomOpenaiModelName,
|
getCustomOpenaiModelName,
|
||||||
|
getCustomOpenaiTemperature,
|
||||||
} from '../config';
|
} from '../config';
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
@@ -50,7 +51,7 @@ router.post('/', async (req, res) => {
|
|||||||
llm = new ChatOpenAI({
|
llm = new ChatOpenAI({
|
||||||
modelName: getCustomOpenaiModelName(),
|
modelName: getCustomOpenaiModelName(),
|
||||||
openAIApiKey: getCustomOpenaiApiKey(),
|
openAIApiKey: getCustomOpenaiApiKey(),
|
||||||
temperature: 0.7,
|
temperature: getCustomOpenaiTemperature(),
|
||||||
configuration: {
|
configuration: {
|
||||||
baseURL: getCustomOpenaiApiUrl(),
|
baseURL: getCustomOpenaiApiUrl(),
|
||||||
},
|
},
|
||||||
|
@@ -13,6 +13,7 @@ import {
|
|||||||
getCustomOpenaiApiKey,
|
getCustomOpenaiApiKey,
|
||||||
getCustomOpenaiApiUrl,
|
getCustomOpenaiApiUrl,
|
||||||
getCustomOpenaiModelName,
|
getCustomOpenaiModelName,
|
||||||
|
getCustomOpenaiTemperature,
|
||||||
} from '../config';
|
} from '../config';
|
||||||
|
|
||||||
export const handleConnection = async (
|
export const handleConnection = async (
|
||||||
@@ -56,12 +57,13 @@ export const handleConnection = async (
|
|||||||
const customOpenaiApiKey = getCustomOpenaiApiKey();
|
const customOpenaiApiKey = getCustomOpenaiApiKey();
|
||||||
const customOpenaiApiUrl = getCustomOpenaiApiUrl();
|
const customOpenaiApiUrl = getCustomOpenaiApiUrl();
|
||||||
const customOpenaiModelName = getCustomOpenaiModelName();
|
const customOpenaiModelName = getCustomOpenaiModelName();
|
||||||
|
const customOpenaiTemperature = getCustomOpenaiTemperature();
|
||||||
|
|
||||||
if (customOpenaiApiKey && customOpenaiApiUrl && customOpenaiModelName) {
|
if (customOpenaiApiKey && customOpenaiApiUrl && customOpenaiModelName) {
|
||||||
llm = new ChatOpenAI({
|
llm = new ChatOpenAI({
|
||||||
modelName: customOpenaiModelName,
|
modelName: customOpenaiModelName,
|
||||||
openAIApiKey: customOpenaiApiKey,
|
openAIApiKey: customOpenaiApiKey,
|
||||||
temperature: 0.7,
|
temperature: customOpenaiTemperature,
|
||||||
configuration: {
|
configuration: {
|
||||||
baseURL: customOpenaiApiUrl,
|
baseURL: customOpenaiApiUrl,
|
||||||
},
|
},
|
||||||
|
@@ -23,6 +23,7 @@ interface SettingsType {
|
|||||||
customOpenaiApiKey: string;
|
customOpenaiApiKey: string;
|
||||||
customOpenaiApiUrl: string;
|
customOpenaiApiUrl: string;
|
||||||
customOpenaiModelName: string;
|
customOpenaiModelName: string;
|
||||||
|
customOpenaiTemperature: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
||||||
@@ -576,6 +577,32 @@ const Page = () => {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="flex flex-col space-y-1">
|
||||||
|
<p className="text-black/70 dark:text-white/70 text-sm">
|
||||||
|
Temperature
|
||||||
|
</p>
|
||||||
|
<Input
|
||||||
|
type="number"
|
||||||
|
min={0}
|
||||||
|
step={0.1}
|
||||||
|
max={1}
|
||||||
|
placeholder="Temperature"
|
||||||
|
value={config.customOpenaiTemperature}
|
||||||
|
isSaving={savingStates['customOpenaiTemperature']}
|
||||||
|
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
setConfig((prev) => ({
|
||||||
|
...prev!,
|
||||||
|
customOpenaiTemperature: parseInt(
|
||||||
|
e.target.value,
|
||||||
|
10,
|
||||||
|
),
|
||||||
|
}));
|
||||||
|
}}
|
||||||
|
onSave={(value) =>
|
||||||
|
saveConfig('customOpenaiTemperature', value)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<div className="flex flex-col space-y-1">
|
<div className="flex flex-col space-y-1">
|
||||||
<p className="text-black/70 dark:text-white/70 text-sm">
|
<p className="text-black/70 dark:text-white/70 text-sm">
|
||||||
Custom OpenAI API Key
|
Custom OpenAI API Key
|
||||||
|
@@ -68,7 +68,13 @@ const MessageBox = ({
|
|||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{message.role === 'user' && (
|
{message.role === 'user' && (
|
||||||
<div className={cn('w-full', messageIndex === 0 ? 'pt-16' : 'pt-8', 'break-words')}>
|
<div
|
||||||
|
className={cn(
|
||||||
|
'w-full',
|
||||||
|
messageIndex === 0 ? 'pt-16' : 'pt-8',
|
||||||
|
'break-words',
|
||||||
|
)}
|
||||||
|
>
|
||||||
<h2 className="text-black dark:text-white font-medium text-3xl lg:w-9/12">
|
<h2 className="text-black dark:text-white font-medium text-3xl lg:w-9/12">
|
||||||
{message.content}
|
{message.content}
|
||||||
</h2>
|
</h2>
|
||||||
|
Reference in New Issue
Block a user