Compare commits
5 Commits
55d8db1217
...
v2.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
1391f3f26f
|
|||
|
0f97ce61ef
|
|||
|
cb3abe33e9
|
|||
|
7130e8d163
|
|||
|
a35c392728
|
@@ -1,3 +1,3 @@
|
||||
const CHATGPT_API_WEB_VERSION = "v2.0.0";
|
||||
const CHATGPT_API_WEB_VERSION = "v2.1.0";
|
||||
|
||||
export default CHATGPT_API_WEB_VERSION;
|
||||
|
||||
@@ -651,14 +651,7 @@ export default function ChatBOX(props: {
|
||||
{Tr(
|
||||
"All chat history and settings are stored in the local browser"
|
||||
)}
|
||||
<br />⚠{Tr("Documents and source code are avaliable here")}:{" "}
|
||||
<a
|
||||
className="underline"
|
||||
href="https://github.com/heimoshuiyu/chatgpt-api-web"
|
||||
target="_blank"
|
||||
>
|
||||
github.com/heimoshuiyu/chatgpt-api-web
|
||||
</a>
|
||||
<br />
|
||||
</p>
|
||||
)}
|
||||
{chatStore.history.map((_, messageIndex) => (
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Tr, langCodeContext, LANG_OPTIONS } from "./translate";
|
||||
import { Tr, langCodeContext, LANG_OPTIONS, tr } from "./translate";
|
||||
import { useState, useEffect, StateUpdater } from "preact/hooks";
|
||||
import { ChatStore, ChatStoreMessage } from "./app";
|
||||
import { calculate_token_length, getMessageText } from "./chatgpt";
|
||||
@@ -44,6 +44,17 @@ export function EditMessage(props: EditMessageProps) {
|
||||
/>
|
||||
)}
|
||||
<div className={"w-full flex justify-center"}>
|
||||
{chatStore.develop_mode && <button
|
||||
className="w-full m-2 p-1 rounded bg-red-500"
|
||||
onClick={() => {
|
||||
if (typeof chat.content === "string") {
|
||||
chat.content = []
|
||||
} else {
|
||||
chat.content = ''
|
||||
}
|
||||
setChatStore({ ...chatStore })
|
||||
}}
|
||||
>Switch to {typeof chat.content === 'string' ? "media message" : "string message"}</button>}
|
||||
<button
|
||||
className={"w-full m-2 p-1 rounded bg-purple-500"}
|
||||
onClick={() => {
|
||||
|
||||
@@ -31,7 +31,6 @@ export function EditMessageString({
|
||||
/>
|
||||
</span>
|
||||
)}
|
||||
<hr className="my-2" />
|
||||
{chat.tool_calls &&
|
||||
chat.tool_calls.map((tool_call) => (
|
||||
<div className="flex flex-col w-full">
|
||||
@@ -79,28 +78,28 @@ export function EditMessageString({
|
||||
</button>
|
||||
</span>
|
||||
<hr className="my-2" />
|
||||
<span className="flex flex-col my-2 justify-between">
|
||||
<button
|
||||
className="bg-blue-300 text-black p-1 rounded"
|
||||
onClick={() => {
|
||||
if (!chat.tool_calls) return;
|
||||
chat.tool_calls.push({
|
||||
type: "function",
|
||||
index: chat.tool_calls.length,
|
||||
id: "",
|
||||
function: {
|
||||
name: "",
|
||||
arguments: "",
|
||||
},
|
||||
});
|
||||
setChatStore({ ...chatStore });
|
||||
}}
|
||||
>
|
||||
{Tr("Add a tool call")}
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
<span className="flex flex-col my-2 justify-between">
|
||||
<button
|
||||
className="bg-blue-300 text-black p-1 rounded"
|
||||
onClick={() => {
|
||||
if (!chat.tool_calls) return;
|
||||
chat.tool_calls.push({
|
||||
type: "function",
|
||||
index: chat.tool_calls.length,
|
||||
id: "",
|
||||
function: {
|
||||
name: "",
|
||||
arguments: "",
|
||||
},
|
||||
});
|
||||
setChatStore({ ...chatStore });
|
||||
}}
|
||||
>
|
||||
{Tr("Add a tool call")}
|
||||
</button>
|
||||
</span>
|
||||
<textarea
|
||||
className="rounded border border-gray-400 w-full h-32 my-2"
|
||||
value={chat.content}
|
||||
|
||||
19
src/main.tsx
19
src/main.tsx
@@ -4,10 +4,27 @@ import { useState, useEffect } from "preact/hooks";
|
||||
import { Tr, langCodeContext, LANG_OPTIONS } from "./translate";
|
||||
|
||||
function Base() {
|
||||
const [langCode, setLangCode] = useState("en-US");
|
||||
const [langCode, _setLangCode] = useState("en-US");
|
||||
|
||||
const setLangCode = (langCode: string) => {
|
||||
_setLangCode(langCode)
|
||||
if (!localStorage) return
|
||||
|
||||
localStorage.setItem('chatgpt-api-web-lang', langCode)
|
||||
}
|
||||
|
||||
// select language
|
||||
useEffect(() => {
|
||||
// query localStorage
|
||||
if (localStorage) {
|
||||
const lang = localStorage.getItem('chatgpt-api-web-lang')
|
||||
if (lang) {
|
||||
console.log(`query langCode ${lang} from localStorage`)
|
||||
_setLangCode(lang)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
const browserCode = window.navigator.language;
|
||||
for (const key in LANG_OPTIONS) {
|
||||
for (const i in LANG_OPTIONS[key].matches) {
|
||||
|
||||
@@ -776,6 +776,16 @@ export default (props: {
|
||||
chatgpt-api-web ChatStore {Tr("Version")}{" "}
|
||||
{props.chatStore.chatgpt_api_web_version}
|
||||
</p>
|
||||
<p>
|
||||
⚠{Tr("Documents and source code are avaliable here")}:{" "}
|
||||
<a
|
||||
className="underline"
|
||||
href="https://github.com/heimoshuiyu/chatgpt-api-web"
|
||||
target="_blank"
|
||||
>
|
||||
github.com/heimoshuiyu/chatgpt-api-web
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user