Merge pull request #5855 from continuedev/dallin/remove-free-trial
Remove free trial provider
This commit is contained in:
commit
bb760f76c2
37 changed files with 140 additions and 936 deletions
|
|
@ -1,5 +1,4 @@
|
|||
import { ConfigHandler } from "../config/ConfigHandler.js";
|
||||
import { TRIAL_FIM_MODEL } from "../config/onboarding.js";
|
||||
import { IDE, ILLM } from "../index.js";
|
||||
import OpenAI from "../llm/llms/OpenAI.js";
|
||||
import { DEFAULT_AUTOCOMPLETE_OPTS } from "../util/parameters.js";
|
||||
|
|
@ -75,11 +74,6 @@ export class CompletionProvider {
|
|||
|
||||
if (llm instanceof OpenAI) {
|
||||
llm.useLegacyCompletionsEndpoint = true;
|
||||
} else if (
|
||||
llm.providerName === "free-trial" &&
|
||||
llm.model !== TRIAL_FIM_MODEL
|
||||
) {
|
||||
llm.model = TRIAL_FIM_MODEL;
|
||||
}
|
||||
|
||||
return llm;
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ import { useHub } from "../control-plane/env";
|
|||
import { BaseLLM } from "../llm";
|
||||
import { LLMClasses, llmFromDescription } from "../llm/llms";
|
||||
import CustomLLMClass from "../llm/llms/CustomLLM";
|
||||
import FreeTrial from "../llm/llms/FreeTrial";
|
||||
import { LLMReranker } from "../llm/llms/llm";
|
||||
import TransformersJsEmbeddingsProvider from "../llm/llms/TransformersJsEmbeddingsProvider";
|
||||
import { slashCommandFromPromptFileV1 } from "../promptFiles/v1/slashCommandFromPromptFile";
|
||||
|
|
@ -244,7 +243,6 @@ async function intermediateToFinalConfig({
|
|||
llmLogger,
|
||||
workOsAccessToken,
|
||||
loadPromptFiles = true,
|
||||
allowFreeTrial = true,
|
||||
}: {
|
||||
config: Config;
|
||||
ide: IDE;
|
||||
|
|
@ -254,7 +252,6 @@ async function intermediateToFinalConfig({
|
|||
llmLogger: ILLMLogger;
|
||||
workOsAccessToken: string | undefined;
|
||||
loadPromptFiles?: boolean;
|
||||
allowFreeTrial?: boolean;
|
||||
}): Promise<{ config: ContinueConfig; errors: ConfigValidationError[] }> {
|
||||
const errors: ConfigValidationError[] = [];
|
||||
|
||||
|
|
@ -343,56 +340,43 @@ async function intermediateToFinalConfig({
|
|||
"summarize",
|
||||
]); // Default to chat role if not specified
|
||||
|
||||
if (allowFreeTrial) {
|
||||
// Obtain auth token (iff free trial being used)
|
||||
const freeTrialModels = models.filter(
|
||||
(model) => model.providerName === "free-trial",
|
||||
);
|
||||
if (freeTrialModels.length > 0) {
|
||||
const ghAuthToken = await ide.getGitHubAuthToken({});
|
||||
for (const model of freeTrialModels) {
|
||||
(model as FreeTrial).setupGhAuthToken(ghAuthToken);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Remove free trial models
|
||||
models = models.filter((model) => model.providerName !== "free-trial");
|
||||
// Free trial provider will be completely ignored
|
||||
let warnAboutFreeTrial = false;
|
||||
models = models.filter((model) => model.providerName !== "free-trial");
|
||||
if (models.filter((m) => m.providerName === "free-trial").length) {
|
||||
warnAboutFreeTrial = true;
|
||||
}
|
||||
|
||||
// Tab autocomplete model
|
||||
let tabAutocompleteModels: BaseLLM[] = [];
|
||||
const tabAutocompleteModels: BaseLLM[] = [];
|
||||
if (config.tabAutocompleteModel) {
|
||||
tabAutocompleteModels = (
|
||||
await Promise.all(
|
||||
(Array.isArray(config.tabAutocompleteModel)
|
||||
? config.tabAutocompleteModel
|
||||
: [config.tabAutocompleteModel]
|
||||
).map(async (desc) => {
|
||||
if ("title" in desc) {
|
||||
const llm = await llmFromDescription(
|
||||
desc,
|
||||
ide.readFile.bind(ide),
|
||||
uniqueId,
|
||||
ideSettings,
|
||||
llmLogger,
|
||||
config.completionOptions,
|
||||
);
|
||||
const autocompleteConfigs = Array.isArray(config.tabAutocompleteModel)
|
||||
? config.tabAutocompleteModel
|
||||
: [config.tabAutocompleteModel];
|
||||
|
||||
if (llm?.providerName === "free-trial") {
|
||||
if (!allowFreeTrial) {
|
||||
// This shouldn't happen
|
||||
throw new Error("Free trial cannot be used with control plane");
|
||||
}
|
||||
const ghAuthToken = await ide.getGitHubAuthToken({});
|
||||
(llm as FreeTrial).setupGhAuthToken(ghAuthToken);
|
||||
await Promise.all(
|
||||
autocompleteConfigs.map(async (desc) => {
|
||||
if ("title" in desc) {
|
||||
const llm = await llmFromDescription(
|
||||
desc,
|
||||
ide.readFile.bind(ide),
|
||||
uniqueId,
|
||||
ideSettings,
|
||||
llmLogger,
|
||||
config.completionOptions,
|
||||
);
|
||||
if (llm) {
|
||||
if (llm.providerName === "free-trial") {
|
||||
warnAboutFreeTrial = true;
|
||||
} else {
|
||||
tabAutocompleteModels.push(llm);
|
||||
}
|
||||
return llm;
|
||||
} else {
|
||||
return new CustomLLMClass(desc);
|
||||
}
|
||||
}),
|
||||
)
|
||||
).filter((x) => x !== undefined) as BaseLLM[];
|
||||
} else {
|
||||
tabAutocompleteModels.push(new CustomLLMClass(desc));
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
applyRequestOptionsToModels(tabAutocompleteModels, config);
|
||||
|
|
@ -458,7 +442,10 @@ async function intermediateToFinalConfig({
|
|||
return embedConfig;
|
||||
}
|
||||
const { provider, ...options } = embedConfig;
|
||||
if (provider === "transformers.js") {
|
||||
if (provider === "transformers.js" || provider === "free-trial") {
|
||||
if (provider === "free-trial") {
|
||||
warnAboutFreeTrial = true;
|
||||
}
|
||||
return new TransformersJsEmbeddingsProvider();
|
||||
} else {
|
||||
const cls = LLMClasses.find((c) => c.providerName === provider);
|
||||
|
|
@ -495,7 +482,10 @@ async function intermediateToFinalConfig({
|
|||
return rerankingConfig;
|
||||
}
|
||||
const { name, params } = config.reranker as RerankerDescription;
|
||||
|
||||
if (name === "free-trial") {
|
||||
warnAboutFreeTrial = true;
|
||||
return null;
|
||||
}
|
||||
if (name === "llm") {
|
||||
const llm = models.find((model) => model.title === params?.modelTitle);
|
||||
if (!llm) {
|
||||
|
|
@ -526,6 +516,14 @@ async function intermediateToFinalConfig({
|
|||
}
|
||||
const newReranker = getRerankingILLM(config.reranker);
|
||||
|
||||
if (warnAboutFreeTrial) {
|
||||
errors.push({
|
||||
fatal: false,
|
||||
message:
|
||||
"Model provider 'free-trial' is no longer supported, will be ignored",
|
||||
});
|
||||
}
|
||||
|
||||
const continueConfig: ContinueConfig = {
|
||||
...config,
|
||||
contextProviders,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import { ConfigYaml } from "@continuedev/config-yaml";
|
||||
|
||||
export const TRIAL_FIM_MODEL = "codestral-latest";
|
||||
export const LOCAL_ONBOARDING_PROVIDER_TITLE = "Ollama";
|
||||
export const LOCAL_ONBOARDING_FIM_MODEL = "qwen2.5-coder:1.5b-base";
|
||||
export const LOCAL_ONBOARDING_FIM_TITLE = "Qwen2.5-Coder 1.5B";
|
||||
|
|
|
|||
|
|
@ -743,8 +743,6 @@ declare global {
|
|||
|
||||
getLastModified(files: string[]): Promise<{ [path: string]: number }>;
|
||||
|
||||
getGitHubAuthToken(args: GetGhTokenArgs): Promise<string | undefined>;
|
||||
|
||||
// LSP
|
||||
gotoDefinition(location: Location): Promise<RangeInFile[]>;
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ import DocsContextProvider from "../../context/providers/DocsContextProvider";
|
|||
import FileContextProvider from "../../context/providers/FileContextProvider";
|
||||
import { contextProviderClassFromName } from "../../context/providers/index";
|
||||
import { ControlPlaneClient } from "../../control-plane/client";
|
||||
import FreeTrial from "../../llm/llms/FreeTrial";
|
||||
import TransformersJsEmbeddingsProvider from "../../llm/llms/TransformersJsEmbeddingsProvider";
|
||||
import { slashCommandFromPromptFileV1 } from "../../promptFiles/v1/slashCommandFromPromptFile";
|
||||
import { getAllPromptFiles } from "../../promptFiles/v2/getPromptFiles";
|
||||
|
|
@ -176,18 +175,8 @@ async function configYamlToContinueConfig(options: {
|
|||
uniqueId: string;
|
||||
llmLogger: ILLMLogger;
|
||||
workOsAccessToken: string | undefined;
|
||||
allowFreeTrial?: boolean;
|
||||
}): Promise<{ config: ContinueConfig; errors: ConfigValidationError[] }> {
|
||||
let {
|
||||
config,
|
||||
ide,
|
||||
ideSettings,
|
||||
ideInfo,
|
||||
uniqueId,
|
||||
llmLogger,
|
||||
allowFreeTrial,
|
||||
} = options;
|
||||
allowFreeTrial = allowFreeTrial ?? true;
|
||||
let { config, ide, ideSettings, ideInfo, uniqueId, llmLogger } = options;
|
||||
|
||||
const localErrors: ConfigValidationError[] = [];
|
||||
|
||||
|
|
@ -302,9 +291,14 @@ async function configYamlToContinueConfig(options: {
|
|||
});
|
||||
|
||||
// Models
|
||||
let warnAboutFreeTrial = false;
|
||||
const defaultModelRoles: ModelRole[] = ["chat", "summarize", "apply", "edit"];
|
||||
for (const model of config.models ?? []) {
|
||||
model.roles = model.roles ?? defaultModelRoles; // Default to all 4 chat-esque roles if not specified
|
||||
|
||||
if (model.provider === "free-trial") {
|
||||
warnAboutFreeTrial = true;
|
||||
}
|
||||
try {
|
||||
const llms = await llmsFromModelConfig({
|
||||
model,
|
||||
|
|
@ -376,34 +370,12 @@ async function configYamlToContinueConfig(options: {
|
|||
);
|
||||
}
|
||||
|
||||
if (allowFreeTrial) {
|
||||
// Obtain auth token (iff free trial being used)
|
||||
const freeTrialModels = continueConfig.modelsByRole.chat.filter(
|
||||
(model) => model.providerName === "free-trial",
|
||||
);
|
||||
if (freeTrialModels.length > 0) {
|
||||
try {
|
||||
const ghAuthToken = await ide.getGitHubAuthToken({});
|
||||
for (const model of freeTrialModels) {
|
||||
(model as FreeTrial).setupGhAuthToken(ghAuthToken);
|
||||
}
|
||||
} catch (e) {
|
||||
localErrors.push({
|
||||
fatal: false,
|
||||
message: `Failed to obtain GitHub auth token for free trial:\n${e instanceof Error ? e.message : e}`,
|
||||
});
|
||||
// Remove free trial models
|
||||
continueConfig.modelsByRole.chat =
|
||||
continueConfig.modelsByRole.chat.filter(
|
||||
(model) => model.providerName !== "free-trial",
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Remove free trial models
|
||||
continueConfig.modelsByRole.chat = continueConfig.modelsByRole.chat.filter(
|
||||
(model) => model.providerName !== "free-trial",
|
||||
);
|
||||
if (warnAboutFreeTrial) {
|
||||
localErrors.push({
|
||||
fatal: false,
|
||||
message:
|
||||
"Model provider 'free-trial' is no longer supported, will be ignored.",
|
||||
});
|
||||
}
|
||||
|
||||
// Context providers
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ const modelDescriptionSchema = z.object({
|
|||
"nebius",
|
||||
"siliconflow",
|
||||
"scaleway",
|
||||
"watsonx"
|
||||
"watsonx",
|
||||
]),
|
||||
model: z.string(),
|
||||
apiKey: z.string().optional(),
|
||||
|
|
@ -88,13 +88,12 @@ const embeddingsProviderSchema = z.object({
|
|||
"ollama",
|
||||
"openai",
|
||||
"cohere",
|
||||
"free-trial",
|
||||
"gemini",
|
||||
"ovhcloud",
|
||||
"nebius",
|
||||
"siliconflow",
|
||||
"scaleway",
|
||||
"watsonx"
|
||||
"watsonx",
|
||||
]),
|
||||
apiBase: z.string().optional(),
|
||||
apiKey: z.string().optional(),
|
||||
|
|
|
|||
3
core/index.d.ts
vendored
3
core/index.d.ts
vendored
|
|
@ -5,7 +5,6 @@ import {
|
|||
} from "@continuedev/config-yaml";
|
||||
import Parser from "web-tree-sitter";
|
||||
import { LLMConfigurationStatuses } from "./llm/constants";
|
||||
import { GetGhTokenArgs } from "./protocol/ide";
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
|
|
@ -808,8 +807,6 @@ export interface IDE {
|
|||
|
||||
getFileStats(files: string[]): Promise<FileStatsMap>;
|
||||
|
||||
getGitHubAuthToken(args: GetGhTokenArgs): Promise<string | undefined>;
|
||||
|
||||
// Secret Storage
|
||||
readSecrets(keys: string[]): Promise<Record<string, string>>;
|
||||
|
||||
|
|
|
|||
|
|
@ -101,23 +101,7 @@
|
|||
// // const originalEmbeddingsProvider =
|
||||
// // await docsService.getEmbeddingsProvider();
|
||||
|
||||
// // // Change embeddings provider
|
||||
// // editConfigJson((config) => ({
|
||||
// // ...config,
|
||||
// // embeddingsProvider: {
|
||||
// // provider: FreeTrial.providerName,
|
||||
// // },
|
||||
// // }));
|
||||
|
||||
// // await getReloadedConfig();
|
||||
|
||||
// // const { provider, isPreindexed} = await docsService.getEmbeddingsProvider();
|
||||
|
||||
// // // Verify reindexing
|
||||
// // const [originalVector] = await originalEmbeddingsProvider.embed(["test"]);
|
||||
// // const [newMockVector] = await provider.embed(["test"]);
|
||||
|
||||
// // expect(originalVector).not.toEqual(newMockVector);
|
||||
// // TODO removed this test when free trial provider was removed
|
||||
// // });
|
||||
|
||||
// test("Handles pulling down and adding pre-indexed docs", async () => {
|
||||
|
|
|
|||
|
|
@ -66,7 +66,6 @@ const PROVIDER_SUPPORTS_IMAGES: string[] = [
|
|||
"openai",
|
||||
"ollama",
|
||||
"gemini",
|
||||
"free-trial",
|
||||
"msty",
|
||||
"anthropic",
|
||||
"bedrock",
|
||||
|
|
@ -148,7 +147,6 @@ const PARALLEL_PROVIDERS: string[] = [
|
|||
"huggingface-tgi",
|
||||
"mistral",
|
||||
"moonshot",
|
||||
"free-trial",
|
||||
"replicate",
|
||||
"together",
|
||||
"novita",
|
||||
|
|
@ -389,6 +387,5 @@ export {
|
|||
autodetectTemplateType,
|
||||
llmCanGenerateInParallel,
|
||||
modelSupportsImages,
|
||||
modelSupportsTools
|
||||
modelSupportsTools,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,270 +0,0 @@
|
|||
import { streamResponse } from "@continuedev/fetch";
|
||||
import { TRIAL_FIM_MODEL } from "../../config/onboarding.js";
|
||||
import { getHeaders } from "../../continueServer/stubs/headers.js";
|
||||
import { TRIAL_PROXY_URL } from "../../control-plane/client.js";
|
||||
import {
|
||||
ChatMessage,
|
||||
Chunk,
|
||||
CompletionOptions,
|
||||
LLMOptions,
|
||||
} from "../../index.js";
|
||||
import { BaseLLM } from "../index.js";
|
||||
|
||||
class FreeTrial extends BaseLLM {
|
||||
static providerName = "free-trial";
|
||||
static defaultOptions: Partial<LLMOptions> | undefined = {
|
||||
maxEmbeddingBatchSize: 128,
|
||||
model: "voyage-code-2",
|
||||
};
|
||||
|
||||
private ghAuthToken: string | undefined = undefined;
|
||||
|
||||
constructor(options: LLMOptions) {
|
||||
super(options);
|
||||
this.embeddingId = `${this.constructor.name}::${this.model}`;
|
||||
}
|
||||
|
||||
setupGhAuthToken(ghAuthToken: string | undefined) {
|
||||
this.ghAuthToken = ghAuthToken;
|
||||
}
|
||||
|
||||
private async _getHeaders() {
|
||||
if (!this.ghAuthToken) {
|
||||
throw new Error(
|
||||
"Please sign in with GitHub in order to use the free trial. If you'd like to use Continue without signing in, you can set up your own local model or API key.",
|
||||
);
|
||||
}
|
||||
return {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${this.ghAuthToken}`,
|
||||
...(await getHeaders()),
|
||||
};
|
||||
}
|
||||
|
||||
private async _countTokens(prompt: string, model: string, isPrompt: boolean) {
|
||||
// Removed to reduce PostHog bill
|
||||
// if (!Telemetry.client) {
|
||||
// throw new Error(
|
||||
// "In order to use the free trial, telemetry must be enabled so that we can monitor abuse. To enable telemetry, set \"allowAnonymousTelemetry\": true in config.json and make sure the box is checked in IDE settings. If you use your own model (local or API key), telemetry will never be required.",
|
||||
// );
|
||||
// }
|
||||
// const event = isPrompt
|
||||
// ? "free_trial_prompt_tokens"
|
||||
// : "free_trial_completion_tokens";
|
||||
// Telemetry.capture(event, {
|
||||
// tokens: this.countTokens(prompt),
|
||||
// model,
|
||||
// });
|
||||
}
|
||||
|
||||
private _convertArgs(options: CompletionOptions): any {
|
||||
return {
|
||||
model: options.model,
|
||||
frequency_penalty: options.frequencyPenalty,
|
||||
presence_penalty: options.presencePenalty,
|
||||
max_tokens: options.maxTokens,
|
||||
stop:
|
||||
options.model === TRIAL_FIM_MODEL
|
||||
? options.stop
|
||||
: options.stop?.slice(0, 2),
|
||||
temperature: options.temperature,
|
||||
top_p: options.topP,
|
||||
};
|
||||
}
|
||||
|
||||
protected async *_streamComplete(
|
||||
prompt: string,
|
||||
signal: AbortSignal,
|
||||
options: CompletionOptions,
|
||||
): AsyncGenerator<string> {
|
||||
const args = this._convertArgs(this.collectArgs(options));
|
||||
|
||||
await this._countTokens(prompt, args.model, true);
|
||||
|
||||
const response = await this.fetch(`${TRIAL_PROXY_URL}/stream_complete`, {
|
||||
method: "POST",
|
||||
headers: await this._getHeaders(),
|
||||
body: JSON.stringify({
|
||||
prompt,
|
||||
...args,
|
||||
}),
|
||||
signal,
|
||||
});
|
||||
|
||||
let completion = "";
|
||||
for await (const value of streamResponse(response)) {
|
||||
yield value;
|
||||
completion += value;
|
||||
}
|
||||
void this._countTokens(completion, args.model, false);
|
||||
}
|
||||
|
||||
protected _convertMessage(message: ChatMessage) {
|
||||
if (message.role === "tool") {
|
||||
return {
|
||||
role: "tool",
|
||||
content: message.content,
|
||||
tool_call_id: message.toolCallId,
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof message.content === "string") {
|
||||
return message;
|
||||
}
|
||||
|
||||
const parts = message.content.map((part) => {
|
||||
if (part.type === "imageUrl") {
|
||||
return {
|
||||
type: "image_url",
|
||||
image_url: {
|
||||
url: part.imageUrl.url,
|
||||
detail: "low",
|
||||
},
|
||||
};
|
||||
}
|
||||
return {
|
||||
type: "text",
|
||||
text: part.text,
|
||||
};
|
||||
});
|
||||
return {
|
||||
...message,
|
||||
content: parts,
|
||||
};
|
||||
}
|
||||
|
||||
protected async *_streamChat(
|
||||
messages: ChatMessage[],
|
||||
signal: AbortSignal,
|
||||
options: CompletionOptions,
|
||||
): AsyncGenerator<ChatMessage> {
|
||||
const args = this._convertArgs(this.collectArgs(options));
|
||||
|
||||
await this._countTokens(
|
||||
messages.map((m) => m.content).join("\n"),
|
||||
args.model,
|
||||
true,
|
||||
);
|
||||
|
||||
const response = await this.fetch(`${TRIAL_PROXY_URL}/stream_chat`, {
|
||||
method: "POST",
|
||||
headers: await this._getHeaders(),
|
||||
body: JSON.stringify({
|
||||
messages: messages.map(this._convertMessage),
|
||||
...args,
|
||||
}),
|
||||
signal,
|
||||
});
|
||||
|
||||
let completion = "";
|
||||
for await (const chunk of streamResponse(response)) {
|
||||
yield {
|
||||
role: "assistant",
|
||||
content: chunk,
|
||||
};
|
||||
completion += chunk;
|
||||
}
|
||||
await this._countTokens(completion, args.model, false);
|
||||
}
|
||||
|
||||
supportsFim(): boolean {
|
||||
return this.model === "codestral-latest";
|
||||
}
|
||||
|
||||
async *_streamFim(
|
||||
prefix: string,
|
||||
suffix: string,
|
||||
signal: AbortSignal,
|
||||
options: CompletionOptions,
|
||||
): AsyncGenerator<string> {
|
||||
const args = this._convertArgs(this.collectArgs(options));
|
||||
|
||||
try {
|
||||
const resp = await this.fetch(`${TRIAL_PROXY_URL}/stream_fim`, {
|
||||
method: "POST",
|
||||
headers: await this._getHeaders(),
|
||||
body: JSON.stringify({
|
||||
prefix,
|
||||
suffix,
|
||||
...args,
|
||||
}),
|
||||
signal,
|
||||
});
|
||||
|
||||
let completion = "";
|
||||
for await (const value of streamResponse(resp)) {
|
||||
yield value;
|
||||
completion += value;
|
||||
}
|
||||
await this._countTokens(completion, args.model, false);
|
||||
} catch (e: any) {
|
||||
if (e.message.startsWith("HTTP 429")) {
|
||||
throw new Error(
|
||||
"You have reached the 2000 request limit for the autocomplete free trial. To continue using autocomplete, please set up a local model or your own Codestral API key.",
|
||||
);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
async listModels(): Promise<string[]> {
|
||||
return [
|
||||
"codestral-latest",
|
||||
"claude-3-5-sonnet-latest",
|
||||
"llama3.1-405b",
|
||||
"llama3.1-70b",
|
||||
"gpt-4o",
|
||||
"gpt-3.5-turbo",
|
||||
"claude-3-5-haiku-latest",
|
||||
"gemini-1.5-pro-latest",
|
||||
];
|
||||
}
|
||||
|
||||
protected async _embed(chunks: string[]): Promise<number[][]> {
|
||||
const resp = await this.fetch(new URL("embeddings", TRIAL_PROXY_URL), {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
input: chunks,
|
||||
model: this.model,
|
||||
}),
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
...(await getHeaders()),
|
||||
},
|
||||
});
|
||||
|
||||
if (resp.status !== 200) {
|
||||
throw new Error(`Failed to embed: ${resp.status} ${await resp.text()}`);
|
||||
}
|
||||
|
||||
const data = (await resp.json()) as any;
|
||||
return data.embeddings;
|
||||
}
|
||||
|
||||
async rerank(query: string, chunks: Chunk[]): Promise<number[]> {
|
||||
if (chunks.length === 0) {
|
||||
return [];
|
||||
}
|
||||
const resp = await this.fetch(new URL("rerank", TRIAL_PROXY_URL), {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
...(await getHeaders()),
|
||||
},
|
||||
body: JSON.stringify({
|
||||
query,
|
||||
documents: chunks.map((chunk) => chunk.content),
|
||||
}),
|
||||
});
|
||||
|
||||
if (!resp.ok) {
|
||||
throw new Error(await resp.text());
|
||||
}
|
||||
|
||||
const data = (await resp.json()) as any;
|
||||
const results = data.sort((a: any, b: any) => a.index - b.index);
|
||||
return results.map((result: any) => result.relevance_score);
|
||||
}
|
||||
}
|
||||
|
||||
export default FreeTrial;
|
||||
|
|
@ -23,7 +23,6 @@ import Deepseek from "./Deepseek";
|
|||
import Docker from "./Docker";
|
||||
import Fireworks from "./Fireworks";
|
||||
import Flowise from "./Flowise";
|
||||
import FreeTrial from "./FreeTrial";
|
||||
import FunctionNetwork from "./FunctionNetwork";
|
||||
import Gemini from "./Gemini";
|
||||
import Groq from "./Groq";
|
||||
|
|
@ -67,7 +66,6 @@ import xAI from "./xAI";
|
|||
export const LLMClasses = [
|
||||
Anthropic,
|
||||
Cohere,
|
||||
FreeTrial,
|
||||
FunctionNetwork,
|
||||
Gemini,
|
||||
Llamafile,
|
||||
|
|
|
|||
|
|
@ -92,7 +92,6 @@ export type ToIdeFromWebviewOrCoreProtocol = {
|
|||
|
||||
gotoDefinition: [{ location: Location }, RangeInFile[]];
|
||||
|
||||
getGitHubAuthToken: [GetGhTokenArgs, string | undefined];
|
||||
getControlPlaneSessionInfo: [
|
||||
{ silent: boolean; useOnboarding: boolean },
|
||||
ControlPlaneSessionInfo | undefined,
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & {
|
|||
];
|
||||
"jetbrains/getColors": [undefined, Record<string, string | null | undefined>];
|
||||
"vscode/openMoveRightMarkdown": [undefined, void];
|
||||
setGitHubAuthToken: [{ token: string }, void];
|
||||
acceptDiff: [AcceptOrRejectDiffPayload, void];
|
||||
rejectDiff: [AcceptOrRejectDiffPayload, void];
|
||||
"edit/sendPrompt": [
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { FromIdeProtocol } from "..";
|
||||
import { GetGhTokenArgs, ToIdeFromWebviewOrCoreProtocol } from "../ide";
|
||||
import { ToIdeFromWebviewOrCoreProtocol } from "../ide";
|
||||
|
||||
import type {
|
||||
ContinueRcJson,
|
||||
|
|
@ -50,9 +50,6 @@ export class MessageIde implements IDE {
|
|||
getIdeSettings(): Promise<IdeSettings> {
|
||||
return this.request("getIdeSettings", undefined);
|
||||
}
|
||||
getGitHubAuthToken(args: GetGhTokenArgs): Promise<string | undefined> {
|
||||
return this.request("getGitHubAuthToken", args);
|
||||
}
|
||||
getFileStats(files: string[]): Promise<FileStatsMap> {
|
||||
return this.request("getFileStats", { files });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,10 +34,6 @@ export class ReverseMessageIde {
|
|||
}
|
||||
|
||||
private initializeListeners() {
|
||||
this.on("getGitHubAuthToken", (data) => {
|
||||
return this.ide.getGitHubAuthToken(data);
|
||||
});
|
||||
|
||||
this.on("getFileStats", (data) => {
|
||||
return this.ide.getFileStats(data.files);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ import {
|
|||
Thread,
|
||||
ToastType,
|
||||
} from "../index.js";
|
||||
import { GetGhTokenArgs } from "../protocol/ide.js";
|
||||
|
||||
class FileSystemIde implements IDE {
|
||||
constructor(private readonly workspaceDir: string) {}
|
||||
|
|
@ -56,9 +55,6 @@ class FileSystemIde implements IDE {
|
|||
pauseCodebaseIndexOnStart: false,
|
||||
};
|
||||
}
|
||||
async getGitHubAuthToken(args: GetGhTokenArgs): Promise<string | undefined> {
|
||||
return undefined;
|
||||
}
|
||||
async getFileStats(fileUris: string[]): Promise<FileStatsMap> {
|
||||
const result: FileStatsMap = {};
|
||||
for (const uri of fileUris) {
|
||||
|
|
|
|||
|
|
@ -36,8 +36,6 @@ class MessageTypes {
|
|||
"getFileStats",
|
||||
"insertAtCursor",
|
||||
"applyToFile",
|
||||
"getGitHubAuthToken",
|
||||
"setGitHubAuthToken",
|
||||
"getControlPlaneSessionInfo",
|
||||
"logoutOfControlPlane",
|
||||
"getTerminalContents",
|
||||
|
|
|
|||
|
|
@ -388,33 +388,6 @@ class IdeProtocolClient(
|
|||
respond(pinnedFiles)
|
||||
}
|
||||
|
||||
"getGitHubAuthToken" -> {
|
||||
val params = Gson().fromJson(
|
||||
dataElement.toString(),
|
||||
GetGhTokenArgs::class.java
|
||||
)
|
||||
|
||||
val ghAuthToken = ide.getGitHubAuthToken(params)
|
||||
|
||||
if (ghAuthToken == null) {
|
||||
// Open a dialog so user can enter their GitHub token
|
||||
continuePluginService.sendToWebview("openOnboardingCard", null, uuid())
|
||||
respond(null)
|
||||
} else {
|
||||
respond(ghAuthToken)
|
||||
}
|
||||
}
|
||||
|
||||
"setGitHubAuthToken" -> {
|
||||
val params = Gson().fromJson(
|
||||
dataElement.toString(),
|
||||
SetGitHubAuthTokenParams::class.java
|
||||
)
|
||||
val continueSettingsService = service<ContinueExtensionSettings>()
|
||||
continueSettingsService.continueState.ghAuthToken = params.token
|
||||
respond(null)
|
||||
}
|
||||
|
||||
"openUrl" -> {
|
||||
val url = Gson().fromJson(
|
||||
dataElement.toString(),
|
||||
|
|
|
|||
|
|
@ -576,11 +576,6 @@ class IntelliJIDE(
|
|||
}
|
||||
}
|
||||
|
||||
override suspend fun getGitHubAuthToken(args: GetGhTokenArgs): String? {
|
||||
val continueSettingsService = service<ContinueExtensionSettings>()
|
||||
return continueSettingsService.continueState.ghAuthToken
|
||||
}
|
||||
|
||||
override suspend fun gotoDefinition(location: Location): List<RangeInFile> {
|
||||
throw NotImplementedError("gotoDefinition not implemented yet")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,10 +4,6 @@ data class CopyTextParams(
|
|||
val text: String
|
||||
)
|
||||
|
||||
data class SetGitHubAuthTokenParams(
|
||||
val token: String
|
||||
)
|
||||
|
||||
data class ApplyToFileParams(
|
||||
val text: String,
|
||||
val streamId: String,
|
||||
|
|
|
|||
|
|
@ -91,7 +91,6 @@ open class ContinueExtensionSettings : PersistentStateComponent<ContinueExtensio
|
|||
var remoteConfigSyncPeriod: Int = 60
|
||||
var userToken: String? = null
|
||||
var enableTabAutocomplete: Boolean = true
|
||||
var ghAuthToken: String? = null
|
||||
var enableOSR: Boolean = shouldRenderOffScreen()
|
||||
var displayEditorTooltip: Boolean = true
|
||||
var showIDECompletionSideBySide: Boolean = false
|
||||
|
|
|
|||
|
|
@ -187,8 +187,6 @@ interface IDE {
|
|||
|
||||
suspend fun getFileStats(files: List<String>): Map<String, FileStats>
|
||||
|
||||
suspend fun getGitHubAuthToken(args: GetGhTokenArgs): String?
|
||||
|
||||
// LSP
|
||||
suspend fun gotoDefinition(location: Location): List<RangeInFile>
|
||||
|
||||
|
|
@ -200,10 +198,6 @@ interface IDE {
|
|||
}
|
||||
}
|
||||
|
||||
data class GetGhTokenArgs(
|
||||
val force: String?
|
||||
)
|
||||
|
||||
data class Message(
|
||||
val messageType: String,
|
||||
val messageId: String,
|
||||
|
|
|
|||
|
|
@ -187,7 +187,6 @@
|
|||
"description": "The provider of the model. This is used to determine the type of model, and how to interact with it.",
|
||||
"enum": [
|
||||
"openai",
|
||||
"free-trial",
|
||||
"anthropic",
|
||||
"anthropic-vertexai",
|
||||
"cohere",
|
||||
|
|
@ -237,7 +236,6 @@
|
|||
],
|
||||
"markdownEnumDescriptions": [
|
||||
"### OpenAI\nUse gpt-4, gpt-3.5-turbo, or any other OpenAI model. See [here](https://openai.com/product#made-for-developers) to obtain an API key.\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/openai)",
|
||||
"### Free Trial\nNew users can try out Continue for free using a proxy server that securely makes calls to OpenAI using our API key. If you are ready to use your own API key or have used all 250 free uses, you can enter your API key in config.json where it says `apiKey=\"\"` or select another model provider.\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/freetrial)",
|
||||
"### Anthropic\nTo get started with Anthropic models, you first need to sign up for the open beta [here](https://claude.ai/login) to obtain an API key.\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/anthropicllm)",
|
||||
"### Anthropic Vertex AI\nTo get started you need to enable the [Vertex AI API](https://console.cloud.google.com/marketplace/product/google/aiplatform.googleapis.com) and set up the [Google Application Default Credentials](https://cloud.google.com/docs/authentication/provide-credentials-adc).",
|
||||
"### Cohere\nTo use Cohere, visit the [Cohere dashboard](https://dashboard.cohere.com/api-keys) to create an API key.\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/cohere)",
|
||||
|
|
@ -736,33 +734,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"provider": {
|
||||
"enum": ["free-trial"]
|
||||
}
|
||||
},
|
||||
"required": ["provider"]
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"model": {
|
||||
"enum": [
|
||||
"gpt-4o",
|
||||
"codestral-latest",
|
||||
"llama3.1-70b",
|
||||
"llama3.1-405b",
|
||||
"gpt-3.5-turbo",
|
||||
"gemini-pro",
|
||||
"claude-3-5-sonnet-latest",
|
||||
"claude-3-haiku-20240307",
|
||||
"AUTODETECT"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
|
|
@ -1515,7 +1486,11 @@
|
|||
"then": {
|
||||
"properties": {
|
||||
"model": {
|
||||
"enum": ["llama3.1-8b", "llama3.1-70b", "llama-4-scout-17b-16e-instruct"]
|
||||
"enum": [
|
||||
"llama3.1-8b",
|
||||
"llama3.1-70b",
|
||||
"llama-4-scout-17b-16e-instruct"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2723,10 +2698,10 @@
|
|||
"x-intellij-html-description": "Learn about setting up models in <a href='https://docs.continue.dev/model-setup/overview'>the documentation</a>.",
|
||||
"default": [
|
||||
{
|
||||
"title": "GPT-4 (trial)",
|
||||
"provider": "free-trial",
|
||||
"model": "gpt-4",
|
||||
"apiKey": ""
|
||||
"title": "Claude 3.7 Sonnet",
|
||||
"provider": "anthropic",
|
||||
"model": "claude-3-7-sonnet-latest",
|
||||
"apiKey": "sk_..."
|
||||
}
|
||||
],
|
||||
"type": "array",
|
||||
|
|
@ -2834,7 +2809,6 @@
|
|||
"ollama",
|
||||
"openai",
|
||||
"cohere",
|
||||
"free-trial",
|
||||
"continue-proxy",
|
||||
"gemini",
|
||||
"voyage",
|
||||
|
|
@ -2970,7 +2944,6 @@
|
|||
"voyage",
|
||||
"watsonx",
|
||||
"llm",
|
||||
"free-trial",
|
||||
"huggingface-tei",
|
||||
"siliconflow"
|
||||
]
|
||||
|
|
|
|||
|
|
@ -105,157 +105,6 @@ class VsCodeIde implements IDE {
|
|||
});
|
||||
}
|
||||
|
||||
private authToken: string | undefined;
|
||||
private askedForAuth = false;
|
||||
|
||||
async getGitHubAuthToken(args: GetGhTokenArgs): Promise<string | undefined> {
|
||||
// Saved auth token
|
||||
if (this.authToken) {
|
||||
return this.authToken;
|
||||
}
|
||||
|
||||
// Try to ask silently
|
||||
const session = await vscode.authentication.getSession("github", [], {
|
||||
silent: true,
|
||||
});
|
||||
|
||||
if (session) {
|
||||
this.authToken = session.accessToken;
|
||||
return this.authToken;
|
||||
}
|
||||
|
||||
try {
|
||||
if (args.force) {
|
||||
this.askedForAuth = true;
|
||||
this.authToken = await vscode.authentication
|
||||
.getSession("github", [], { createIfNone: true })
|
||||
.then((session) => session.accessToken);
|
||||
return this.authToken;
|
||||
}
|
||||
|
||||
// If we haven't asked yet, give explanation of what is happening and why
|
||||
// But don't wait to return this immediately
|
||||
// We will use a callback to refresh the config
|
||||
if (!this.askedForAuth) {
|
||||
vscode.window
|
||||
.showInformationMessage(
|
||||
"Continue will request read access to your GitHub email so that we can prevent abuse of the free trial. If you prefer not to sign in, you can use Continue with your own API keys or local model.",
|
||||
"Sign in",
|
||||
"Use API key / local model",
|
||||
"Learn more",
|
||||
)
|
||||
.then(async (selection) => {
|
||||
if (selection === "Use API key / local model") {
|
||||
await vscode.commands.executeCommand(
|
||||
"continue.continueGUIView.focus",
|
||||
);
|
||||
(await this.vscodeWebviewProtocolPromise).request(
|
||||
"openOnboardingCard",
|
||||
undefined,
|
||||
);
|
||||
|
||||
// Remove free trial models
|
||||
editConfigFile(
|
||||
(config) => {
|
||||
let tabAutocompleteModel = undefined;
|
||||
if (Array.isArray(config.tabAutocompleteModel)) {
|
||||
tabAutocompleteModel = config.tabAutocompleteModel.filter(
|
||||
(model) => model.provider !== "free-trial",
|
||||
);
|
||||
} else if (
|
||||
config.tabAutocompleteModel?.provider === "free-trial"
|
||||
) {
|
||||
tabAutocompleteModel = undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
...config,
|
||||
models: config.models.filter(
|
||||
(model) => model.provider !== "free-trial",
|
||||
),
|
||||
tabAutocompleteModel,
|
||||
};
|
||||
},
|
||||
(config) => {
|
||||
return {
|
||||
...config,
|
||||
models: config.models?.filter(
|
||||
(model) =>
|
||||
!(
|
||||
"provider" in model && model.provider === "free-trial"
|
||||
),
|
||||
),
|
||||
};
|
||||
},
|
||||
);
|
||||
} else if (selection === "Learn more") {
|
||||
vscode.env.openExternal(
|
||||
vscode.Uri.parse(
|
||||
"https://docs.continue.dev/reference/Model%20Providers/freetrial",
|
||||
),
|
||||
);
|
||||
} else if (selection === "Sign in") {
|
||||
const session = await vscode.authentication.getSession(
|
||||
"github",
|
||||
[],
|
||||
{
|
||||
createIfNone: true,
|
||||
},
|
||||
);
|
||||
if (session) {
|
||||
this.authToken = session.accessToken;
|
||||
}
|
||||
}
|
||||
});
|
||||
this.askedForAuth = true;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const session = await vscode.authentication.getSession("github", [], {
|
||||
silent: this.askedForAuth,
|
||||
createIfNone: !this.askedForAuth,
|
||||
});
|
||||
if (session) {
|
||||
this.authToken = session.accessToken;
|
||||
return session.accessToken;
|
||||
} else if (!this.askedForAuth) {
|
||||
// User cancelled the login prompt
|
||||
// Explain that they can avoid the prompt by removing free trial models from config.json
|
||||
vscode.window
|
||||
.showInformationMessage(
|
||||
"We'll only ask you to log in if using the free trial. To avoid this prompt, make sure to remove free trial models from your config.json",
|
||||
"Remove for me",
|
||||
"Open Assistant configuration",
|
||||
)
|
||||
.then((selection) => {
|
||||
if (selection === "Remove for me") {
|
||||
editConfigFile(
|
||||
(configJson) => {
|
||||
configJson.models = configJson.models.filter(
|
||||
(model) => model.provider !== "free-trial",
|
||||
);
|
||||
configJson.tabAutocompleteModel = undefined;
|
||||
return configJson;
|
||||
},
|
||||
(config) => {
|
||||
config.models = config.models?.filter(
|
||||
(model) =>
|
||||
!("provider" in model && model.provider === "free-trial"),
|
||||
);
|
||||
return config;
|
||||
},
|
||||
);
|
||||
} else if (selection === "Open Assistant configuration") {
|
||||
this.openFile(getConfigJsonPath());
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to get GitHub authentication session:", error);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
showToast: IDE["showToast"] = async (...params) => {
|
||||
const [type, message, ...otherParams] = params;
|
||||
const { showErrorMessage, showWarningMessage, showInformationMessage } =
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import { v4 as uuidv4 } from "uuid";
|
|||
import * as vscode from "vscode";
|
||||
|
||||
import { handleLLMError } from "../util/errorHandling";
|
||||
import { showFreeTrialLoginMessage } from "../util/messages";
|
||||
import { VsCodeIde } from "../VsCodeIde";
|
||||
import { VsCodeWebviewProtocol } from "../webviewProtocol";
|
||||
|
||||
|
|
@ -33,21 +32,15 @@ interface VsCodeCompletionInput {
|
|||
}
|
||||
|
||||
export class ContinueCompletionProvider
|
||||
implements vscode.InlineCompletionItemProvider {
|
||||
private async onError(e: any) {
|
||||
implements vscode.InlineCompletionItemProvider
|
||||
{
|
||||
private async onError(e: unknown) {
|
||||
if (await handleLLMError(e)) {
|
||||
return;
|
||||
}
|
||||
let message = e.message;
|
||||
if (message.includes("Please sign in with GitHub")) {
|
||||
showFreeTrialLoginMessage(
|
||||
message,
|
||||
this.configHandler.reloadConfig.bind(this.configHandler),
|
||||
() => {
|
||||
void this.webviewProtocol.request("openOnboardingCard", undefined);
|
||||
},
|
||||
);
|
||||
return;
|
||||
let message = "Continue Autocomplete Error";
|
||||
if (e instanceof Error) {
|
||||
message += `: ${e.message}`;
|
||||
}
|
||||
vscode.window.showErrorMessage(message, "Documentation").then((val) => {
|
||||
if (val === "Documentation") {
|
||||
|
|
|
|||
|
|
@ -352,9 +352,6 @@ export class VsCodeMessenger {
|
|||
this.onWebviewOrCore("showToast", (msg) => {
|
||||
this.ide.showToast(...msg.data);
|
||||
});
|
||||
this.onWebviewOrCore("getGitHubAuthToken", (msg) =>
|
||||
ide.getGitHubAuthToken(msg.data),
|
||||
);
|
||||
this.onWebviewOrCore("getControlPlaneSessionInfo", async (msg) => {
|
||||
return getControlPlaneSessionInfo(
|
||||
msg.data.silent,
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
import * as vscode from "vscode";
|
||||
|
||||
export function showFreeTrialLoginMessage(
|
||||
message: string,
|
||||
reloadConfig: () => void,
|
||||
openOnboardingCard: () => void,
|
||||
) {
|
||||
vscode.window
|
||||
.showInformationMessage(message, "Sign In", "Use API key / local model")
|
||||
.then((selection) => {
|
||||
if (selection === "Sign In") {
|
||||
vscode.authentication
|
||||
.getSession("github", [], {
|
||||
createIfNone: true,
|
||||
})
|
||||
.then(() => {
|
||||
reloadConfig();
|
||||
});
|
||||
} else if (selection === "Use API key / local model") {
|
||||
openOnboardingCard();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -8,7 +8,6 @@ import * as vscode from "vscode";
|
|||
import { IMessenger } from "../../../core/protocol/messenger";
|
||||
|
||||
import { handleLLMError } from "./util/errorHandling";
|
||||
import { showFreeTrialLoginMessage } from "./util/messages";
|
||||
|
||||
export class VsCodeWebviewProtocol
|
||||
implements IMessenger<FromWebviewProtocol, ToWebviewProtocol>
|
||||
|
|
@ -135,10 +134,6 @@ export class VsCodeWebviewProtocol
|
|||
this.request("setupLocalConfig", undefined);
|
||||
}
|
||||
});
|
||||
} else if (message.includes("Please sign in with GitHub")) {
|
||||
showFreeTrialLoginMessage(message, this.reloadConfig, () =>
|
||||
this.request("openOnboardingCard", undefined),
|
||||
);
|
||||
} else {
|
||||
Telemetry.capture(
|
||||
"webview_protocol_error",
|
||||
|
|
|
|||
|
|
@ -1,22 +1,20 @@
|
|||
import { useAppSelector } from "../redux/hooks";
|
||||
import { selectSelectedChatModel } from "../redux/slices/configSlice";
|
||||
import { FREE_TRIAL_LIMIT_REQUESTS } from "../util/freeTrial";
|
||||
import { getLocalStorage } from "../util/localStorage";
|
||||
import FreeTrialProgressBar from "./loaders/FreeTrialProgressBar";
|
||||
|
||||
function Footer() {
|
||||
const defaultModel = useAppSelector(selectSelectedChatModel);
|
||||
|
||||
if (defaultModel?.provider === "free-trial") {
|
||||
return (
|
||||
<footer className="flex flex-col border-0 border-t border-solid border-t-zinc-700 px-2 py-2">
|
||||
<FreeTrialProgressBar
|
||||
completed={getLocalStorage("ftc") ?? 0}
|
||||
total={FREE_TRIAL_LIMIT_REQUESTS}
|
||||
/>
|
||||
</footer>
|
||||
);
|
||||
}
|
||||
// TODO hook hub up to free trial
|
||||
// if (defaultModel?.provider === "free-trial") {
|
||||
// return (
|
||||
// <footer className="flex flex-col border-0 border-t border-solid border-t-zinc-700 px-2 py-2">
|
||||
// <FreeTrialProgressBar
|
||||
// completed={getLocalStorage("ftc") ?? 0}
|
||||
// total={FREE_TRIAL_LIMIT_REQUESTS}
|
||||
// />
|
||||
// </footer>
|
||||
// );
|
||||
// }
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,82 +0,0 @@
|
|||
import { ArrowTopRightOnSquareIcon } from "@heroicons/react/24/outline";
|
||||
import { useContext, useState } from "react";
|
||||
import { StyledActionButton, Input, Button, ButtonSubtext } from "../..";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { setShowDialog } from "../../../redux/slices/uiSlice";
|
||||
import { useDispatch } from "react-redux";
|
||||
|
||||
interface JetBrainsFetchGitHubTokenDialogProps {
|
||||
onComplete: () => void;
|
||||
}
|
||||
|
||||
const GITHUB_AUTH_URL =
|
||||
"https://github.com/settings/tokens/new?scopes=user:email&description=Continue%20Free%20Trial%20Token%20";
|
||||
|
||||
function JetBrainsFetchGitHubTokenDialog({
|
||||
onComplete,
|
||||
}: JetBrainsFetchGitHubTokenDialogProps) {
|
||||
const dispatch = useDispatch();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const [jbGhAuthToken, setJbGhAuthToken] = useState("");
|
||||
const [hasClickedGitHubButton, setHasClickedGitHubButton] = useState(false);
|
||||
|
||||
async function submitJetBrainsToken() {
|
||||
await ideMessenger.request("setGitHubAuthToken", {
|
||||
token: jbGhAuthToken,
|
||||
});
|
||||
dispatch(setShowDialog(false));
|
||||
onComplete();
|
||||
}
|
||||
|
||||
function openGitHubTokenPage() {
|
||||
ideMessenger.post("openUrl", GITHUB_AUTH_URL);
|
||||
setHasClickedGitHubButton(true);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-3 p-8">
|
||||
<div className="text-center">
|
||||
<h1 className="my-0 text-xl">Sign in with GitHub</h1>
|
||||
<p className="text-sm">
|
||||
Continue will request read access to your GitHub email so that we can
|
||||
prevent abuse of the free trial. If you prefer not to sign in, you can
|
||||
use Continue with your own API keys or local model.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col gap-3">
|
||||
{hasClickedGitHubButton ? (
|
||||
<div className="flex flex-col items-start">
|
||||
<label className="text-sm">Token</label>
|
||||
<Input
|
||||
className="flex-1"
|
||||
placeholder="Enter your GitHub token"
|
||||
value={jbGhAuthToken}
|
||||
onChange={(e) => setJbGhAuthToken(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<StyledActionButton onClick={openGitHubTokenPage}>
|
||||
<p className="text-sm">Get GitHub token</p>
|
||||
<ArrowTopRightOnSquareIcon width={24} height={24} />
|
||||
</StyledActionButton>
|
||||
)}
|
||||
|
||||
<div>
|
||||
<Button
|
||||
onClick={submitJetBrainsToken}
|
||||
disabled={!jbGhAuthToken}
|
||||
className="mt-2 grid w-full grid-flow-col items-center gap-2"
|
||||
>
|
||||
Get started using our API keys
|
||||
</Button>
|
||||
<ButtonSubtext>
|
||||
Try 50 chat and 2k autocomplete requests
|
||||
</ButtonSubtext>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default JetBrainsFetchGitHubTokenDialog;
|
||||
|
|
@ -2,10 +2,7 @@ import { useContext } from "react";
|
|||
import { useDispatch } from "react-redux";
|
||||
import { Button, ButtonSubtext } from "../..";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { setDialogMessage, setShowDialog } from "../../../redux/slices/uiSlice";
|
||||
import { isJetBrains } from "../../../util";
|
||||
import { useSubmitOnboarding } from "../hooks";
|
||||
import JetBrainsFetchGitHubTokenDialog from "./JetBrainsFetchGitHubTokenDialog";
|
||||
|
||||
interface QuickstartSubmitButtonProps {
|
||||
isDialog?: boolean;
|
||||
|
|
@ -21,36 +18,10 @@ function QuickstartSubmitButton({ isDialog }: QuickstartSubmitButtonProps) {
|
|||
submitOnboarding();
|
||||
}
|
||||
|
||||
function openJetBrainsDialog() {
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(
|
||||
setDialogMessage(
|
||||
<JetBrainsFetchGitHubTokenDialog onComplete={onComplete} />,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
async function fetchGitHubAuthToken() {
|
||||
const result = await ideMessenger.request("getGitHubAuthToken", {
|
||||
force: true,
|
||||
});
|
||||
|
||||
if (result.status === "success") {
|
||||
onComplete();
|
||||
} else {
|
||||
ideMessenger.post("showToast", [
|
||||
"error",
|
||||
"Failed to sign up for Continue free trial through GitHub",
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
async function onClick() {
|
||||
if (isJetBrains()) {
|
||||
openJetBrainsDialog();
|
||||
} else {
|
||||
await fetchGitHubAuthToken();
|
||||
}
|
||||
// REMOVED THIS LOGIC TO GET GITHUB TOKEN
|
||||
// SINCE NOW USES THE HUB FOR FREE TRIAL
|
||||
// AND COMPONENT IS CURRENTLY UNUSED
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ import {
|
|||
} from "../pages/AddNewModel/configs/providers";
|
||||
import { useAppDispatch } from "../redux/hooks";
|
||||
import { updateSelectedModelByRole } from "../redux/thunks";
|
||||
import { FREE_TRIAL_LIMIT_REQUESTS, hasPassedFTL } from "../util/freeTrial";
|
||||
|
||||
interface QuickModelSetupProps {
|
||||
onDone: () => void;
|
||||
|
|
@ -54,7 +53,7 @@ function AddModelForm({
|
|||
];
|
||||
|
||||
const allProviders = Object.entries(providers)
|
||||
.filter(([key]) => !["freetrial", "openai-aiohttp"].includes(key))
|
||||
.filter(([key]) => !["openai-aiohttp"].includes(key))
|
||||
.map(([, provider]) => provider)
|
||||
.filter((provider) => !!provider)
|
||||
.map((provider) => provider!); // for type checking
|
||||
|
|
@ -74,10 +73,7 @@ function AddModelForm({
|
|||
: selectedProvider.apiKeyUrl;
|
||||
|
||||
function isDisabled() {
|
||||
if (
|
||||
selectedProvider.downloadUrl ||
|
||||
selectedProvider.provider === "free-trial"
|
||||
) {
|
||||
if (selectedProvider.downloadUrl) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -138,7 +134,8 @@ function AddModelForm({
|
|||
<form onSubmit={formMethods.handleSubmit(onSubmit)}>
|
||||
<div className="mx-auto max-w-md p-6">
|
||||
<h1 className="mb-0 text-center text-2xl">Add Chat model</h1>
|
||||
{!hideFreeTrialLimitMessage && hasPassedFTL() && (
|
||||
{/* TODO sync free trial limit with hub */}
|
||||
{/* {!hideFreeTrialLimitMessage && hasPassedFTL() && (
|
||||
<p className="text-sm text-gray-400">
|
||||
You've reached the free trial limit of {FREE_TRIAL_LIMIT_REQUESTS}{" "}
|
||||
free inputs. To keep using Continue, you can either use your own
|
||||
|
|
@ -151,7 +148,7 @@ function AddModelForm({
|
|||
</a>
|
||||
.
|
||||
</p>
|
||||
)}
|
||||
)} */}
|
||||
|
||||
<div className="my-8 flex flex-col gap-6">
|
||||
<div>
|
||||
|
|
|
|||
|
|
@ -423,33 +423,6 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
],
|
||||
isOpenSource: true,
|
||||
},
|
||||
llama3170bTrial: {
|
||||
title: "Codellama 70b (Free Trial)",
|
||||
description:
|
||||
"The best code model from Meta, fine-tuned for code generation and conversation",
|
||||
refUrl: "",
|
||||
params: {
|
||||
title: "CodeLlama-70b",
|
||||
model: "codellama-70b",
|
||||
contextLength: 4096,
|
||||
},
|
||||
icon: "meta.png",
|
||||
providerOptions: ["free-trial"],
|
||||
isOpenSource: false,
|
||||
},
|
||||
llama31405bTrial: {
|
||||
title: "Llama3.1 405b (Free Trial)",
|
||||
description: "The latest Llama model from Meta, fine-tuned for chat",
|
||||
refUrl: "",
|
||||
params: {
|
||||
title: "Llama3.1-405b",
|
||||
model: "llama3.1-405b",
|
||||
contextLength: 8192,
|
||||
},
|
||||
icon: "meta.png",
|
||||
providerOptions: ["free-trial"],
|
||||
isOpenSource: false,
|
||||
},
|
||||
mixtralTrial: {
|
||||
title: "Mixtral (Free Trial)",
|
||||
description:
|
||||
|
|
@ -461,7 +434,7 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
contextLength: 4096,
|
||||
},
|
||||
icon: "mistral.png",
|
||||
providerOptions: ["free-trial", "groq"],
|
||||
providerOptions: ["groq"],
|
||||
isOpenSource: false,
|
||||
},
|
||||
llama38bChat: {
|
||||
|
|
@ -725,13 +698,7 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
model: "phind-codellama-34b",
|
||||
contextLength: 4096,
|
||||
},
|
||||
providerOptions: [
|
||||
"ollama",
|
||||
"lmstudio",
|
||||
"llama.cpp",
|
||||
"replicate",
|
||||
"free-trial",
|
||||
],
|
||||
providerOptions: ["ollama", "lmstudio", "llama.cpp", "replicate"],
|
||||
isOpenSource: true,
|
||||
},
|
||||
codestral: {
|
||||
|
|
@ -859,7 +826,7 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
apiKey: "<API_KEY>",
|
||||
},
|
||||
icon: "gemini.png",
|
||||
providerOptions: ["gemini", "free-trial", "askSage"],
|
||||
providerOptions: ["gemini", "askSage"],
|
||||
isOpenSource: false,
|
||||
},
|
||||
gemini15Flash: {
|
||||
|
|
@ -998,7 +965,7 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
systemMessage:
|
||||
"You are an expert software developer. You give helpful and concise responses.",
|
||||
},
|
||||
providerOptions: ["openai", "free-trial", "askSage"],
|
||||
providerOptions: ["openai", "askSage"],
|
||||
icon: "openai.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
|
|
@ -1026,7 +993,7 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
contextLength: 8096,
|
||||
title: "GPT-3.5-Turbo",
|
||||
},
|
||||
providerOptions: ["openai", "free-trial", "askSage"],
|
||||
providerOptions: ["openai", "askSage"],
|
||||
icon: "openai.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
|
|
@ -1040,7 +1007,7 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
title: "Claude 3.5 Sonnet",
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["anthropic", "free-trial", "askSage"],
|
||||
providerOptions: ["anthropic", "askSage"],
|
||||
icon: "anthropic.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
|
|
@ -1068,7 +1035,7 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
title: "Claude 3 Sonnet",
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["anthropic", "free-trial", "askSage"],
|
||||
providerOptions: ["anthropic", "askSage"],
|
||||
icon: "anthropic.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
|
|
@ -1082,7 +1049,7 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
title: "Claude 3.5 Haiku",
|
||||
apiKey: "",
|
||||
},
|
||||
providerOptions: ["anthropic", "free-trial"],
|
||||
providerOptions: ["anthropic"],
|
||||
icon: "anthropic.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
|
|
@ -1685,8 +1652,7 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
},
|
||||
deepseekR1DistillLlama70B: {
|
||||
title: "DeepSeek R1 Distill Llama 70B",
|
||||
description:
|
||||
"A llama 3.1 70 model distilled from deekseek R1",
|
||||
description: "A llama 3.1 70 model distilled from deekseek R1",
|
||||
params: {
|
||||
title: "DeepSeek R1 Distill Llama 70B",
|
||||
model: "DeepSeek-R1-Distill-Llama-70B",
|
||||
|
|
@ -1698,8 +1664,7 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
},
|
||||
deepseekR1: {
|
||||
title: "DeepSeek R1",
|
||||
description:
|
||||
"DeekSeek R1 reasoning model from DeepSeek",
|
||||
description: "DeekSeek R1 reasoning model from DeepSeek",
|
||||
params: {
|
||||
title: "DeepSeek R1",
|
||||
model: "DeepSeek-R1",
|
||||
|
|
@ -1711,8 +1676,7 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
},
|
||||
deepseekV3: {
|
||||
title: "DeepSeek V3",
|
||||
description:
|
||||
"DeekSeek V3 reasoning model from DeepSeek",
|
||||
description: "DeekSeek V3 reasoning model from DeepSeek",
|
||||
params: {
|
||||
title: "DeepSeek V3",
|
||||
model: "DeepSeek-V3-0324",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import { HTMLInputTypeAttribute } from "react";
|
||||
import { ModelProviderTags } from "../../../components/modelSelection/utils";
|
||||
import { FREE_TRIAL_LIMIT_REQUESTS } from "../../../util/freeTrial";
|
||||
import { completionParamsInputs } from "./completionParamsInputs";
|
||||
import type { ModelPackage } from "./models";
|
||||
import { models } from "./models";
|
||||
|
|
@ -748,34 +747,6 @@ To get started, [register](https://dataplatform.cloud.ibm.com/registration/stepo
|
|||
models.MetaLlama3,
|
||||
],
|
||||
},
|
||||
"free-trial": {
|
||||
title: "Continue limited free trial",
|
||||
provider: "free-trial",
|
||||
refPage: "freetrial",
|
||||
description:
|
||||
"New users can try out Continue for free using a proxy server that securely makes calls to OpenAI, Anthropic, or Together using our API key",
|
||||
longDescription: `New users can try out Continue for free using a proxy server that securely makes calls to OpenAI, Anthropic, or Together using our API key. If you are ready to set up a model for long-term use or have used all ${FREE_TRIAL_LIMIT_REQUESTS} free uses, you can enter your API key or use a local model.`,
|
||||
icon: "openai.png",
|
||||
tags: [ModelProviderTags.Free],
|
||||
packages: [
|
||||
models.llama31405bTrial,
|
||||
models.llama3170bTrial,
|
||||
{ ...models.claude35Sonnet, title: "Claude 3.5 Sonnet (trial)" },
|
||||
{ ...models.gpt4o, title: "GPT-4o (trial)" },
|
||||
{ ...models.gpt35turbo, title: "GPT-3.5-Turbo (trial)" },
|
||||
{ ...models.claude35Haiku, title: "Claude 3.5 Haiku (trial)" },
|
||||
models.mixtralTrial,
|
||||
{ ...models.gemini15Pro, title: "Gemini 1.5 Pro (trial)" },
|
||||
{
|
||||
...models.AUTODETECT,
|
||||
params: {
|
||||
...models.AUTODETECT.params,
|
||||
title: "Free Trial",
|
||||
},
|
||||
},
|
||||
],
|
||||
collectInputFor: [...completionParamsInputsConfigs],
|
||||
},
|
||||
sambanova: {
|
||||
title: "SambaNova",
|
||||
provider: "sambanova",
|
||||
|
|
@ -797,7 +768,7 @@ To get started, [register](https://dataplatform.cloud.ibm.com/registration/stepo
|
|||
},
|
||||
...completionParamsInputsConfigs,
|
||||
],
|
||||
packages:[
|
||||
packages: [
|
||||
models.llama4Scout,
|
||||
models.llama4Maverick,
|
||||
models.llama3370BInstruct,
|
||||
|
|
@ -808,7 +779,7 @@ To get started, [register](https://dataplatform.cloud.ibm.com/registration/stepo
|
|||
models.qwq32B,
|
||||
models.deepseekR1DistillLlama70B,
|
||||
models.deepseekR1,
|
||||
models.deepseekV3
|
||||
models.deepseekV3,
|
||||
],
|
||||
apiKeyUrl: "https://cloud.sambanova.ai/apis",
|
||||
},
|
||||
|
|
@ -1011,9 +982,7 @@ To get started, [register](https://dataplatform.cloud.ibm.com/registration/stepo
|
|||
required: true,
|
||||
},
|
||||
],
|
||||
packages: [
|
||||
{...models.AUTODETECT}
|
||||
],
|
||||
apiKeyUrl: "https://venice.ai/chat"
|
||||
}
|
||||
packages: [{ ...models.AUTODETECT }],
|
||||
apiKeyUrl: "https://venice.ai/chat",
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ import { ErrorBoundary } from "react-error-boundary";
|
|||
import styled from "styled-components";
|
||||
import { Button, lightGray, vscBackground } from "../../components";
|
||||
import FeedbackDialog from "../../components/dialogs/FeedbackDialog";
|
||||
import FreeTrialOverDialog from "../../components/dialogs/FreeTrialOverDialog";
|
||||
import { useFindWidget } from "../../components/find/FindWidget";
|
||||
import TimelineItem from "../../components/gui/TimelineItem";
|
||||
import { NewSessionButton } from "../../components/mainInput/belowMainInput/NewSessionButton";
|
||||
|
|
@ -49,10 +48,6 @@ import { cancelStream } from "../../redux/thunks/cancelStream";
|
|||
import { streamEditThunk } from "../../redux/thunks/edit";
|
||||
import { loadLastSession } from "../../redux/thunks/session";
|
||||
import { isJetBrains, isMetaEquivalentKeyPressed } from "../../util";
|
||||
import {
|
||||
FREE_TRIAL_LIMIT_REQUESTS,
|
||||
incrementFreeTrialCount,
|
||||
} from "../../util/freeTrial";
|
||||
|
||||
import { getLocalStorage, setLocalStorage } from "../../util/localStorage";
|
||||
import { EmptyChatBody } from "./EmptyChatBody";
|
||||
|
|
@ -191,32 +186,33 @@ export function Chat() {
|
|||
return;
|
||||
}
|
||||
|
||||
if (model.provider === "free-trial") {
|
||||
const newCount = incrementFreeTrialCount();
|
||||
// TODO - hook up with hub to detect free trial progress
|
||||
// if (model.provider === "free-trial") {
|
||||
// const newCount = incrementFreeTrialCount();
|
||||
|
||||
if (newCount === FREE_TRIAL_LIMIT_REQUESTS) {
|
||||
posthog?.capture("ftc_reached");
|
||||
}
|
||||
if (newCount >= FREE_TRIAL_LIMIT_REQUESTS) {
|
||||
// Show this message whether using platform or not
|
||||
// So that something happens if in new chat
|
||||
void ideMessenger.ide.showToast(
|
||||
"error",
|
||||
"You've reached the free trial limit. Please configure a model to continue.",
|
||||
);
|
||||
// if (newCount === FREE_TRIAL_LIMIT_REQUESTS) {
|
||||
// posthog?.capture("ftc_reached");
|
||||
// }
|
||||
// if (newCount >= FREE_TRIAL_LIMIT_REQUESTS) {
|
||||
// // Show this message whether using platform or not
|
||||
// // So that something happens if in new chat
|
||||
// void ideMessenger.ide.showToast(
|
||||
// "error",
|
||||
// "You've reached the free trial limit. Please configure a model to continue.",
|
||||
// );
|
||||
|
||||
// Card in chat will only show if no history
|
||||
// Also, note that platform card ignore the "Best", always opens to main tab
|
||||
onboardingCard.open("Best");
|
||||
// // Card in chat will only show if no history
|
||||
// // Also, note that platform card ignore the "Best", always opens to main tab
|
||||
// onboardingCard.open("Best");
|
||||
|
||||
// If history, show the dialog, which will automatically close if there is not history
|
||||
if (history.length) {
|
||||
dispatch(setDialogMessage(<FreeTrialOverDialog />));
|
||||
dispatch(setShowDialog(true));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
// // If history, show the dialog, which will automatically close if there is not history
|
||||
// if (history.length) {
|
||||
// dispatch(setDialogMessage(<FreeTrialOverDialog />));
|
||||
// dispatch(setShowDialog(true));
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
if (isInEdit) {
|
||||
void dispatch(
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ export const gatherContext = createAsyncThunk<
|
|||
|
||||
// Automatically use currently open file
|
||||
if (!modifiers.noContext) {
|
||||
const usingFreeTrial = selectedChatModel.provider === "free-trial";
|
||||
const usingFreeTrial = false; // TODO no longer tracking free trial count, need to hook up to hub
|
||||
|
||||
const currentFileResponse = await extra.ideMessenger.request(
|
||||
"context/getContextItems",
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ export const modelDescriptionSchema = z.object({
|
|||
"continue-proxy",
|
||||
"nebius",
|
||||
"scaleway",
|
||||
"watsonx"
|
||||
"watsonx",
|
||||
]),
|
||||
model: z.string(),
|
||||
apiKey: z.string().optional(),
|
||||
|
|
@ -109,13 +109,12 @@ export const embeddingsProviderSchema = z.object({
|
|||
"ollama",
|
||||
"openai",
|
||||
"cohere",
|
||||
"free-trial",
|
||||
"gemini",
|
||||
"ovhcloud",
|
||||
"continue-proxy",
|
||||
"nebius",
|
||||
"scaleway",
|
||||
"watsonx"
|
||||
"watsonx",
|
||||
]),
|
||||
apiBase: z.string().optional(),
|
||||
apiKey: z.string().optional(),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue