text stringlengths 14 100k | source stringclasses 1
value | repo stringclasses 810
values | language stringclasses 13
values |
|---|---|---|---|
<|fim_suffix|>httpProxyCache;
}
private static final class UiListenerHandler extends Handler implements CacheListener {
private final String url;
private final List<CacheListener> listeners;
public UiListenerHandler(String url, List<CacheListener> listeners) {
super(Looper... | fim | CarGuo/GSYVideoPlayer | java |
<|fim_prefix|>package com.danikula.videocache;
import static com.danikula.videocache.Preconditions.checkNotNull;
import static com.danikula.videocache.ProxyCacheUtils.DEFAULT_BUFFER_SIZE;
import static java.net.HttpURLConnection.HTTP_MOVED_PERM;
import static java.net.HttpURLConnection.HTTP_MOVED_TEMP;
import static j... | fim | CarGuo/GSYVideoPlayer | java |
<|fim_suffix|>ProxySelector(ProxySelector defaultProxySelector, String hostToIgnore, int portToIgnore) {
this.defaultProxySelector = checkNotNull(defaultProxySelector);
this.hostToIgnore = checkNotNull(hostToIgnore);
this.portToIgnore = portToIgnore;
}
static void install(String hostToI... | fim | CarGuo/GSYVideoPlayer | java |
<|fim_prefix|>package com.danikula.videocache;
/**
* Indicates int<|fim_suffix|>ause) {
super(cause);
}
}
<|fim_middle|>erruption error in work of {@link ProxyCache} fired by user.
*
* @author Alexey Danilov
*/
public class InterruptedProxyCacheException extends ProxyCacheException {
public Interr... | fim | CarGuo/GSYVideoPlayer | java |
<|fim_suffix|>rce.open(0);
byte[] response = new byte[expectedResponse.length];
source.read(response);
boolean pingOk = Arrays.equals(expectedResponse, response);
HttpProxyCacheDebuger.printfLog("Ping response: `" + new String(response) + "`, pinged? " + pingOk);
... | fim | CarGuo/GSYVideoPlayer | java |
<|fim_prefix|>package com.danikula.videocache;
public final class Preconditions {
public static <T> T checkNotNull(T reference) {
if (reference == null) {
throw new NullPointerException();
}
return reference;
}
public static void checkAllNotNull(Object... references) {... | fim | CarGuo/GSYVideoPlayer | java |
<|fim_prefix|>package com.danikula.videocache;
import static com.danikula.vide<|fim_suffix|> if (errorsCount >= MAX_READ_SOURCE_ATTEMPTS) {
readSourceErrorsCount.set(0);
throw new ProxyCacheException("Error reading source " + errorsCount + " times");
}
}
public void shutdown()... | fim | CarGuo/GSYVideoPlayer | java |
<|fim_prefix|>package com.danikula.videocache;<|fim_suffix|> error in work of {@link ProxyCache}.
*
* @author Alexey Danilov
*/
public class ProxyCacheException extends Exception {
public ProxyCacheException(String message) {
super(message + BuildConfig.LIBRARY_VERSION);
}
public ProxyCacheExce... | fim | CarGuo/GSYVideoPlayer | java |
<|fim_suffix|>b : bytes) {
sb.append(String.format("%02x", b));
}
return sb.toString();
}
}
<|fim_prefix|>package com.danikula.videocache;
import static com.danikula.videocache.Preconditions.checkArgument;
import static com.danikula.videocache.Preconditions.checkNotNull;
import android... | fim | CarGuo/GSYVideoPlayer | java |
<|fim_prefix|>package com.danikula.videocache;
/**
* Source for proxy.
*
* @author Alexey Danilov (danikula@gmail.com).
*/
public interface Source {
/**
* Opens source. Source s<|fim_suffix|>ngth is unknown.
*
* @return bytes length
* @throws ProxyCacheException if error occur while fetchi... | fim | CarGuo/GSYVideoPlayer | java |
package com.danikula.videocache;
import androidx.annotation.NonNull;
/**
* Stores source's info.
*
* @author Alexey Danilov (danikula@gmail.com).
*/
public class SourceInfo {
public final String url;
public final long length;
public final String mime;
public SourceInfo(String url, long length, S... | fim | CarGuo/GSYVideoPlayer | java |
<|fim_suffix|>dividual application cache directory (for only video caching from Proxy). Cache directory will be
* created on SD card <i>("/Android/data/[app_package_name]/cache/video-cache")</i> if card is mounted .
* Else - Android defines cache directory on device's file system.
*
* @param context... | fim | CarGuo/GSYVideoPlayer | java |
<|fim_suffix|>r Alexey Danilov (danikula@gmail.com).
*/
public interface DiskUsage {
void touch(File file) throws IOException;
}
<|fim_prefix|>package com.danikula.videocache.file;
import java.io.File;
import<|fim_middle|> java.io.IOException;
/**
* Declares how {@link FileCache} will use disc space.
*
* @a... | fim | CarGuo/GSYVideoPlayer | java |
<|fim_prefix|>package com.danikula.videocache.file;
import com.danikula.videocache.Cache;
import com.danikula.videocache.ProxyCacheException;
import j<|fim_suffix|> constructor as some temp file for not completed cache.
*
* @return file for caching.
*/
public File getFile() {
return file;
... | fim | CarGuo/GSYVideoPlayer | java |
<|fim_suffix|>Generator {
String generate(String url);
}
<|fim_prefix|>package com.danikula.videocache.file;
/**
* Generator for files to be used for caching.
*
* @author Alexey Danilov (danikula@gmail.com).
*/
publ<|fim_middle|>ic interface FileName<|endoftext|> | fim | CarGuo/GSYVideoPlayer | java |
package com.danikula.videocache.file;
import com.danikula.videocache.HttpProxyCacheDebuger;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.LinkedList;
import j... | fim | CarGuo/GSYVideoPlayer | java |
<|fim_suffix|> touchInBackground(file);
return null;
}
}
}
<|fim_prefix|>package com.danikula.videocache.file;
import com.danikula.videocache.HttpProxyCacheDebuger;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.Callable;
import java.util... | fim | CarGuo/GSYVideoPlayer | java |
<|fim_prefix|>package com.danikula.videocache<|fim_suffix|>;
return dotIndex != -1 && dotIndex > slashIndex && dotIndex + 2 + MAX_EXTENSION_LENGTH > url.length() ?
url.substring(dotIndex + 1) : "";
}
}
<|fim_middle|>.file;
import android.text.TextUtils;
import com.danikula.videocache.ProxyCach... | fim | CarGuo/GSYVideoPlayer | java |
<|fim_suffix|>otalCount <= maxCount;
}
}
<|fim_prefix|>package com.danikula.videocache.file;
import java.io.File;
/**
* {@link DiskUsage} that uses LRU (Least Rec<|fim_middle|>ently Used) strategy and trims cache size to max files count if needed.
*
* @author Alexey Danilov (danikula@gmail.com).
*/
public cla... | fim | CarGuo/GSYVideoPlayer | java |
<|fim_suffix|>nt totalCount) {
return totalSize <= maxSize;
}
}
<|fim_prefix|>package com.danikula.videocache.file;
import java.io.File;
/**
* {@link DiskUsage} that uses LRU (Least Recently Used) strategy a<|fim_middle|>nd trims cache size to max size if needed.
*
* @author Alexey Danilov (danikula@gm... | fim | CarGuo/GSYVideoPlayer | java |
<|fim_suffix|>*
* @author Alexey Danilov (danikula@gmail.com).
*/
public class UnlimitedDiskUsage implements DiskUsage {
@Override
public void touch(File file) throws IOException {
// do nothing
}
}
<|fim_prefix|>package com.danikula.videocache.file;
import jav<|fim_middle|>a.io.File;
import jav... | fim | CarGuo/GSYVideoPlayer | java |
<|fim_prefix|>package com.danikula.videocache.headers;
import java.util.HashMap;
import java.util.Map;
/**
* Empty {@l<|fim_suffix|>ublic Map<String, String> addHeaders(String url) {
return new HashMap<>();
}
}
<|fim_middle|>ink HeaderInjector} implementation.
*
* @author Lucas Nelaupe (https://github... | fim | CarGuo/GSYVideoPlayer | java |
<|fim_prefix|>package com.danikula.videocache.headers;
import java.util.Map;
/**
* Allows to add custom headers to server's requests.
*
* @author Lucas Nelaupe (https://github.com/lucas34).
*/
public interface HeaderInjector {
/**
* Adds headers to server's requests for corresponding url.
*
* ... | fim | CarGuo/GSYVideoPlayer | java |
<|fim_suffix|> cursor.getLong(cursor.getColumnIndexOrThrow(COLUMN_LENGTH)),
cursor.getString(cursor.getColumnIndexOrThrow(COLUMN_MIME))
);
}
private ContentValues convert(SourceInfo sourceInfo) {
ContentValues values = new ContentValues();
values.put(COLUMN_URL, source... | fim | CarGuo/GSYVideoPlayer | java |
<|fim_suffix|> get(String url) {
return null;
}
@Override
public void put(String url, SourceInfo sourceInfo) {
}
@Override
public void release() {
}
}
<|fim_prefix|>package com.danikula.videocache.sourcestorage;
import com.danikula.v<|fim_middle|>ideocache.SourceInfo;
/**
* {@li... | fim | CarGuo/GSYVideoPlayer | java |
<|fim_prefix|>package com.danikula.videocache.so<|fim_suffix|>
import com.danikula.videocache.SourceInfo;
/**
* Storage for {@link SourceInfo}.
*
* @author Alexey Danilov (danikula@gmail.com).
*/
public interface SourceInfoStorage {
SourceInfo get(String url);
void put(String url, SourceInfo sourceInfo);... | fim | CarGuo/GSYVideoPlayer | java |
<|fim_prefix|>package com.danikula.videocache.sourcestorage;
import android.content.Context;
/**
<|fim_suffix|>eInfoStorage(context);
}
public static SourceInfoStorage newEmptySourceInfoStorage() {
return new NoSourceInfoStorage();
}
}
<|fim_middle|>* Simple factory for {@link SourceInfoStorage}... | fim | CarGuo/GSYVideoPlayer | java |
module.exports = {
printWidth: 80,
tabWidth: 2,
useTabs: false,
semi: true,
singleQuote: false,
trailingComma: 'all',
bracketSpacing: true,
arrowParens: 'always',
};
<|endoftext|> | fim | ChatGPTNextWeb/NextChat | javascript |
<|fim_suffix|>sonBody?.model as string,
ServiceProvider["302.AI"] as string,
)
) {
return NextResponse.json(
{
error: true,
message: `you are not allowed to use ${jsonBody?.model} model`,
},
{
status: 403,
},
... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_suffix|>ndler(req, { params });
case ApiPath.Stability:
return stabilityHandler(req, { params });
case ApiPath.Iflytek:
return iflytekHandler(req, { params });
case ApiPath.DeepSeek:
return deepseekHandler(req, { params });
case ApiPath.XAI:
return xaiHandler(req, { params ... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_suffix|>roller();
// alibaba use base url or just remove the path
let path = `${req.nextUrl.pathname}`.replaceAll(ApiPath.Alibaba, "");
let baseUrl = serverConfig.alibabaUrl || ALIBABA_BASE_URL;
if (!baseUrl.startsWith("http")) {
baseUrl = `https://${baseUrl}`;
}
if (baseUrl.endsWith("/")) {
... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_suffix|>th = `${req.nextUrl.pathname}`.replaceAll(ApiPath.Anthropic, "");
let baseUrl =
serverConfig.anthropicUrl || serverConfig.baseUrl || ANTHROPIC_BASE_URL;
if (!baseUrl.startsWith("http")) {
baseUrl = `https://${baseUrl}`;
}
if (baseUrl.endsWith("/")) {
baseUrl = baseUrl.slice(0, -1);
... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_prefix|>import md5 from "spark-md5";
import { NextRequest, NextResponse } from "next/server";
import { getServerSideConfig } from "@/app/config/server";
async function handle(req: NextRequest, res: NextResponse) {
const serverConfig = getServerSideConfig();
const storeUrl = () =>
`https://api.cloudflare.... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_prefix|>import<|fim_suffix|>g();
console.log("[Auth] allowed hashed codes: ", [...serverConfig.codes]);
console.log("[Auth] got access code:", accessCode);
console.log("[Auth] hashed access code:", hashedCode);
console.log("[User IP] ", getIP(req));
console.log("[Time] ", new Date().toLocaleString());
... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_suffix|>ure] ", e);
return NextResponse.json(prettyObject(e));
}
}
<|fim_prefix|>import { ModelProvider } from "@/app/constant";
import { prettyObject } from "@/app/utils/format";
import { NextRequest, NextResponse } from "next/server";
import { auth } from "./auth";
import { request<|fim_middle|>Openai } f... | fim | ChatGPTNextWeb/NextChat | typescript |
import { getServerSideConfig } from "@/app/config/server";
import {
BAIDU_BASE_URL,
ApiPath,
ModelProvider,
ServiceProvider,
} from "@/app/constant";
import { prettyObject } from "@/app/utils/format";
import { NextRequest, NextResponse } from "next/server";
import { auth } from "@/app/api/auth";
import { isMode... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_prefix|>import { getServerSideConfig } from "@/app/config/server";
import {
BYTEDANCE_BASE_URL,
ApiPath,
ModelProvider,
ServiceProvider,
} from "@/app/constant";
import { prettyObject } from "@/app/utils/format";
import { NextRequest, NextResponse } from "next/server";
import { auth } from "@/app/api/auth... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_prefix|>import { NextRequest, NextResponse } from "next/server";
import { getServerSideConfig } from "../config/server";
import { OPENAI_BASE_URL, ServiceProvider } from "../constant";
import { cloudflareAIGatewayUrl } from "../utils/cloudflare";
import { getModelProvider, isModelNotavailableInServer } from "../u... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_prefix|>import { NextResponse } from "next/s<|fim_suffix|>rver";
import { getServerSideConfig } from "../../config/server";
const serverConfig = getServerSideConfig();
// Danger! Do not hard code any secret value here!
// 警告!不要在这里写入任何敏感信息!
const DANGER_CONFIG = {
needCode: serverConfig.needCode,
hideUserAp... | fim | ChatGPTNextWeb/NextChat | typescript |
import { getServerSideConfig } from "@/app/config/server";
import {
DEEPSEEK_BASE_URL,
ApiPath,
ModelProvider,
ServiceProvider,
} from "@/app/constant";
import { prettyObject } from "@/app/utils/format";
import { NextRequest, NextResponse } from "next/server";
import { auth } from "@/app/api/auth";
import { isM... | fim | ChatGPTNextWeb/NextChat | typescript |
import { getServerSideConfig } from "@/app/config/server";
import {
CHATGLM_BASE_URL,
ApiPath,
ModelProvider,
ServiceProvider,
} from "@/app/constant";
import { prettyObject } from "@/app/utils/format";
import { NextRequest, NextResponse } from "next/server";
import { auth } from "@/app/api/auth";
import { isMo... | fim | ChatGPTNextWeb/NextChat | typescript |
import { NextRequest, NextResponse } from "next/server";
import { auth } from "./auth";
import { getServerSideConfig } from "@/app/config/server";
import { ApiPath, GEMINI_BASE_URL, ModelProvider } from "@/app/constant";
import { prettyObject } from "@/app/utils/format";
const serverConfig = getServerSideConfig();
ex... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_prefix|>import { getServerSideConfig } from "@/app/config/server";
import {
IFLYTEK_BASE_URL,
ApiPath,
ModelProvider,
ServiceProvider,
} from "@/app/constant";
import { prettyObject } from "@/app/utils/format";
import { NextRequest, NextResponse } from "next/server";
import { auth } from "@/app/api/auth";... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_suffix|>dy = JSON.parse(clonedBody) as { model?: string };
// not undefined and is false
if (
isModelNotavailableInServer(
serverConfig.customModels,
jsonBody?.model as string,
ServiceProvider.Moonshot as string,
)
) {
return NextResponse.js... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_prefix|>import { type OpenAIListModelResponse } from "@/app/client/platforms/openai";
import { getServerSideConfig } from "@/app/config/server";
import { ModelProvider, OpenaiPath } from "@/app/constant";
import { prettyObject } from "@/app/utils/format";
import { NextRequest, NextResponse } from "next/server";
i... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_suffix|>prompt for credentials
const newHeaders = new Headers(res.headers);
newHeaders.delete("www-authenticate");
// to disable nginx buffering
newHeaders.set("X-Accel-Buffering", "no");
// The latest version of the OpenAI API forced the content-encoding to be "br" in json response
// So... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_suffix|>meoutId = setTimeout(
() => {
controller.abort();
},
10 * 60 * 1000,
);
const fetchUrl = `${baseUrl}${path}`;
const fetchOptions: RequestInit = {
headers: {
"Content-Type": "application/json",
Authorization: req.headers.get("Authorization") ?? "",
},
method... | fim | ChatGPTNextWeb/NextChat | typescript |
import { NextRequest, NextResponse } from "next/server";
import { getServerSideConfig } from "@/app/config/server";
import { ModelProvider, STABILITY_BASE_URL } from "@/app/constant";
import { auth } from "@/app/api/auth";
export async function handle(
req: NextRequest,
{ params }: { params: { path: string[] } },
... | fim | ChatGPTNextWeb/NextChat | typescript |
import { getServerSideConfig } from "@/app/config/server";
import { TENCENT_BASE_URL, ModelProvider } from "@/app/constant";
import { prettyObject } from "@/app/utils/format";
import { NextRequest, NextResponse } from "next/server";
import { auth } from "@/app/api/auth";
import { getHeader } from "@/app/utils/tencent";... | fim | ChatGPTNextWeb/NextChat | typescript |
import { NextRequest, NextResponse } from "next/server";
async function handle(
req: NextRequest,
{ params }: { params: { action: string; key: string[] } },
) {
const requestUrl = new URL(req.url);
const endpoint = requestUrl.searchParams.get("endpoint");
if (req.method === "OPTIONS") {
return NextRespo... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_prefix|>import { NextRequest, NextResponse } from "next/server";
import { STORAGE_KEY, internalAllowedWebDavEndpoints } from "../../../constant";
import { getServerSideConfig } from "@/app/config/server";
const config = getServerSideConfig();
const mergedAllowedWebDavEndpoints = [
...internalAllowedWebDavEndp... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_prefix|>import { getServerSideConfig } from "@/app/config/server";
import {
XAI_BASE_URL,
ApiPath,
ModelProvider,
ServiceProvider,
} from "@/app/constant";
import { prettyObject } from "@/app/utils/format";
import { NextRequest, NextResponse } from "next/server";
import { auth } from "@/app/api/auth";
imp... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_suffix|>etConfig() {
const modelConfig = chatStore.currentSession().mask.modelConfig;
const isGoogle = modelConfig.providerName === ServiceProvider.Google;
const isAzure = modelConfig.providerName === ServiceProvider.Azure;
const isAnthropic = modelConfig.providerName === ServiceProvider.Anthropic... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_suffix|>ing) {
const key = this.key(sessionId, messageId);
const controller = this.controllers[key];
controller?.abort();
},
stopAll() {
Object.values(this.controllers).forEach((v) => v.abort());
},
hasPending() {
return Object.values(this.controllers).length > 0;
},
remove(sess... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_suffix|> const controller = new AbortController();
options.onController?.(controller);
try {
const chatPath = this.path(AI302.ChatPath);
const chatPayload = {
method: "POST",
body: JSON.stringify(requestPayload),
signal: controller.signal,
headers: getHeaders()... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_prefix|>"use client";
import { ApiPath, Alibaba, ALIBABA_BASE_URL } from "@/app/constant";
import {
useAccessStore,
useAppConfig,
useChatStore,
ChatMessageTool,
usePluginStore,
} from "@/app/store";
import {
preProcessImageContentForAlibabaDashScope,
streamWithThink,
} from "@/app/utils/chat";
impor... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_suffix|>> {
if (!v.content) return false;
if (typeof v.content === "string" && !v.content.trim()) return false;
return true;
})
.map((v) => {
const { role, content } = v;
const insideRole = ClaudeMapper[role] ?? "user";
if (!visionModel || typeof conten... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_prefix|>"use client";
import { ApiPath, Baidu, BAIDU_BASE_URL } from "@/app/constant";
import { useAccessStore, useAppConfig, useChatStore } from "@/app/store";
import { getAccessToken } from "@/app/utils/baidu";
import {
ChatOptions,
getHeaders,
LLMApi,
LLMModel,
MultimodalContent,
SpeechOptions,
} ... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_suffix|>shouldStream,
model: modelConfig.model,
temperature: modelConfig.temperature,
presence_penalty: modelConfig.presence_penalty,
frequency_penalty: modelConfig.frequency_penalty,
top_p: modelConfig.top_p,
};
const controller = new AbortController();
options.onContro... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_prefix|>"use client";
// azure and openai, using same models. so using same LLMApi.
import { ApiPath, DEEPSEEK_BASE_URL, DeepSeek } from "@/app/constant";
import {
useAccessStore,
useAppConfig,
useChatStore,
ChatMessageTool,
usePluginStore,
} from "@/app/store";<|fim_suffix|>es.push(msg);
}
... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_prefix|>"use client";
import { ApiPath, CHATGLM_BASE_URL, ChatGLM } from "@/app/constant";
import {
useAccessStore,
useAppConfig,
useChatStore,
ChatMessageTool,
usePluginStore,
} from "@/app/store";
import { stream } from "@/app/utils/chat";
import {
ChatOptions,
getHeaders,
LLMApi,
LLMModel,
... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_suffix|> ? // @ts-ignore
[{ functionDeclarations: tools.map((tool) => tool.function) }]
: [],
funcs,
controller,
// parseSSE
(text: string, runTools: ChatMessageTool[]) => {
// console.log("parseSSE", text, runTools);
... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_suffix|>h = ApiPath.Iflytek;
baseUrl = isApp ? IFLYTEK_BASE_URL : apiPath;
}
if (baseUrl.endsWith("/")) {
baseUrl = baseUrl.slice(0, baseUrl.length - 1);
}
if (!baseUrl.startsWith("http") && !baseUrl.startsWith(ApiPath.Iflytek)) {
baseUrl = "https://" + baseUrl;
}
conso... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_prefix|>"use client";
// azure and openai, using same models. so using same LLMApi.
import {
ApiPath,
MOONSHOT_BASE_URL,
Moonshot,
REQUEST_TIMEOUT_MS,
} from "@/app/constant";
import {
useAccessStore,
useAppConfig,
useChatStore,
ChatMessageTool,
usePluginStore,
} from "@/app/store";
import { str... | fim | ChatGPTNextWeb/NextChat | typescript |
"use client";
// azure and openai, using same models. so using same LLMApi.
import {
ApiPath,
OPENAI_BASE_URL,
DEFAULT_MODELS,
OpenaiPath,
Azure,
REQUEST_TIMEOUT_MS,
ServiceProvider,
} from "@/app/constant";
import {
ChatMessageTool,
useAccessStore,
useAppConfig,
useChatStore,
usePluginStore,
} ... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_prefix|>"use client";
// azure and openai, using same models. so using same LLMApi.
import {
ApiPath,
SILICONFLOW_BASE_URL,
SiliconFlow,
DEFAULT_MODELS,
} from "@/app/constant";
import {
useAccessStore,
useAppConfig,
useChatStore,
ChatMessageTool,
usePluginStore,
} from "@/app/store";
import { p... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_prefix|>"use client";
import { ApiPath, TENCENT_BASE_URL } from "@/app/constant";
import { useAccessStore, useAppConfig, useChatStore } from "@/app/store";
import {
ChatOptions,
getHeaders,
LLMApi,
LLMModel,
MultimodalContent,
SpeechOptions,
} from "../api";
import Locale from "../../locales";
import... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_suffix|>
(
requestPayload: RequestPayload,
toolCallMessage: any,
toolCallResult: any[],
) => {
// @ts-ignore
requestPayload?.messages?.splice(
// @ts-ignore
requestPayload?.messages?.length,
0... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_suffix|> return {
matched,
invoke: () => matched && commands[command]!(userInput),
};
}
return { match, search };
}
<|fim_prefix|>import { useEffect } from "react";
import { useSearchParams } from "react-router-dom";
import Locale from "./locales";
type Command = (param: string) => void;
in... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_prefix|>import {
useEffect,
useState,
useRef,
useMemo,
forwardRef,
useImperativeHandle,
} from "react";
import { useParams } from "react-router";
import { IconButton } from "./button";
import { nanoid } from "nanoid";
import ExportIcon from "../icons/share.svg";
import CopyIcon from "../icons/copy.svg... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_prefix|>import styles from "./auth.module.scss";
import { IconButton } from "./button";
import { useState, useEffect } from "react";
import { useNavigate } from "react-router-dom";
import { Path, SAAS_CHAT_URL } from "../constant";
import { useAccessStore } from "../store";
import Locale from "../locales";
import... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_prefix|>import * as React from "react";
import styles from "./button.module.scss";
import { CSSProperties } from "react";
import clsx from "clsx";
export type ButtonType = "primary" | "danger" | null;
export function IconButton(props: {
onClick?: () => void;
icon?: JSX.Element;
type?: ButtonType;
text?... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_prefix|>import DeleteIcon from "../icons/delete.svg";
import styles from "./home.module.scss";
import {
DragDropContext,
Droppable,
Draggable,
OnDragEndResponder,
} from "@hello-pangea/dnd";
import { useChatStore } from "../store";
import Locale from "../locales";
import { useLocation, useNavigate } fr... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_suffix|>rrent?.blur()}
onTouchStart={() => {
inputRef.current?.blur();
setAutoScroll(false);
}}
>
{messages
// TODO
// .filter((m) => !m.isMcpResponse)
.map((message, i) => {
... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_prefix|>import EmojiPicker, {
Emoji,
EmojiStyle,
Theme as EmojiTheme,
} from "emoji-picker-react";
import { ModelType } from "../store";
import BotIconDefault from "../icons/llm-icons/default.svg";
import BotIconOpenAI from "../icons/llm-icons/openai.svg";
import BotIconGemini from "../icons/llm-icons/gem... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_suffix|> } finally {
useChatStore.getState().clearAllData();
}
}
render() {
if (this.state.hasError) {
// Render error message
return (
<div className="error">
<h2>Oops, something went wrong!</h2>
<pre>
<code>{this.state.error?.toString()}</co... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_prefix|>/* eslint-disable @next/next/no-img-element */
import { ChatMessage, useAppConfig, useChatStore } from "../store";
import Locale from "../locales";
import styles from "./exporter.module.scss";
import {
List,
ListItem,
Modal,
Select,
showImageModal,
showModal,
showToast,
} from "./ui-lib";
im... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_prefix|>"use client";
require("../polyfill");
import { useEffect, useState } from "react";
import styles from "./home.module.scss";
import BotIcon from "../icons/bot.svg";
import LoadingIcon from "../icons/three-dots.svg";
import { getCSSVar, useMobileScreen } from "../utils";
import dynamic from "next/dynam... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_prefix|>import * as React from "react";
import styles from "./input-range.module.scss";
import clsx from "clsx";<|fim_suffix|> aria-label={aria}
type="range"
title={title}
value={value}
min={min}
max={max}
step={step}
onChange={onChange}
></input... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_suffix|>ne, quoteEnd) => {
return !quoteEnd ? bodyEnd + space + htmlEnd + "\n```\n" : match;
},
);
}
function _MarkDownContent(props: { content: string }) {
const escapedContent = useMemo(() => {
return tryWrapHtmlCode(escapeBrackets(props.content));
}, [props.content]);
return (
... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_suffix|>
const navigate = useNavigate();
const maskStore = useMaskStore();
const chatStore = useChatStore();
const filterLang = maskStore.language;
const allMasks = maskStore
.getAll()
.filter((m) => !filterLang || m.lang === filterLang);
const [searchMasks, setSearchMasks] = useState<Mask... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_prefix|>import { IconButton } from "./button";
import { ErrorBoundary } from "./error";
import styles from "./mcp-market.module.scss";
import EditIcon from "../icons/edit.svg";
import AddIcon from "../icons/add.svg";
import CloseIcon from "../icons/close.svg";
import DeleteIcon from "../icons/delete.svg";
import ... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_prefix|>import { useEffect, useMemo, useState } from "react";
import { ChatMessage, useAppConfig, useChatStore } from "../store";
import { Updater } from "../typing";
import { IconButton } from "./button";
import { Avatar } from "./emoji";
import { MaskAvatar } <|fim_suffix|> <div className={styles["message-se... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_prefix|>import { ServiceProvider } from "@/app/constant";
import { ModalConfigValidator, ModelConfig } from "../store";
import Locale from "../locales";
import { InputRange } from "./input-range";
import { ListItem, Select } from "./ui-lib";
import { useAllModels } from "../utils/hooks";
import { groupBy } from ... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_suffix|>ick={() => navigate(Path.Home)}
></IconButton>
{!state?.fromHome && (
<IconButton
text={Locale.NewChat.NotShow}
onClick={async () => {
if (await showConfirm(Locale.NewChat.ConfirmNoShow)) {
startChat();
config.... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_prefix|>import { useDebouncedCallback } from "use-debounce";
import OpenAPIClie<|fim_suffix|>>
)}
</List>
<List>
<ListItem title={Locale.Plugin.EditModal.Content}>
<div className={pluginStyles["plugin-schema"]}>
<input
... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_suffix|> "./realtime-chat";
<|fim_prefix|>export * fro<|fim_middle|>m<|endoftext|> | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_prefix|>import VoiceIcon from "@/app/icons/voice.svg";
import VoiceOffIcon from "@/app/icons/voice-off.svg";
import PowerIcon from "@/app/icons/power.svg";
import styles from "./realtime-chat.module.scss";
import clsx from "clsx";
import { useState, useRef, useEffect } from "react";
import { useChatStore, crea... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_suffix|>Title}
value={props.realtimeConfig.apiKey}
type="text"
placeholder={Locale.Settings.Realtime.ApiKey.Placeholder}
onChange={(e) => {
props.updateConfig(
(config) => (config.apiKey = e.currentTarget.value),
... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_suffix|>m "./sd-panel";
<|fim_prefix|>export * from "<|fim_middle|>./sd";
export * fro<|endoftext|> | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_suffix|> value={props.data[item.value]}
style={{ maxWidth: "100%", width: "100%" }}
onChange={(e) => {
props.onChange(item.value, e.currentTarget.value);
}}
/>
</ControlParamItem>
);
... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_prefix|>import { IconButton } from "@/app/components/button";
import GithubIcon from "@/app/icons/github.svg";
import SDIcon from "@/app/icons/sd.svg";
import ReturnIcon from "@/app/icons/return.svg";
import HistoryIcon from "@/app/icons/history.svg";
import Locale from "@/app/locales";
import { Path, REPO_URL }... | fim | ChatGPTNextWeb/NextChat | typescript |
import chatStyles from "@/app/components/chat.module.scss";
import styles from "@/app/components/sd/sd.module.scss";
import homeStyles from "@/app/components/home.module.scss";
import { IconButton } from "@/app/components/button";
import ReturnIcon from "@/app/icons/return.svg";
import Locale from "@/app/locales";
imp... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_prefix|>import { useState, useEffect, useRef, useCallback } from "react";
import { ErrorBoundary } from "./error";
import styles from "./mask.module.scss";
import { useNavigate } from "react-router-dom";
import { IconButton } from "./button";
import CloseIcon from "../icons/close.svg";
import EyeIcon from "../ico... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_suffix|>nChange={(e) =>
updateConfig(
(config) => (config.fontFamily = e.currentTarget.value),
)
}
></input>
</ListItem>
<ListItem
title={Locale.Settings.AutoGenerateTitle.Title}
subTitle={Loca... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_suffix|>tener("keydown", onKeyDown);
return () => window.removeEventListener("keydown", onKeyDown);
});
}
export function useDragSideBar() {
const limit = (x: number) => Math.min(MAX_SIDEBAR_WIDTH, x);
const config = useAppConfig();
const startX = useRef(0);
const startDragWidth = useRef(config.si... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_suffix|>TS.Model}>
<Select
value={props.ttsConfig.model}
onChange={(e) => {
props.updateConfig(
(config) =>
(config.model = TTSConfigValidator.model(
e.currentTarget.value,
)),
... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_prefix|>/* eslint-disable @next/next/no-img-element */
import styles from "./ui-lib.module.scss";
import LoadingIcon from "../icons/three-dots.svg";
import CloseIcon from "../icons/close.svg";
import EyeIcon from "../icons/eye.svg";
import EyeOffIcon from "../icons/eye-off.svg";
import DownIcon from "../icons/dow... | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_prefix|>export <|fim_suffix|>int";
<|fim_middle|>* from "./voice-pr<|endoftext|> | fim | ChatGPTNextWeb/NextChat | typescript |
<|fim_suffix|>To(0, centerY);
/**
* 声纹绘制算法:
* 1. 使用历史数据平均值实现平滑过渡
* 2. 通过正弦函数添加自然波动
* 3. 使用贝塞尔曲线连接点,使曲线更平滑
* 4. 绘制对称部分形成完整声纹
*/
for (let i = 0; i < frequencies.length; i++) {
const x = i * sliceWidth;
let avgFrequency = frequencies[i];
/**
... | fim | ChatGPTNextWeb/NextChat | typescript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.