5 Commits

Author SHA1 Message Date
1391f3f26f v2.1.0 2024-01-30 10:41:13 +08:00
0f97ce61ef move source code link to settings 2024-01-30 10:22:45 +08:00
cb3abe33e9 langCode from localStorage 2024-01-30 10:19:08 +08:00
7130e8d163 change message type 2024-01-30 10:09:36 +08:00
a35c392728 fix: hide "add a tool call" 2024-01-30 10:01:51 +08:00
6 changed files with 62 additions and 32 deletions

View File

@@ -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;

View File

@@ -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) => (

View File

@@ -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={() => {

View File

@@ -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}

View File

@@ -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) {

View File

@@ -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>