🔥 remove openai-aiohttp options

This commit is contained in:
Nate Sesti 2023-12-15 09:44:02 -08:00
parent c18476b77f
commit b1863d8a0e
5 changed files with 6 additions and 91 deletions

View file

@ -287,7 +287,6 @@ declare global {
type ModelProvider =
| "openai"
| "openai-free-trial"
| "openai-aiohttp"
| "anthropic"
| "together"
| "ollama"

1
core/index.d.ts vendored
View file

@ -295,7 +295,6 @@ type TemplateType =
type ModelProvider =
| "openai"
| "openai-free-trial"
| "openai-aiohttp"
| "anthropic"
| "together"
| "ollama"

View file

@ -1,72 +1,11 @@
import { BaseLLM } from "..";
import { CompletionOptions, LLMOptions, ModelProvider } from "../..";
import { LLMOptions, ModelProvider } from "../..";
import OpenAI from "./OpenAI";
class TextGenWebUI extends BaseLLM {
class TextGenWebUI extends OpenAI {
static providerName: ModelProvider = "text-gen-webui";
static defaultOptions: Partial<LLMOptions> = {
apiBase: "http://localhost:5000",
};
private _convertArgs(options: CompletionOptions, prompt: string) {
const finalOptions: any = {
prompt,
...options,
max_new_tokens: options.maxTokens,
};
delete finalOptions.maxTokens;
return finalOptions;
}
protected async *_streamComplete(
prompt: string,
options: CompletionOptions
): AsyncGenerator<string> {
const streamingUrl =
this.apiBase?.replace("5000", "5005") || "http://localhost:5005";
const wsUrl = streamingUrl
.replace("http://", "ws://")
.replace("https://", "wss://");
const payload = JSON.stringify({
...this._convertArgs(options, prompt),
stream: true,
});
const websocket = new WebSocket(`${wsUrl}/api/v1/stream`);
const messageQueue: string[] = [];
let isDone = false;
websocket.onopen = () => {
websocket.send(payload);
};
websocket.onmessage = (event) => {
const incomingData = JSON.parse(event.data);
const incomingDataEvent = incomingData.event;
if (incomingDataEvent === "text_stream") {
messageQueue.push(incomingData.text);
} else if (incomingDataEvent === "stream_end") {
isDone = true;
}
};
websocket.onerror = (error) => {
isDone = true;
throw error;
};
while (!isDone) {
while (messageQueue.length > 0) {
const nextMessage = messageQueue.shift();
if (nextMessage) {
yield nextMessage;
}
}
await new Promise((resolve) => setTimeout(resolve, 0)); // Don't block the event loop
}
}
}
export default TextGenWebUI;

View file

@ -97,7 +97,6 @@
"enum": [
"openai",
"openai-free-trial",
"openai-aiohttp",
"anthropic",
"together",
"ollama",
@ -284,7 +283,7 @@
"if": {
"properties": {
"provider": {
"enum": ["openai", "openai-aiohttp"]
"enum": ["openai"]
}
},
"required": ["provider"]
@ -371,7 +370,7 @@
"if": {
"properties": {
"provider": {
"enum": ["openai", "openai-aiohttp"]
"enum": ["openai"]
},
"apiType": {
"not": {

View file

@ -620,27 +620,6 @@ After it's up and running, you can start using Continue.`,
packages: [...osModels, deepseek],
collectInputFor: [...completionParamsInputs],
},
textgenwebui: {
title: "text-generation-webui",
provider: "text-gen-webui",
description: "A popular open-source front-end for serving LLMs locally",
longDescription: `text-generation-webui is a comprehensive, open-source language model UI and local server. You can also set it up with an [OpenAI-compatible server extension](https://github.com/oobabooga/text-generation-webui/tree/main/extensions/openai#an-openedai-api-openai-like), but this model provider is made to interface with the built-in server, which has a different format. To setup the text-generation-webui server, take the following steps:
1. Clone the repository: \`git clone https://github.com/oobabooga/text-generation-webui/tree/main\`
2. Change into the directory: \`cd text-generation-webui\`
3. Run the one-click installer script for your operating system, using the --api flag:
- Mac: \`sh start_macos.sh --api\`
- Linux: \`sh start_linux.sh --api\`
- Windows: \`. start_windows.bat --api\`
- WSL: \`. start_wsl.bat --api\`
4. Find a model to run and download its weights into the folder \`text-generation-webui/models\`. The best place to find models is [The Bloke on HuggingFace](https://huggingface.co/TheBloke)
5. Navigate to [the UI](http://127.0.0.1:7860), click the "Model" tab, and load the model you've downloaded
6. Once the model is loaded, you can start using Continue`,
icon: undefined,
tags: [ModelProviderTag.Local, ModelProviderTag["Open-Source"]],
packages: [...osModels, deepseek],
collectInputFor: [...completionParamsInputs],
},
palm: {
title: "Google PaLM API",
provider: "google-palm",
@ -674,7 +653,7 @@ After it's up and running, you can start using Continue.`,
},
"openai-aiohttp": {
title: "Other OpenAI-compatible API",
provider: "openai-aiohttp",
provider: "openai",
description:
"If you are using any other OpenAI-compatible API, for example text-gen-webui, FastChat, LocalAI, or llama-cpp-python, you can simply enter your server URL",
longDescription: `If you are using any other OpenAI-compatible API, you can simply enter your server URL. If you still need to set up your model server, you can follow a guide below: