Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ NEXT_PUBLIC_ACCESS_PERPLEXITY=
PERPLEXITY_API_KEY=
PERPLEXITY_ENDPOINT=

## Venice
NEXT_PUBLIC_ACCESS_VENICE=
VENICE_API_KEY=
VENICE_ENDPOINT=

# -------------- Search Engines --------------

## Google
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ ENV AWS_ACCESS_KEY="" \
OPENAI_API_KEY="" \
OPENAI_API_ENDPOINT="" \
PERPLEXITY_API_KEY="" \
PERPLEXITY_ENDPOINT=""
PERPLEXITY_ENDPOINT="" \
VENICE_API_KEY="" \
VENICE_ENDPOINT=""

CMD ["pnpm", "start"]
15 changes: 15 additions & 0 deletions app/api/chat/messages/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ const perplexity = new OpenAI({
baseURL: process.env.PERPLEXITY_ENDPOINT ?? 'https://api.perplexity.ai/',
});

const venice = new OpenAI({
apiKey: process.env.VENICE_API_KEY ?? '',
baseURL: process.env.VENICE_ENDPOINT ?? 'https://api.venice.ai/api/v1',
});

export const runtime = 'edge';

export const dynamic = 'force-dynamic';
Expand Down Expand Up @@ -185,6 +190,16 @@ export async function POST(req: Request) {
const output = OpenAIStream(response);
return new StreamingTextResponse(output);
}
case Provider.Venice: {
const response = await venice.chat.completions.create({
model: config.model.model_id,
stream: true,
max_tokens: 4096,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: max_tokens should be configurable through the config object

Consider making max_tokens configurable through the config object rather than hardcoding it. This value is duplicated in venice/route.ts as well.

Suggested implementation:

            const response = await venice.chat.completions.create({
                model: config.model.model_id,
                stream: true,
                max_tokens: config.model.max_tokens,
                messages,
            });

You'll also need to:

  1. Update the config type definition to include max_tokens in the model configuration
  2. Update any config files or objects to include the max_tokens value
  3. Update venice/route.ts to use the same config.model.max_tokens instead of its hardcoded value

messages,
});
const output = OpenAIStream(response);
return new StreamingTextResponse(output);
}
default:
return new Response('Invalid Provider', { status: 400 });
}
Expand Down
36 changes: 36 additions & 0 deletions app/api/chat/messages/venice/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { OpenAIStream, StreamingTextResponse } from 'ai';
import OpenAI from 'openai';

import { ApiConfig } from '@/types/app';

export const runtime = 'edge';

export const dynamic = 'force-dynamic';

