Skip to content

Commit 0d9d08d

Browse files
committed
fix(chatgpt): chatgpt & ollama update #39
1 parent d1c9115 commit 0d9d08d

File tree

5 files changed

+68
-22
lines changed

5 files changed

+68
-22
lines changed

src/app/components/Chat/ConversationPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ const ConversationPanel: FC<Props> = (props) => {
187187
};
188188

189189
const isBotShowSetting = useCallback(() => {
190-
if(props.botId == 'chatgpt' || props.botId == 'claude' || props.botId == 'bing'){
190+
if(props.botId == 'chatgpt' || props.botId == 'claude' || props.botId == 'bing' || props.botId == 'ollama'){
191191
return true
192192
}
193193
return false;

src/app/components/Chat/ErrorAction.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const ChatGPTAuthErrorAction = () => {
3939

4040
return (
4141
<div className="flex flex-row gap-2 items-center">
42-
<a href="https://chat.openai.com" target='_blank' rel="noreferrer"><ActionButton text={t('Login to ChatGPT')} /></a>
42+
<a href="https://chatgpt.com" target='_blank' rel="noreferrer"><ActionButton text={t('Login to ChatGPT')} /></a>
4343
<span className="text-sm text-primary-text">OR</span>
4444
<a
4545
onClick={() => setShowSettings(true)}
@@ -93,7 +93,7 @@ const ErrorAction: FC<{ error: ChatError }> = ({ error }) => {
9393
}
9494
if (error.code === ErrorCode.CHATGPT_AUTH) {
9595
return (
96-
<a href="https://chat.openai.com" target="_blank" rel="noreferrer">
96+
<a href="https://chatgpt.com" target="_blank" rel="noreferrer">
9797
<ActionButton text={t('Login to ChatGPT')} />
9898
</a>
9999
)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { FC } from 'react'
2+
import { useTranslation } from 'react-i18next'
3+
import {ClaudeAPIModel, OllamaAPIModel, UserConfig} from '~services/user-config'
4+
import { Input } from '../Input'
5+
import Select from '../Select'
6+
7+
interface Props {
8+
userConfig: UserConfig
9+
updateConfigValue: (update: Partial<UserConfig>) => void
10+
}
11+
12+
const OllamaAPISettings: FC<Props> = ({ userConfig, updateConfigValue }) => {
13+
const { t } = useTranslation()
14+
return (
15+
<div className="flex flex-col gap-2">
16+
<div className="flex flex-col gap-1">
17+
<p className="font-medium text-sm">API Host({t('Make sure your Ollama server has `export OLLAMA_ORIGINS="*"` configured')})</p>
18+
<Input
19+
className="w-[300px]"
20+
placeholder="http://xxxx:xxxx/api/chat"
21+
value={userConfig.ollamaApi}
22+
onChange={(e) => updateConfigValue({ ollamaApi: e.currentTarget.value })}
23+
type="input"
24+
/>
25+
</div>
26+
<div className="flex flex-col gap-1 w-[300px]">
27+
<p className="font-medium text-sm">{t('Model')}</p>
28+
<Select
29+
options={Object.entries(OllamaAPIModel).map(([k, v]) => ({ name: k, value: v }))}
30+
value={userConfig.ollamaModel}
31+
onChange={(v) => updateConfigValue({ ollamaModel: v })}
32+
/>
33+
</div>
34+
</div>
35+
)
36+
}
37+
38+
export default OllamaAPISettings

src/app/consts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export const CHATBOTS: Record<BotId, { name: string; avatar: string }> = {
7373
},
7474
}
7575

76-
export const CHATGPT_HOME_URL = 'https://chat.openai.com'
76+
export const CHATGPT_HOME_URL = 'https://chatgpt.com'
7777
export const CHATGPT_API_MODELS = ['gpt-3.5-turbo', 'gpt-4-turbo', 'gpt-4'] as const
7878
export const ALL_IN_ONE_PAGE_ID = 'all'
7979

src/services/user-config.ts

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ export enum BingConversationStyle {
1111

1212
export enum ChatGPTMode {
1313
Webapp = 'webapp',
14-
API = 'api',
15-
Azure = 'azure',
16-
Poe = 'poe',
17-
OpenRouter = 'openrouter',
14+
API = 'api'
1815
}
1916

2017
export enum ChatGPTWebModel {
@@ -35,16 +32,32 @@ export enum PoeClaudeModel {
3532

3633
export enum ClaudeMode {
3734
Webapp = 'webapp',
38-
API = 'api',
39-
Poe = 'poe',
40-
OpenRouter = 'openrouter',
35+
API = 'api'
4136
}
4237

4338
export enum ClaudeAPIModel {
44-
'claude-2' = 'claude-2',
45-
'claude-instant-1' = 'claude-instant-v1',
39+
'claude-instant-1' = 'claude-instant-1.2',
40+
'claude-2' = 'claude-2.1',
41+
'claude-3-sonnet' = 'claude-3-sonnet-20240229',
42+
'claude-3-opus' = 'claude-3-opus-20240229'
43+
}
44+
45+
export enum OllamaAPIModel {
46+
'Llama 3 8B ' = 'llama3',
47+
'Llama 3 70B' = 'llama3:70b',
48+
'Phi-3 3.8B ' = 'phi3',
49+
'Mistral 7B ' = 'mistral',
50+
'Neural Chat 7B ' = 'neural-chat',
51+
'Starling 7B ' = 'starling-lm',
52+
'Code Llama 7B ' = 'codellama',
53+
'Llama 2 Uncensored 7B ' = 'llama2-uncensored',
54+
'LLaVA 7B ' = 'llava',
55+
'Gemma 2B ' = 'gemma:2b',
56+
'Gemma 7B ' = 'gemma:7b',
57+
'Solar 10.7B' = 'solar'
4658
}
4759

60+
4861
export enum OpenRouterClaudeModel {
4962
'claude-2' = 'claude-2',
5063
'claude-instant-v1' = 'claude-instant-v1',
@@ -59,19 +72,20 @@ const userConfigWithDefaultValue = {
5972
chatgptMode: ChatGPTMode.Webapp,
6073
chatgptWebappModelName: ChatGPTWebModel['GPT-3.5'],
6174
chatgptPoeModelName: PoeGPTModel['GPT-3.5'],
62-
startupPage: "chatgpt",
6375
bingConversationStyle: BingConversationStyle.Balanced,
6476
poeModel: PoeClaudeModel['claude-instant'],
6577
azureOpenAIApiKey: '',
6678
azureOpenAIApiInstanceName: '',
6779
azureOpenAIApiDeploymentName: '',
68-
enabledBots: Object.keys(CHATBOTS).slice(0, 8) as BotId[],
80+
enabledBots: Object.keys(CHATBOTS) as BotId[],
6981
claudeApiKey: '',
70-
claudeMode: ClaudeMode.Poe,
82+
claudeMode: ClaudeMode.API,
7183
claudeApiModel: ClaudeAPIModel['claude-2'],
7284
openrouterOpenAIModel: CHATGPT_API_MODELS[0] as (typeof CHATGPT_API_MODELS)[number],
7385
openrouterClaudeModel: OpenRouterClaudeModel['claude-2'],
7486
openrouterApiKey: '',
87+
ollamaApi: 'http://localhost:11434/api/chat',
88+
ollamaModel: 'llama3'
7589
}
7690

7791
export type UserConfig = typeof userConfigWithDefaultValue
@@ -93,12 +107,6 @@ export async function getUserConfig(): Promise<UserConfig> {
93107
if (result.chatgptApiModel === 'gpt-3.5-turbo-16k') {
94108
result.chatgptApiModel = 'gpt-3.5-turbo'
95109
}
96-
if (
97-
result.claudeApiModel !== ClaudeAPIModel['claude-2'] ||
98-
result.claudeApiModel !== ClaudeAPIModel['claude-instant-1']
99-
) {
100-
result.claudeApiModel = ClaudeAPIModel['claude-2']
101-
}
102110
return defaults(result, userConfigWithDefaultValue)
103111
}
104112

0 commit comments

Comments
 (0)