text
stringlengths
14
100k
source
stringclasses
1 value
repo
stringclasses
810 values
language
stringclasses
13 values
import tauriConfig from "../../src-tauri/tauri.conf.json"; import { DEFAULT_INPUT_TEMPLATE } from "../constant"; export const getBuildConfig = () => { if (typeof process === "undefined") { throw Error( "[Server Config] you are importing a nodejs-only module outside of nodejs", ); } const buildMode...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>import { BuildConfig, getBuildConfig } from "./build"; export function getClientConfig() { if (typeof document !== "undefined"<|fim_suffix|>{key}']`, ) as HTMLMetaElement; ret = meta?.content ?? ""; } else { ret = defaultValue ?? ""; } return ret; } <|fim_middle|>) { // client si...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|>nv.IFLYTEK_API_SECRET, isDeepSeek, deepseekUrl: process.env.DEEPSEEK_URL, deepseekApiKey: getApiKey(process.env.DEEPSEEK_API_KEY), isXAI, xaiUrl: process.env.XAI_URL, xaiApiKey: getApiKey(process.env.XAI_API_KEY), isChatGLM, chatglmUrl: process.env.CHATGLM_URL, chatg...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|>lowModels = [ "Qwen/Qwen2.5-7B-Instruct", "Qwen/Qwen2.5-72B-Instruct", "deepseek-ai/DeepSeek-R1", "deepseek-ai/DeepSeek-R1-Distill-Llama-70B", "deepseek-ai/DeepSeek-R1-Distill-Llama-8B", "deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B", "deepseek-ai/DeepSeek-R1-Distill-Qwen-14B", "deepseek-ai/D...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|> notification: { requestPermission(): Promise<Permission>; isPermissionGranted(): Promise<boolean>; sendNotification(options: string | Options): void; }; updater: { checkUpdate(): Promise<UpdateResult>; installUpdate(): Promise<void>; onUpdaterEvent( h...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|> </> )} </body> </html> ); } <|fim_prefix|>/* eslint-disable @next/next/no-page-custom-font */ import "./styles/globals.scss"; import "./styles/markdown.scss"; import "./styles/highlight.scss"; import { getClientConfig } from "./config/client"; import type { Metadata, Viewport ...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|>, int16Data); } }; this.source.connect(this.workletNode); this.source.connect(this.mergeNode, 0, 0); this.workletNode.connect(this.context.destination); this.workletNode.port.postMessage({ command: "START_RECORDING" }); } catch (error) { console.error("Err...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>import { SubmitKey } from "../store/config"; import type { PartialLocaleType } from "./index"; import { getClientConfig } from "../config/client"; import { SAAS_CHAT_UTM_URL } from "@/app/constant"; const isApp = !!getClientConfig()?.isApp; const ar: PartialLocaleType = { WIP: "قريبًا...", Error: { ...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>import { SubmitKey } from "../store/config"; import type { PartialLocaleType } from "./index"; import { getClientConfig } from "../config/client"; import { SAAS_CHAT_UTM_URL } from "@/app/constant"; const isApp = !!getClientConfig()?.isApp; const bn: PartialLocaleType = { WIP: "শীঘ্রই আসছে...", Error...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>import { getClientConfig } from "../config/client"; import { SubmitKey } from "../store/config"; import { SAAS_CHAT_UTM_URL } from "@/app/constant"; const isApp = !!getClientConfig()?.isApp; const cn = { WIP: "该功能仍在开发中……", Error: { Unauthorized: isApp ? `😆 对话遇到了一些问题,不用慌: \\ 1️⃣ 想要零...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>import { SubmitKey } from "../store/config"; import type { PartialLocaleType } from "./index"; import { getClientConfig } from "../config/client"; import { SAAS_CHAT_UTM_URL } from "@/app/constant"; const isApp = !!getClientConfig()?.isApp; const cs: PartialLocaleType = { WIP: "V přípravě...", Error:...
fim
ChatGPTNextWeb/NextChat
typescript
import { getClientConfig } from "../config/client"; import { SubmitKey } from "../store/config"; import { SAAS_CHAT_UTM_URL } from "@/app/constant"; import { PartialLocaleType } from "./index"; const isApp = !!getClientConfig()?.isApp; const da: PartialLocaleType = { WIP: "Der kommer snart mere...", Error: { U...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|>n wieder aktivieren.", Title: "Wählen Sie eine Maske aus", SubTitle: "Starten Sie jetzt und lassen Sie sich von den Gedanken hinter der Maske inspirieren", More: "Alle anzeigen", }, URLCommand: { Code: "Ein Zugangscode wurde im Link gefunden. Möchten Sie diesen automatisch einfü...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>import { getClientConfig } from "../config/client"; import { SubmitKey } from "../store/config"; import { LocaleType } from "./index"; import { SAAS_CHAT_UTM_URL } from "@/app/constant"; // if you are adding a new translation, please use PartialLocaleType instead of LocaleType const isApp = !!getClientCo...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|>óricos", SubTitle: "Cuando los mensajes históricos no comprimidos superan este valor, se realizará la compresión", }, Usage: { Title: "Consulta de saldo", SubTitle(used: any, total: any) { return `Saldo usado este mes: $${used}, total suscrito: $${total}`; ...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|>e superflu, sans gras. Si aucun sujet, retournez simplement « discussion informelle »", Summarize: "Faites un résumé succinct de la discussion, à utiliser comme prompt de contexte ultérieur, en moins de 200 mots", }, }, Copy: { Success: "Copié dans le presse-papiers", Failed:...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|>l kustom, pisahkan dengan koma", }, }, Model: "Model", CompressModel: { Title: "Model Kompresi", SubTitle: "Model yang digunakan untuk mengompres riwayat", }, Temperature: { Title: "Randomness (temperature)", SubTitle: "Semakin tinggi nilainya, semakin ac...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>import cn from "./cn"; import en from "./en"; import pt from "./pt"; import tw from "./tw"; import da from "./da"; import id from "./id"; import fr from "./fr"; import es from "./es"; import it from "./it"; import tr from "./tr"; import jp from "./jp"; import de from "./de"; import vi from "./vi"; import ...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>import { SubmitKey } from "../store/config"; import type { PartialLocaleType } from "./index"; import { getClientConfig } from "../config/client"; import { SAAS_CHAT_UTM_URL } from "@/app/constant"; const isApp = !!getClientConfig()?.isApp; const it: PartialLocaleType = { WIP: "Work in progress...", ...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>import { SubmitKey } from "../store/config"; import type { PartialLocaleType } from "./index"; import { getClientConfig } from "../config/client"; import { SAAS_CHAT_UTM_URL } from "@/app/constant"; const isApp = !!getClientConfig()?.isApp; const jp: PartialLocaleType = { WIP: "この機能は開発中です", Error: { ...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|>, 클립보드 권한을 부여해주세요.", }, Download: { Success: "내용이 디렉토리에 다운로드되었습니다.", Failed: "다운로드 실패.", }, Context: { Toast: (x: any) => ` ${x} 개의 프리셋 프롬프트 포함됨`, Edit: "현재 대화 설정", Add: "대화 추가", Clear: "컨텍스트가 지워졌습니다.", Revert: "컨텍스트 복원", }, Discovery: { Name: "디스커버리", }, Mc...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>import { SubmitKey } from "../store/config"; import type { PartialLocaleType } from "./index"; import { getClientConfig } from "../config/client"; import { SAAS_CHAT_UTM_URL } from "@/app/constant"; const isApp = !!getClientConfig()?.isApp; const no: PartialLocaleType = { WIP: "Arbeid pågår ...", Err...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|>s`, }, Item: { View: "Ver", }, }, Mask: { Name: "Máscara", Page: { Title: "Template de Prompt", SubTitle: (count: number) => `${count} templates de prompt`, Search: "Buscar Templates", Create: "Criar", }, Item: { Info: (count: number) => ...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|> ApiKey: { Title: "API-ключ", SubTitle: "Использовать пользовательский Baidu API-ключ", Placeholder: "Baidu API-ключ", }, SecretKey: { Title: "Секретный ключ", SubTitle: "Использовать пользовательский Baidu Secret Key", Placeh...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>import { getClientConfig } from "../config/client"; import { SubmitKey } from "../store/config"; import type { PartialLocaleType } from "./index"; import { SAAS_CHAT_UTM_URL } from "@/app/constant"; // if you are adding a new translation, please use PartialLocaleType instead of LocaleType const isApp = !...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|>inize emin misiniz?", }, Home: { NewChat: "Yeni sohbet", DeleteChat: "Seçilen sohbeti silmek istediğinize emin misiniz?", DeleteToast: "Sohbet silindi", Revert: "Geri al", }, Settings: { Title: "Ayarlar", SubTitle: "Tüm ayar seçenekleri", Danger: { Reset: { ...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>import { getClientConfig } from "../config/client"; import { SubmitKey } from "../store/config"; import { SAAS_CHAT_UTM_URL } from "@/app/constant"; const isApp = !!getClientConfig()?.isApp; const tw = { WIP: "此功能仍在開發中……", Error: { Unauthorized: isApp ? `😆 對話遇到了一些問題,不用慌: \\ 1️⃣ 想要無須設定開...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|>ên kết, có tự động điền không?", }, UI: { Confirm: "Xác nhận", Cancel: "Hủy", Close: "Đóng", Create: "Tạo mới", Edit: "Chỉnh sửa", Export: "Xuất", Import: "Nhập", Sync: "Đồng bộ", Config: "Cấu hình", }, Exporter: { Description: { Title: "Chỉ tin nhắn ...
fim
ChatGPTNextWeb/NextChat
typescript
import fs from "fs"; import path from "path"; import { CN_MASKS } from "./cn"; import { TW_MASKS } from "./tw"; import { EN_MASKS } from "./en"; import { type BuiltinMask } from "./typing"; const BUILTIN_MASKS: Record<string, BuiltinMask[]> = { cn: CN_MASKS, tw: TW_MASKS, en: EN_MASKS, }; const dirname = path....
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>import { BuiltinMask } from "./typing"; export const CN_MASKS: BuiltinMask[] = [ { avatar: "1f5bc-fe0f", name: "AI文生图", context: [ { id: "text-to-pic-0", role: "system", content: "You are a useful Assistant that won't refuse to draw picture, instead, ...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|> "en", builtin: true, createdAt: 1688899480410, }, { avatar: "1f916", name: "Prompt Improvement", context: [ { id: "prompt-improve-0", role: "user", content: 'Read all of the instructions below and once you understand them say "Shall we begin...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|> }; }) .then((masks) => { const { cn = [], tw = [], en = [] } = masks; return [...cn, ...tw, ...en].map((m) => { BUILTIN_MASKS.push(BUILTIN_MASK_STORE.add(m)); }); }); } <|fim_prefix|>import { Mask } from "../store/mask"; import { type BuiltinMask } from "./typing"; ...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>import { BuiltinMask } from "./typing"; export const TW_MASKS: BuiltinMask[] = [ { avatar: "1f5bc-fe0f", name: "以文搜圖", context: [ { id: "text-to-pic-0", role: "system", content: "You are a useful Assistant that won't refuse to draw picture, instead, y...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|>onfig>; }; <|fim_prefix|>import { ModelConfig } from "../store"; import { type Mask } from "../store/mask"; export type BuiltinMask = Omit<Mask, "id" | "modelConfig"> & { builtin: Boolean; <|fim_middle|>modelConfig: Partial<ModelC<|endoftext|>
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|> const configStr = await fs.readFile(CONFIG_PATH, "utf-8"); return JSON.parse(configStr); } catch (error) { logger.error(`Failed to load MCP config, using default config: ${error}`); return DEFAULT_MCP_CONFIG; } } // 更新 MCP 配置文件 async function updateMcpConfig(config: McpConfigData): Promi...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>import { Client } from "@modelcontextprotocol/sdk/client/index.js"; import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js"; import { MCPClientLogger } from "./logger"; import { ListToolsResponse, McpRequestMessage, ServerConfig } from "./types"; import { z } from "zod"; const lo...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|> info(message: any) { this.print(colors.blue, message); } success(message: any) { this.print(colors.green, message); } error(message: any) { this.print(colors.red, message); } warn(message: any) { this.print(colors.yellow, message); } debug(message: any) { if (th...
fim
ChatGPTNextWeb/NextChat
typescript
// ref: https://spec.modelcontextprotocol.io/specification/basic/messages/ import { z } from "zod"; import { Client } from "@modelcontextprotocol/sdk/client/index.js"; export interface McpRequestMessage { jsonrpc?: "2.0"; id?: string | number; method: "tools/call" | string; params?: { [key: string]: unkno...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>export function isMcpJson(content: string) { return content.match(/```json:mcp:([^{\s]<|fim_suffix|> } return null; } <|fim_middle|>+)([\s\S]*?)```/); } export function extractMcpJson(content: string) { const match = content.match(/```json:mcp:([^{\s]+)([\s\S]*?)```/); if (match && match.length =...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>import { Analytics } from "@vercel/analytics/react"; import { Home } from "./component<|fim_suffix|>deConfig } from "./config/server"; const serverConfig = getServerSideConfig(); export default async function App() { return ( <> <Home /> {serverConfig?.isVercel && ( <> ...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|> // Use Array.prototype.slice method to get value at the specified index return Array.prototype.slice.call(this, index, index + 1)[0]; }; } export {}; <|fim_prefix|>declare global { interface Array<T> { at(index: number): T | undefined; } } if (!Array.prototype<|fim_middle|>.at) { Array....
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>import { GoogleSafetySettingsThreshold, ServiceProvider, StoreKey, ApiPath, OPENAI_BASE_URL, ANTHROPIC_BASE_URL, GEMINI_BASE_URL, BAIDU_BASE_URL, BYTEDANCE_BASE_URL, ALIBABA_BASE_URL, TENCENT_BASE_URL, MOONSHOT_BASE_URL, STABILITY_BASE_URL, IFLYTEK_BASE_URL, DEEPSEEK_BASE_URL...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>import { getMessageTextContent, isDalle3, safeLocalStorage, trimTopic, } from "../utils"; import { indexedDBStorage } from "@/app/utils/indexedDB-storage"; import { nanoid } from "nanoid"; import type { ClientApi, MultimodalContent, RequestMessage, } from "../client/api"; import { getClient...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>import { LLMModel } from "../client/api"; import { DalleQuality, DalleStyle, ModelSize } from "../typing"; import { getClientConfig } from "../config/client"; import { DEFAULT_INPUT_TEMPLATE, DEFAULT_MODELS, DEFAULT_SIDEBAR_WIDTH, DEFAULT_TTS_ENGINE, DEFAULT_TTS_ENGINES, DEFAULT_TTS_MODEL, D...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|>rom "./plugin"; <|fim_prefix|>export * from "./chat"; export * from "./update"; export * from "./access"; export * from<|fim_middle|> "./config"; export * f<|endoftext|>
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|>(language: Lang | undefined) { set({ language, }); }, }), { name: StoreKey.Mask, version: 3.1, migrate(state, version) { const newState = JSON.parse(JSON.stringify(state)) as MaskState; // migrate mask id to nanoid if (version < 3) { Obje...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>import OpenAPIClientAxios from "openapi-client-axios"; import { StoreKey } from "../constant"; import { nanoid } from "nanoid"; import { createPersistStore } from "../utils/store"; import { getClientConfig } from "../config/client"; import yaml from "js-yaml"; import { adapter, getOperationId } from "../u...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|>wState = JSON.parse(JSON.stringify(state)) as { prompts: Record<string, Prompt>; }; if (version < 3) { Object.values(newState.prompts).forEach((p) => (p.id = nanoid())); } return newState as any; }, onRehydrateStorage(state) { // Skip store rehydrat...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>import { Stability, StoreKey, ACCESS_CODE_PREFIX, ApiPath, } from "@/app/constant"; import { getBearerToken } from "@/app/client/api"; import { createPersistStore } from "@/app/utils/store"; import { nanoid } from "nanoid"; import { uploadImage, base64Image2Blob } from "@/app/utils/chat"; import {...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|>.stringify(localState)); console.log( "[Sync] Remote state is empty, using local state instead.", ); return; } else { const parsedRemoteState = JSON.parse( await client.get(config.username), ) as AppState; mergeApp...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|>IT_URL)).json()) as { commit: { author: { name: string; date: string }; }; sha: string; }[]; const remoteCommitTime = data[0].commit.author.date; const remoteId = new Date(remoteCommitTime).getTime().toString(); return remoteId; } else if (type === "tag") { ...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|>port type DalleSize = "1024x1024" | "1792x1024" | "1024x1792"; export type DalleQuality = "standard" | "hd"; export type DalleStyle = "vivid" | "natural"; export type ModelSize = | "1024x1024" | "1792x1024" | "1024x1792" | "768x1344" | "864x1152" | "1344x768" | "1152x864" | "1440x720" |...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|>erSourceNode.disconnect(); } const buffer = await audioContext!.decodeAudioData(audioBuffer); audioBufferSourceNode = audioContext!.createBufferSource(); audioBufferSourceNode.buffer = buffer; audioBufferSourceNode.connect(audioContext!.destination); audioContext!.resume().then(()...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|>alue: 1 }); } <|fim_prefix|>import { sendGAEvent }<|fim_middle|> from "@next/third-parties/google"; export function trackConversationGuideToCPaymentClick() { sendGAEvent("event", "ConversationGuideToCPaymentClick", { value: 1 }); } export function trackAuthorizationPageButtonToCPaymentClick() { send...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>import { BAIDU_OATUH_URL } from "../constant"; /** * 使用 AK,SK 生成鉴权签名(Access Token) * @return 鉴权签名信息 */ export async function getAccessToken( clientId: string, clientSecret: string, ): Promise<{ access_token: string; expires_in: number; error?: number; }> { const res = await fetch( `${BA...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|>ing !== chunk.isThinking; lastIsThinking = chunk.isThinking; if (chunk.isThinking) { // If in thinking mode if (!isInThinkingMode || isThinkingChanged) { // If this is a new thinking block or mode changed, add prefix isInThinkingMode...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>export functi<|fim_suffix|>== undefined && obj[k] !== null && obj[k] !== "", ); } <|fim_middle|>on deepClone<T>(obj: T) { return JSON.parse(JSON.stringify(obj)); } export function ensure<T extends object>( obj: T, keys: Array<[keyof T][number]>, ) { return keys.every( (k) => obj[k] !<|endof...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>import { createWebDavClient } from "./webdav"; import { createUpstashClient } from "./upstash"; export enum ProviderType { WebDAV = "webdav", UpStash = "upstash", } export const SyncClients = { [ProviderType.UpStash]: createUpstashClient, [ProviderType.WebDAV]: createWebDavClient, } as const; t...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>import { STORAGE_KEY } from "@/app/constant"; import { SyncStore } from "@/app/store/sync"; import { chunks } from "../format"; export type UpstashConfig = SyncStore["upstash"]; export type UpStashClient = ReturnType<typeof createUpstashClient>; export function createUpstashClient(store: SyncStore) { ...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|>eaders: this.headers(), }); console.log("[WebDav] get key = ", key, res.status, res.statusText); if (404 == res.status) { return ""; } return await res.text(); }, async set(key: string, value: string) { const res = await fetch(this.path(fileName, pro...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|>udflare.com/v1/{account_id}/{gateway_id}/openai/chat/completions if ("openai" == paths[6]) { // is openai gateway return paths.slice(0, 7).concat(paths.slice(-2)).join("/"); // rebuild ai gateway openai_url } // https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/anthrop...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>export function prettyObject(msg: any) { const obj = msg; if (typeof msg !== "string") { msg = JSON.stringify(msg, null, " "); } if (msg === "{}") { return obj.toString(); } if (msg.startsWith("```json")) { return msg; } return ["```json", msg, "```"].join("\n"); } export fun...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|>else { const gamma0x = M[round - 15]; const gamma1x = M[round - 2]; MRound = M[round - 7] + M[round - 16] + (rightRotate(gamma0x, 7) ^ rightRotate(gamma0x, 18) ^ (gamma0x >>> 3)) + (rightRotate(gamma1x, 17) ^ ...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|>aultModel( configStore.models, [configStore.customModels, accessStore.customModels].join(","), accessStore.defaultModel, ); }, [ accessStore.customModels, accessStore.defaultModel, configStore.customModels, configStore.models, ]); return models; } <|fim_prefix|...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|>ed) { console.warn("skip setItem", name); return; } await set(name, value); } catch (error) { localStorage.setItem(name, value); } } public async removeItem(name: string): Promise<void> { try { await del(name); } catch (error) { localStora...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|>perty is not inherited source[key] && typeof source[key] === "object" || key === "__proto__" || key === "constructor" ) { merge((target[key] = target[key] || {}), source[key]); return; } target[key] = source[key]; }); } <|fim_prefix|>export function merge(target: any,...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|>.startsWith("gpt-4o-mini") ); } /** * Checks if a model is not available on any of the specified providers in the server. * * @param {string} customModels - A string of custom models, comma-separated. * @param {string} modelName - The name of the model to check. * @param {string|string[]} provider...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>// import axios from "axios"; import { Buffer } from "buffer"; import { randomBytes } from "crypto"; import { Readable } from "stream"; // Modified according to https://github.com/Migushthe2nd/MsEdgeTTS /** * https://learn.microsoft.com/en-us/azure/ai-services/speech-service/speech-synthesis-markup-voi...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>export function omit<T extends object, U extends (keyo<|fim_suffix|>orEach((key) => delete ret[key]); return ret; } export function pick<T extends object, U extends (keyof T)[]>( obj: T, ...keys: U ): Pick<T, U[number]> { const ret: any = {}; keys.forEach((key) => (ret[key] = obj[key])); retu...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>import { create } from "zustand"; import { combine, persist, createJSONStorage } from "zustand/mid<|fim_suffix|>te: T) => T | Partial<T>), replace?: boolean | undefined, ) => void; export function createPersistStore<T extends object, M>( state: T, methods: ( set: SetStoreState<T & MakeUpdater<T...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>// using tauri command to send request // see src-tauri/src/stream.rs, and src-tauri/src/main.rs // 1. invoke('stream_fetch', {url, method, headers, body}), get response with headers. // 2. listen event: `stream-response` multi times to get body type ResponseEvent = { id: number; payload: { reque...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|> } else { // if both have the same session id, merge the messages const localMessageIds = new Set(localSession.messages.map((v) => v.id)); remoteSession.messages.forEach((m) => { if (!localMessageIds.has(m.id)) { localSession.messages.push(m); ...
fim
ChatGPTNextWeb/NextChat
typescript
import { sign, hash as getHash, hex } from "./hmac"; // 使用 SHA-256 和 secret 进行 HMAC 加密 function sha256(message: any, secret: any, encoding?: string) { const result = sign(secret, message); return encoding == "hex" ? hex(result).toString() : result; } function getDate(timestamp: number) { const date = new Date(t...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>export function estimateTokenLength(input: string): number { let tokenLength = 0; for (let i = 0; i < input.length; i++) { const charCode = input.charCodeAt(i); if (charCode < 128) { // ASCII character<|fim_suffix|> tokenLength += 1.5; } } return tokenLength; } <|fim_middle...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>import { useEffect, useState } from "react"; import { showToast } from "./components/ui-lib"; import Locale from "./locales"; import { RequestMessage } from "./client/api"; import { REQUEST_TIMEOUT_MS, REQUEST_TIMEOUT_MS_FOR_THINKING, ServiceProvider, } from "./constant"; // import { fetch as tauriF...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|>oad the Next.js config which is async export default createJestConfig(config); <|fim_prefix|>import type { Config } from "jest"; import nextJest from "next/jest.js"; const createJestConfig = nextJest({ // Provide the path to your Next.js app to load next.config.js and .env files in your test environmen...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|>[]), headers: new Headers(), redirected: false, statusText: "OK", type: "basic", url: "", body: null, bodyUsed: false, arrayBuffer: () => Promise.resolve(new ArrayBuffer(0)), blob: () => Promise.resolve(new Blob()), formData: () => Promise.resolve(new FormData()), ...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|>n: "https://generativelanguage.googleapis.com/:path*", }, { source: "/api/proxy/openai/:path*", destination: "https://api.openai.com/:path*", }, { source: "/api/proxy/anthropic/:path*", destination: "https://api.anthropic.com/:path*", }, ...
fim
ChatGPTNextWeb/NextChat
javascript
<|fim_prefix|>// @ts-nocheck class AudioRecorderProcessor extends AudioWorkletProcessor { constructor() { super(); this.isRecording = false; this.bufferSize = 2400; // 100ms at 24kHz this.currentBuffer = []; this.port.onmessage = (event) => { if (event.data.command === "START_RECORDING") { ...
fim
ChatGPTNextWeb/NextChat
javascript
<|fim_prefix|>const CHATGPT_NEXT_WEB_CACHE = "chatgpt-next-web-cache"; const CHATGPT_NEXT_WEB_FILE_CACHE = "chatgpt-next-web-file"; let a="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let nanoid=(e=21)=>{let t="",r=crypto.getRandomValues(new Uint8Array(e));for(let n=0;n<e;n++)t+=a[63&r[n]];return t...
fim
ChatGPTNextWeb/NextChat
javascript
<|fim_prefix|>if ('serviceWorker' in navigator) { window.addEventListener('DOMContentLoaded', function () { navigator.serviceWorker.register('/serviceWorker.js').then(function (registration) { console.log('ServiceWorker registration successful with scope: ', registration.scope); const sw = registratio...
fim
ChatGPTNextWeb/NextChat
javascript
<|fim_suffix|>> { fs.writeFile(FILE, JSON.stringify({ cn, tw, en })); }) .catch((e) => { console.error("[Fetch] failed to fetch prompts"); fs.writeFile(FILE, JSON.stringify({ cn: [], tw: [], en: [] })); }) .finally(() => { console.log("[Fetch] saved to " + FILE); }); } main(...
fim
ChatGPTNextWeb/NextChat
javascript
<|fim_prefix|>fn main() { tauri_build::build(<|fim_suffix|><|fim_middle|>) } <|endoftext|>
fim
ChatGPTNextWeb/NextChat
rust
<|fim_suffix|>r(not(debug_assertions), windows_subsystem = "windows")] mod stream; fn main() { tauri::Builder::default() .invoke_handler(tauri::generate_handler![stream::stream_fetch]) .plugin(tauri_plugin_window_state::Builder::default().build()) .run(tauri::generate_context!()) .expect("error whil...
fim
ChatGPTNextWeb/NextChat
rust
<|fim_prefix|>// // use std::time::Duration; use std::error::Error; use std::sync::atomic::{AtomicU32, Ordering}; use std::collections::HashMap; use futures_util::{StreamExt}; use reqwest::Client; use reqwest::header::{HeaderName, HeaderMap}; static REQUEST_COUNTER: AtomicU32 = AtomicU32::new(0); #[derive(Debug, Clo...
fim
ChatGPTNextWeb/NextChat
rust
<|fim_prefix|>import { isModelNotavailableInServer } from "../app/utils/model"; describe("isModelNotavailableInServer", () => { test("test model will return false, which means the model is available", () => { const customModels = ""; const modelName = "gpt-4"; const providerNames = "OpenAI"; const re...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>import { getModelProvider } from "../app/utils/model"; describe("getModelProvider", () => { test("should return model and provider when input contains '@'", () => { const input = "model@provider"; const [model, provider] = getModelProvider(input); expect(model).toBe("model")<|fim_suffix|>in...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_prefix|>function sum(a: number, b: number) { return a + b; } describe("sum module", () => { test("adds 1 + <|fim_suffix|> expect(sum(1, 2)).toBe(3); }); }); <|fim_middle|>2 to equal 3", () => {<|endoftext|>
fim
ChatGPTNextWeb/NextChat
typescript
import { jest } from "@jest/globals"; import { isVisionModel } from "../app/utils"; describe("isVisionModel", () => { const originalEnv = process.env; beforeEach(() => { jest.resetModules(); process.env = { ...originalEnv }; }); afterEach(() => { process.env = originalEnv; }); test("should i...
fim
ChatGPTNextWeb/NextChat
typescript
<|fim_suffix|>eName = Path.GetFileName source let dest = Path.Combine(dest, fileName) if not isForced && File.Exists dest then writeError "destination file already exists" else if File.Exists dest then File.Delete dest ...
fim
ChrisPritchard/FSH
fsharp
<|fim_prefix|>/// Com<|fim_suffix|>ConsoleColor.Red let command = ConsoleColor.Yellow let argument = ConsoleColor.Gray let code = ConsoleColor.Cyan let pipe = ConsoleColor.Green let neutral = ConsoleColor.Gray /// Sets the console foreground to the specified colour. /// Intended to be used with t...
fim
ChrisPritchard/FSH
fsharp
<|fim_suffix|>to run a process that doesn't exist. // But running something you don't have rights too will also throw this. apply Colours.errorOutput printfn "%s: %s" fileName ex.Message // Hide the cursor. Console.CursorVisible <- false /// Attempts to run an ex...
fim
ChrisPritchard/FSH
fsharp
<|fim_prefix|>/// Wrappers for F# Interactive, making it a little easier/consistent to use from the rest of FSH. /// Contains one primary class, Fsi. module Interactive open Microsoft.FSharp.Compiler.Interactive.Shell open System.IO /// This class instantiates the FSI instance, along with hidden reader/writer stream...
fim
ChrisPritchard/FSH
fsharp
<|fim_prefix|>/// Methods for parsing a line of input into its constituent tokens and parts. /// Parts operates on a raw string, breaking it into logical chunks. /// Tokens takes these chunks, and groups them into process-able tokens. module LineParser open System open Model open Common /// Folds the given string li...
fim
ChrisPritchard/FSH
fsharp
<|fim_suffix|> soFar // Enter with shift/control/alt pressed adds a new line, aligned with the prompt position. | ConsoleKey.Enter -> reader priorIndex (soFar + newline) 0 | ConsoleKey.Backspace when Console.CursorLeft <> startPos -> let relPos = lastLineStart soFa...
fim
ChrisPritchard/FSH
fsharp
/// In this module is the print formatted method, which prints a line of text in its coloured, multi-line form to the output. /// This is used by the LineReader module, re-writing the current line to the Console out every time a character is read. module LineWriter open System open Model open Common open LineParser ...
fim
ChrisPritchard/FSH
fsharp
<|fim_prefix|>/// FSH has very little need for its own types, as its largely about translating user input into direct actions. /// However, where custom types are needed they are defined here, along with closely related methods. module Model open System.Text /// Token is a DU used to tag parts of a read input. /// I...
fim
ChrisPritchard/FSH
fsharp
<|fim_prefix|>/// The core shell loop is defined and run here. /// It prompts the user for input, then processes the result before repeating. /// In addition, some ancillary functions like process launching are also defined. open System open System.IO open Common open Model open Builtins open LineParser open LineRead...
fim
ChrisPritchard/FSH
fsharp
<|fim_prefix|>module LineParser.Parts open FsUnit open FsUnit.Xunit open Xunit [<Fact>] let ``Parts parses blank as blank`` () = let result = parts "" result |> should be Empty [<Fact>] let ``Parts parses single as single`` () = let result = parts "test" result |> should equal ["test"] [<Fact>] let...
fim
ChrisPritchard/FSH
fsharp
<|fim_suffix|> result |> should equal [Command ("test", [])] [<Fact>] let ``Tokens parses a command with args`` () = let result = tokens ["test";"a1";"a2"] result |> should equal [Command ("test", ["a1";"a2"])] [<Fact>] let ``Tokens parses code into a pipe into code`` () = let result = tokens ["(10)...
fim
ChrisPritchard/FSH
fsharp