export async function POST(req: Request) {
const {
messages,
config,
stream,
}: {
messages: any[];
config: ApiConfig;
stream: boolean;
} = await req.json();

const venice = new OpenAI({
apiKey: config.provider?.apiKey ?? process.env.VENICE_API_KEY ?? '',
baseURL: config.provider?.endpoint ?? process.env.VENICE_ENDPOINT ?? 'https://api.venice.ai/api/v1',
});

const response = await venice.chat.completions.create({
model: config.model.model_id,
stream: true,
max_tokens: 4096,
messages,
});

const output = OpenAIStream(response);

return new StreamingTextResponse(output);
}
9 changes: 9 additions & 0 deletions components/layout/model-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { model as HuggingFaceModel } from '@/config/provider/huggingface';
import { model as MistralModel } from '@/config/provider/mistral';
import { model as OpenAIModel } from '@/config/provider/openai';
import { model as PerplexityModel } from '@/config/provider/perplexity';
import { model as VeniceModel } from '@/config/provider/venice';
import store from '@/hooks/store';
import { Model, SimpleModel } from '@/types/model';
import { ProviderSetting } from '@/types/settings';
Expand Down Expand Up @@ -162,6 +163,14 @@ export const ModelSelect = () => {
currentProviderSettings={currentProviderSettings}
configured={process.env['NEXT_PUBLIC_ACCESS_PERPLEXITY'] == 'true'}
/>
<ModelSelector
label={Provider.Venice}
models={VeniceModel}
recentUsedModel={currentUseModel}
setCurrentUseModel={handleModelChange}
currentProviderSettings={currentProviderSettings}
configured={process.env['NEXT_PUBLIC_ACCESS_VENICE'] == 'true'}
/>
<DropdownMenuSeparator />
<CustomModelSelector
label={Provider.Custom}
Expand Down
4 changes: 4 additions & 0 deletions components/layout/settings-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const SettingsDialog = () => {
const [mistral, setMistral] = useState<ProviderSetting['Mistral'] | null>(currentProviderSettings?.Mistral || null);
const [openAI, setOpenAI] = useState<ProviderSetting['OpenAI'] | null>(currentProviderSettings?.OpenAI || null);
const [perplexity, setPerplexity] = useState<ProviderSetting['Perplexity'] | null>(currentProviderSettings?.Perplexity || null);
const [venice, setVenice] = useState<ProviderSetting['Venice'] | null>(currentProviderSettings?.Venice || null);

const [custom, setCustom] = useState<ProviderSetting['Custom'] | null>(currentProviderSettings?.Custom || null);

Expand Down Expand Up @@ -100,6 +101,7 @@ export const SettingsDialog = () => {
Mistral: mistral!,
OpenAI: openAI!,
Perplexity: perplexity!,
Venice: venice!,

Custom: custom!,
});
Expand Down Expand Up @@ -203,6 +205,8 @@ export const SettingsDialog = () => {
setMistral={setMistral}
perplexity={perplexity}
setPerplexity={setPerplexity}
venice={venice}
setVenice={setVenice}
custom={custom}
setCustom={setCustom}
/>
Expand Down
4 changes: 4 additions & 0 deletions components/layout/settings-drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const SettingsDrawer = () => {
const [mistral, setMistral] = useState<ProviderSetting['Mistral'] | null>(currentProviderSettings?.Mistral || null);
const [openAI, setOpenAI] = useState<ProviderSetting['OpenAI'] | null>(currentProviderSettings?.OpenAI || null);
const [perplexity, setPerplexity] = useState<ProviderSetting['Perplexity'] | null>(currentProviderSettings?.Perplexity || null);
const [venice, setVenice] = useState<ProviderSetting['Venice'] | null>(currentProviderSettings?.Venice || null);

const [custom, setCustom] = useState<ProviderSetting['Custom'] | null>(currentProviderSettings?.Custom || null);

Expand Down Expand Up @@ -100,6 +101,7 @@ export const SettingsDrawer = () => {
Mistral: mistral!,
OpenAI: openAI!,
Perplexity: perplexity!,
Venice: venice!,
});

setCurrentSearchEngineSettings({
Expand Down Expand Up @@ -186,6 +188,8 @@ export const SettingsDrawer = () => {
setMistral={setMistral}
perplexity={perplexity}
setPerplexity={setPerplexity}
venice={venice}
setVenice={setVenice}
custom={custom}
setCustom={setCustom}
/>
Expand Down
7 changes: 7 additions & 0 deletions components/layout/settings/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { HuggingFaceProvider } from '@/components/layout/settings/provider/huggi
import { MistralProvider } from '@/components/layout/settings/provider/mistral';
import { OpenAIProvider } from '@/components/layout/settings/provider/openai';
import { PerplexityProvider } from '@/components/layout/settings/provider/perplexity';
import { VeniceProvider } from '@/components/layout/settings/provider/venice';
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/custom/select';
import { Provider, Providers } from '@/config/provider';
import { ProviderSetting } from '@/types/settings';
Expand Down Expand Up @@ -43,6 +44,8 @@ export const ProviderSettings = ({
setOpenAI,
perplexity,
setPerplexity,
venice,
setVenice,

custom,
setCustom,
Expand Down Expand Up @@ -71,6 +74,8 @@ export const ProviderSettings = ({
setOpenAI: (value: ProviderSetting['OpenAI'] | null) => void;
perplexity: ProviderSetting['Perplexity'] | null;
setPerplexity: (value: ProviderSetting['Perplexity'] | null) => void;
venice: ProviderSetting['Venice'] | null;
setVenice: (value: ProviderSetting['Venice'] | null) => void;

custom: ProviderSetting['Custom'] | null;
setCustom: (value: ProviderSetting['Custom'] | null) => void;
Expand Down Expand Up @@ -103,6 +108,8 @@ export const ProviderSettings = ({
return <OpenAIProvider openAI={openAI} setOpenAI={setOpenAI} />;
case Provider.Perplexity:
return <PerplexityProvider perplexity={perplexity} setPerplexity={setPerplexity} />;
case Provider.Venice:
return <VeniceProvider venice={venice} setVenice={setVenice} />;
case Provider.Custom:
return <CustomProvider custom={custom} setCustom={setCustom} />;
default:
Expand Down
35 changes: 35 additions & 0 deletions components/layout/settings/provider/venice.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Input } from '@/components/ui/custom/input';
import { ProviderSetting } from '@/types/settings';

export const VeniceProvider = ({ venice, setVenice }: { venice: ProviderSetting['Venice'] | null; setVenice: (value: ProviderSetting['Venice'] | null) => void }) => {
return (
<div className='space-y-2'>
<div className='space-y-0.5'>
<p className='px-1 text-sm'>Venice API Key</p>
<Input
type='text'
placeholder='sk-xxxx'
value={venice?.apiKey}
onChange={(e) => {
setVenice({
apiKey: e.target.value,
});
}}
/>
</div>
<div className='space-y-0.5'>
<p className='px-1 text-sm'>Venice Endpoint</p>
<Input
type='text'
placeholder='https://api.venice.ai/api/v1'
value={venice?.endpoint}
onChange={(e) => {
setVenice({
endpoint: e.target.value,
});
}}
/>
</div>
</div>
);
};
12 changes: 10 additions & 2 deletions config/provider/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { HuggingFaceModelId, HuggingFaceModelName } from '@/config/provider/hugg
import { MistralModelId, MistralModelName } from '@/config/provider/mistral';
import { OpenAIModelId, OpenAIModelName } from '@/config/provider/openai';
import { PerplexityModelId, PerplexityModelName } from '@/config/provider/perplexity';
import { VeniceModelId, VeniceModelName } from '@/config/provider/venice';

export type AllModelId =
| AmazonModelId
Expand All @@ -21,7 +22,8 @@ export type AllModelId =
| MistralModelId
| GoogleModelId
| OpenAIModelId
| PerplexityModelId;
| PerplexityModelId
| VeniceModelId;

export type AllModelName =
| AmazonModelName
Expand All @@ -34,7 +36,8 @@ export type AllModelName =
| MistralModelName
| GoogleModelName
| OpenAIModelName
| PerplexityModelName;
| PerplexityModelName
| VeniceModelName;

export enum Provider {
Amazon = 'Amazon',
Expand All @@ -48,6 +51,7 @@ export enum Provider {
HuggingFace = 'HuggingFace',
Mistral = 'Mistral',
Perplexity = 'Perplexity',
Venice = 'Venice',

Custom = 'Custom',
}
Expand Down Expand Up @@ -100,6 +104,10 @@ export const Providers: {
id: 'perplexity',
name: Provider.Perplexity,
},
{
id: 'venice',
name: Provider.Venice,
},
{
id: 'custom',
name: Provider.Custom,
Expand Down
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ services:

- PERPLEXITY_API_KEY=
- PERPLEXITY_ENDPOINT=

- VENICE_API_KEY=
- VENICE_ENDPOINT=
restart: always
ports:
- 3000:3000
Binary file added public/img/Venice.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions types/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ export interface PerplexitySettings {
endpoint?: string;
}

export interface VeniceSettings {
apiKey?: string;
endpoint?: string;
}

export type CustomSettings = SingleCustomSettings[];

export interface SingleCustomSettings {
Expand All @@ -108,6 +113,7 @@ export interface ProviderSetting {
[Provider.HuggingFace]?: HuggingFaceSettings;
[Provider.Mistral]?: MistralSettings;
[Provider.Perplexity]?: PerplexitySettings;
[Provider.Venice]?: VeniceSettings;
[Provider.Custom]?: CustomSettings;
}

Expand All @@ -123,4 +129,5 @@ export type SpecifiedProviderSetting =
| HuggingFaceSettings
| MistralSettings
| PerplexitySettings
| VeniceSettings
| SingleCustomSettings;