Skip to content

Commit

Permalink
feat: Add Falcon-180b (#539)
Browse files Browse the repository at this point in the history
* Add Falcon

* Add Falcon180bBotSettings

* housekeeping

---------

Co-authored-by: Sunner Sun <[email protected]>
  • Loading branch information
tanchekwei and sunner authored Sep 10, 2023
1 parent 8ce75a2 commit 80782a4
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 0 deletions.
Binary file added public/bots/falcon-180b-logo.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 68 additions & 0 deletions src/bots/huggingface/Falcon180bBot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import GradioBot from "@/bots/huggingface/GradioBot";
import AsyncLock from "async-lock";
import axios from "axios";

export default class Falcon180bBot extends GradioBot {
static _brandId = "falcon"; // Brand id of the bot, should be unique. Used in i18n.
static _className = "Falcon180bBot"; // Class name of the bot
static _logoFilename = "falcon-180b-logo.jpeg"; // Place it in public/bots/
static _loginUrl = "https://tiiuae-falcon-180b-demo.hf.space/"; // Any Gradio URL
static _settingsComponent = "Falcon180bBotSettings"; // Vue component filename for settings
static _model = "falcon-180b";
static _lock = new AsyncLock(); // Send requests in queue to save LMSYS
static _fnIndexes = [3]; // Indexes of the APIs to call in order. Sniffer it by devtools.

static _predictUrl = Falcon180bBot._loginUrl + "run/predict";

constructor() {
super();
}

sendPredict(fn_index, session_hash, payload) {
return axios.post(Falcon180bBot._predictUrl, {
fn_index,
data: [],
event_data: null,
session_hash: session_hash,
...payload,
});
}

async _sendPrompt(prompt, onUpdateResponse, callbackParam) {
try {
const session_hash = await this.getChatContext();
await axios.all([
this.sendPredict(4, session_hash),
this.sendPredict(1, session_hash, {
data: [prompt],
}),
]);
await this.sendPredict(2, session_hash, { data: [null, null] });
await super._sendPrompt(prompt, onUpdateResponse, callbackParam);
await this.sendPredict(5, session_hash);
} catch (error) {
throw Error(error);
}
}

/* eslint-disable no-unused-vars */
makeData(fn_index, prompt) {
let r = null;
if (fn_index === this.constructor._fnIndexes[0]) {
r = [null, null, "", 0.9, 256, 0.9, 1.2];
}
return r;
}

parseData(fn_index, data) {
let r = undefined;
if (fn_index === this.constructor._fnIndexes[0]) {
r = data[0][data[0].length - 1][1];
}
return r;
}

parseError(errorMsg) {
return errorMsg;
}
}
4 changes: 4 additions & 0 deletions src/bots/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import Llama2HC70bBot from "./huggingface/Llama2HC70bBot";
import Llama213bBot from "./lmsys/Llama213bBot";
import Llama27bBot from "./lmsys/Llama27bBot";
import Llama270bBot from "./lmsys/Llama270bBot";
import Falcon180bBot from "./huggingface/Falcon180bBot";

const all = [
Qihoo360AIBrainBot.getInstance(),
Expand All @@ -58,6 +59,7 @@ const all = [
ClaudePlusPoeBot.getInstance(),
WenxinQianfanBot.getInstance(),
WenxinQianfanTurboBot.getInstance(),
Falcon180bBot.getInstance(),
AzureOpenAIAPIBot.getInstance(),
ChatGPT35Bot.getInstance(),
ChatGPT35PoeBot.getInstance(),
Expand Down Expand Up @@ -134,6 +136,7 @@ export const botTags = {
bots.getBotByClassName("ClaudeAIBot"),
bots.getBotByClassName("PiBot"),
bots.getBotByClassName("SageBot"),
bots.getBotByClassName("Falcon180bBot"),
],
paid: [
bots.getBotByClassName("ChatGPT4Bot"),
Expand All @@ -155,6 +158,7 @@ export const botTags = {
bots.getBotByClassName("MOSSBot"),
bots.getBotByClassName("OpenAssistantBot"),
bots.getBotByClassName("VicunaBot"),
bots.getBotByClassName("Falcon180bBot"),
],
api: [
bots.getBotByClassName("AzureOpenAIAPIBot"),
Expand Down
19 changes: 19 additions & 0 deletions src/components/BotSettings/Falcon180bBotSettings.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<template>
<login-setting :bot="bot"></login-setting>
</template>

<script>
import Bot from "@/bots/huggingface/Falcon180bBot";
import LoginSetting from "@/components/BotSettings/LoginSetting.vue";
export default {
components: {
LoginSetting,
},
data() {
return {
bot: Bot.getInstance(),
};
},
};
</script>
2 changes: 2 additions & 0 deletions src/components/SettingsModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ import BardBotSettings from "@/components/BotSettings/BardBotSettings.vue";
import MOSSBotSettings from "@/components/BotSettings/MOSSBotSettings.vue";
import WenxinQianfanBotSettings from "@/components/BotSettings/WenxinQianfanBotSettings.vue";
import GradioAppBotSettings from "@/components/BotSettings/GradioAppBotSettings.vue";
import Falcon180bBotSettings from "@/components/BotSettings/Falcon180bBotSettings.vue";
import LMSYSBotSettings from "@/components/BotSettings/LMSYSBotSettings.vue";
import HuggingChatBotSettings from "@/components/BotSettings/HuggingChatBotSettings.vue";
import QianWenBotSettings from "@/components/BotSettings/QianWenBotSettings.vue";
Expand Down Expand Up @@ -133,6 +134,7 @@ const botSettings = [
{ brand: "characterAI", component: CharacterAIBotSettings },
{ brand: "chatGpt", component: ChatGPTBotSettings },
{ brand: "claudeAi", component: ClaudeAIBotSettings },
{ brand: "falcon", component: Falcon180bBotSettings },
{ brand: "gradio", component: GradioAppBotSettings },
{ brand: "huggingChat", component: HuggingChatBotSettings },
{ brand: "lmsys", component: LMSYSBotSettings },
Expand Down
4 changes: 4 additions & 0 deletions src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@
"name": "Open Assistant",
"queue": "There are { queue_size } requests in the queue, you are in { queue_position }th place"
},
"falcon": {
"name": "Falcon",
"falcon-180b": "180b"
},
"dev": {
"name": "Dev Bot"
},
Expand Down
4 changes: 4 additions & 0 deletions src/i18n/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@
"name": "Open Assistant",
"queue": "当前有 { queue_size } 个请求在队列中,你在第 { queue_position } 位"
},
"falcon": {
"name": "Falcon",
"falcon-180b": "180b"
},
"dev": {
"name": "开发专用 Bot"
},
Expand Down

1 comment on commit 80782a4

@vercel
Copy link

@vercel vercel bot commented on 80782a4 Sep 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

chatall – ./

chatall-sunner.vercel.app
chatall-git-main-sunner.vercel.app
chatall-llm.vercel.app

Please sign in to comment.