Skip to content

Commit

Permalink
Merge pull request #263 from n4ze3m/next
Browse files Browse the repository at this point in the history
v1.8.3
  • Loading branch information
n4ze3m committed May 17, 2024
2 parents a9eae08 + 510d33a commit 2e8c43b
Show file tree
Hide file tree
Showing 18 changed files with 386 additions and 237 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ Dialoqbase nothing without the support of our wonderful sponsors. If you are int

<a href="https://github.com/mjtechguy" target="_blank"><img src="https://avatars.githubusercontent.com/u/29070994?s=64&v=4"></a>
<a href="https://github.com/senavi888" target="_blank"><img src="https://avatars.githubusercontent.com/u/161348858?s=64&v=4"></a>
<a href="https://github.com/hkjang" target="_blank"><img src="https://avatars.githubusercontent.com/u/3069493?s=64&v=4"></a>
<a href="https://github.com/FarazPatankar" target="_blank"><img src="https://avatars.githubusercontent.com/u/10681116?s=64&v=4"></a>

And many more wonderful supporters from [Ko-fi](https://ko-fi.com/n4ze3m).
Expand Down
2 changes: 1 addition & 1 deletion app/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "app",
"private": true,
"version": "1.8.2",
"version": "1.8.3",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
4 changes: 3 additions & 1 deletion app/ui/src/@types/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export type BotSettings = {
model: string;
public_id: string;
temperature: number;
embedding: string;
embedding: string;
noOfDocumentsToRetrieve: number;
qaPrompt: string;
questionGeneratorPrompt: string;
Expand All @@ -15,6 +15,8 @@ export type BotSettings = {
bot_protect: boolean;
use_rag: boolean;
bot_model_api_key: string;
noOfChatHistoryInContext: number;
semanticSearchSimilarityScore: string
},
chatModel: {
label: string;
Expand Down
49 changes: 49 additions & 0 deletions app/ui/src/components/Bot/Settings/SettingsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ export const SettingsCard: React.FC<BotSettings> = ({
use_rag: data.use_rag,
bot_model_api_key: data.bot_model_api_key,
noOfDocumentsToRetrieve: data.noOfDocumentsToRetrieve,
noOfChatHistoryInContext: data.noOfChatHistoryInContext,
semanticSearchSimilarityScore: data.semanticSearchSimilarityScore,
}}
form={form}
requiredMark={false}
Expand Down Expand Up @@ -297,6 +299,52 @@ export const SettingsCard: React.FC<BotSettings> = ({
placeholder="Enter number of documents to retrieve"
/>
</Form.Item>
{/* <Form.Item
name="noOfChatHistoryInContext"
label="Number of chat history in context"
rules={[
{
required: true,
message:
"Please input a number of chat history in context!",
},
]}
>
<InputNumber
min={0}
style={{ width: "100%" }}
placeholder="Enter number of chat history in context"
/>
</Form.Item> */}
<Form.Item
label={"Semantic Search Similarity Score"}
name="semanticSearchSimilarityScore"
rules={[
{
required: true,
message: "Please input a similarity score!",
},
]}
>
<Select
placeholder="Select a similarity score"
options={[
{ label: "Consider all documents", value: "none" },
{
label: "Similarity Score >= 0.2",
value: "0.2",
},
{
label: "Similarity Score >= 0.5",
value: "0.5",
},
{
label: "Similarity Score >= 0.7",
value: "0.7",
},
]}
/>
</Form.Item>

<Form.Item
label={"Question Answering Prompt (System Prompt)"}
Expand All @@ -310,6 +358,7 @@ export const SettingsCard: React.FC<BotSettings> = ({
>
<Input.TextArea size="large" rows={5} placeholder="" />
</Form.Item>

<div className="flex flex-row justify-start gap-4">
<button
type="button"
Expand Down
58 changes: 32 additions & 26 deletions app/ui/src/components/Settings/Model/LLMForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,22 @@ const providers: Record<any, string> = {
fireworks: "https://api.fireworks.ai/inference/v1",
openrouter: "https://openrouter.ai/api/v1",
together: "https://api.together.xyz",
replicate: "https://api.replicate.ai",
};

const providerName: Record<any, string> = {
fireworks: "Fireworks AI",
openrouter: "OpenRouter",
together: "Together",
"openai-api": "OpenAI",
google: "Google",
anthropic: "Anthropic",
replicate: "Replicate",
};

const thirdPartyProviders = Object.keys(providers);
const noFetchProviders = ["openai-api", "google", "anthropic", "replicate"];

const thirdPartyProviders = Object.keys(providers);
export const LLMForm: React.FC<Props> = ({ setOpenAddModel }) => {
const [fetchUrlForm] = Form.useForm();
const [form] = Form.useForm();
Expand Down Expand Up @@ -116,7 +122,7 @@ export const LLMForm: React.FC<Props> = ({ setOpenAddModel }) => {
form={fetchUrlForm}
layout="vertical"
onFinish={(value) => {
if (apiType === "replicate") {
if (noFetchProviders.includes(apiType)) {
saveModel(value);
} else {
fetchModel(value);
Expand Down Expand Up @@ -173,47 +179,35 @@ export const LLMForm: React.FC<Props> = ({ setOpenAddModel }) => {
</Form.Item>
)}

{apiType === "replicate" && (
{noFetchProviders.includes(apiType) && (
<>
<Form.Item
name="api_key"
label="Replicate API Key"
rules={[
{
required: true,
message: "Please your Replicate API Key",
message: "Please enter a model name",
},
]}
name="name"
label="Model Name"
>
<Input.Password
<Input
size="large"
type="text"
placeholder="Enter API Key"
placeholder="Enter a model name"
autoComplete="off"
/>
</Form.Item>

<Form.Item
name="model_id"
label="Model"
label="Model ID"
rules={[
{
required: true,
message: "Please enter a replicate model id",
message: "Please enter a model id",
},
]}
>
<Input
size="large"
placeholder="mistralai/mixtral-8x7b-instruct-v0.1"
/>
</Form.Item>

<Form.Item
name="stream_available"
label="Is Streaming Available?"
valuePropName="checked"
>
<Switch />
<Input size="large" placeholder="Enter a model id" />
</Form.Item>
</>
)}
Expand All @@ -226,7 +220,7 @@ export const LLMForm: React.FC<Props> = ({ setOpenAddModel }) => {
rules={[
{
required: true,
message: `Please your ${providerName[apiType]} API Key`,
message: `Please enter ${providerName[apiType]} API Key`,
},
]}
>
Expand Down Expand Up @@ -268,6 +262,18 @@ export const LLMForm: React.FC<Props> = ({ setOpenAddModel }) => {
label: "OpenRouter",
value: "openrouter",
},
{
label: "OpenAI",
value: "openai-api",
},
{
label: "Google",
value: "google",
},
{
label: "Anthropic",
value: "anthropic",
},
]}
/>
</Form.Item>
Expand All @@ -277,7 +283,7 @@ export const LLMForm: React.FC<Props> = ({ setOpenAddModel }) => {
disabled={isSaveModel}
className="flex w-full justify-center rounded-md border border-transparent bg-indigo-600 py-2 px-4 text-sm font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2"
>
{apiType === "replicate"
{noFetchProviders.includes(apiType)
? !isSaveLocalModel
? "Save Model"
: "Saving Model..."
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dialoqbase",
"version": "1.8.2",
"version": "1.8.3",
"description": "Create chatbots with ease",
"scripts": {
"ui:dev": "pnpm run --filter ui dev",
Expand Down
3 changes: 2 additions & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"@langchain/cohere": "^0.0.6",
"@langchain/community": "^0.0.35",
"@langchain/google-genai": "^0.0.10",
"@langchain/groq": "^0.0.3",
"@langchain/openai": "^0.0.18",
"@prisma/client": "^5.9.1",
"@slack/bolt": "^3.13.2",
Expand Down Expand Up @@ -81,6 +80,7 @@
"replicate": "^0.26.0",
"sitemapper": "^3.2.6",
"ts-node": "^10.9.1",
"turndown": "^7.1.3",
"unique-names-generator": "^4.7.1",
"wavefile": "^11.0.0",
"yt-transcript": "^0.0.2",
Expand All @@ -91,6 +91,7 @@
"@types/node": "20.4.4",
"@types/pubsub-js": "^1.8.3",
"@types/tap": "^15.0.5",
"@types/turndown": "^5.0.4",
"c8": "9.0.0",
"fastify-tsconfig": "2.0.0",
"prisma": "^5.9.1",
Expand Down
3 changes: 3 additions & 0 deletions server/prisma/migrations/q_27/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- AlterTable
ALTER TABLE "Bot" ADD COLUMN "noOfChatHistoryInContext" INTEGER DEFAULT 15,
ADD COLUMN "semanticSearchSimilarityScore" TEXT DEFAULT 'none';
68 changes: 35 additions & 33 deletions server/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,40 @@ datasource db {
}

model Bot {
id String @id @default(cuid())
publicId String @unique @default(uuid())
name String
user_id Int?
User User? @relation(fields: [user_id], references: [user_id])
description String?
createdAt DateTime @default(now())
temperature Float @default(0.7)
noOfDocumentsToRetrieve Int? @default(4)
model String @default("gpt-3.5-turbo")
provider String @default("openai")
embedding String @default("openai")
streaming Boolean @default(false)
showRef Boolean @default(false)
questionGeneratorPrompt String @default("Given the following conversation and a follow up question, rephrase the follow up question to be a standalone question. Chat History: {chat_history} Follow Up Input: {question} Standalone question:")
qaPrompt String @default("You are a helpful AI assistant. Use the following pieces of context to answer the question at the end. If you don't know the answer, just say you don't know. DO NOT try to make up an answer. If the question is not related to the context, politely respond that you are tuned to only answer questions that are related to the context. {context} Question: {question} Helpful answer in markdown:")
voice_to_text_type String @default("web_api")
text_to_voice_enabled Boolean @default(false)
text_to_voice_type String @default("web_api")
text_to_voice_type_metadata Json @default("{}") @db.Json
use_hybrid_search Boolean @default(false)
haveDataSourcesBeenAdded Boolean @default(false)
use_rag Boolean @default(false)
bot_protect Boolean @default(false)
bot_api_key String?
bot_model_api_key String?
options Json? @default("{}") @db.Json
BotAppearance BotAppearance[]
document BotDocument[]
BotIntegration BotIntegration[]
BotPlayground BotPlayground[]
source BotSource[]
id String @id @default(cuid())
publicId String @unique @default(uuid())
name String
user_id Int?
User User? @relation(fields: [user_id], references: [user_id])
description String?
createdAt DateTime @default(now())
temperature Float @default(0.7)
noOfDocumentsToRetrieve Int? @default(4)
noOfChatHistoryInContext Int? @default(15)
semanticSearchSimilarityScore String? @default("none")
model String @default("gpt-3.5-turbo")
provider String @default("openai")
embedding String @default("openai")
streaming Boolean @default(false)
showRef Boolean @default(false)
questionGeneratorPrompt String @default("Given the following conversation and a follow up question, rephrase the follow up question to be a standalone question. Chat History: {chat_history} Follow Up Input: {question} Standalone question:")
qaPrompt String @default("You are a helpful AI assistant. Use the following pieces of context to answer the question at the end. If you don't know the answer, just say you don't know. DO NOT try to make up an answer. If the question is not related to the context, politely respond that you are tuned to only answer questions that are related to the context. {context} Question: {question} Helpful answer in markdown:")
voice_to_text_type String @default("web_api")
text_to_voice_enabled Boolean @default(false)
text_to_voice_type String @default("web_api")
text_to_voice_type_metadata Json @default("{}") @db.Json
use_hybrid_search Boolean @default(false)
haveDataSourcesBeenAdded Boolean @default(false)
use_rag Boolean @default(false)
bot_protect Boolean @default(false)
bot_api_key String?
bot_model_api_key String?
options Json? @default("{}") @db.Json
BotAppearance BotAppearance[]
document BotDocument[]
BotIntegration BotIntegration[]
BotPlayground BotPlayground[]
source BotSource[]
}

model BotSource {
Expand Down Expand Up @@ -96,7 +98,7 @@ model DialoqbaseSettings {
hideDefaultModels Boolean? @default(false)
defaultChatModel String @default("gpt-3.5-turbo-dbase")
defaultEmbeddingModel String @default("dialoqbase_eb_text-embedding-ada-002")
ollamaURL String? @default("http://host.docker.internal:11434")
ollamaURL String? @default("http://host.docker.internal:11434")
}

model BotIntegration {
Expand Down
8 changes: 8 additions & 0 deletions server/prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,14 @@ const LLMS: {
stream_available: true,
model_provider: "Groq",
},
{
model_id: "gpt-4o-dbase",
name: "GPT-4o (OpenAI)",
model_type: "chat",
stream_available: true,
model_provider: "OpenAI",
config: "{}",
}
];

const EMBEDDING_MODELS: {
Expand Down

0 comments on commit 2e8c43b

Please sign in to comment.