Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.4.3 #152

Merged
merged 5 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .github/workflows/next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,4 @@ jobs:
with:
tags: |
n4z3m/dialoqbase-next:latest
push: true
platforms: linux/amd64,linux/arm64
cache-from: type=registry,ref=n4z3m/dialoqbase-next:latest
cache-to: type=inline
push: true
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.4.2",
"version": "1.4.3",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
113 changes: 57 additions & 56 deletions app/ui/src/components/Bot/Playground/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,24 +110,27 @@ export const PlaygroundgForm = () => {
})}
className="shrink-0 flex-grow flex items-center "
>
<div className="relative flex max-h-40 w-full grow flex-col overflow-hidden bg-background px-8 rounded-md border sm:px-12 items-center">
<div className="flex items-center p-2 rounded-full border bg-gray-100 w-full">
<textarea
// disabled={isSendinhg}
onKeyDown={(e) => {
if (e.key === "Enter" && !e.shiftKey && !isSending) {
e.preventDefault();
form.onSubmit(async (value) => {
if (value.message.trim().length === 0) {
return;
}
form.reset();
resetHeight();
await sendMessage(value.message);
})();
}
}}
ref={textareaRef}
className={`min-h-[40px] w-full resize-none border-0 bg-transparent py-[1rem] m-0 focus:ring-0 focus-visible:ring-0 dark:bg-transparent pr-2 md:pr-0 ${
listening && "placeholder:italic"
}`}
// className="min-h-[60px] w-full resize-none bg-transparent px-4 py-[1.3rem] focus-within:outline-none sm:text-sm focus:ring-0 focus-visible:ring-0 dark:bg-transparent "
// className={`min-h-[32px] w-full resize-none border-0 bg-transparent py-[0.8rem] m-0 focus:ring-0 focus-visible:ring-0 dark:bg-transparent ${
// listening && "placeholder:italic"
// }`}
className="rounded-full pl-4 pr-2 py-2 w-full resize-none bg-transparent focus-within:outline-none sm:text-sm focus:ring-0 focus-visible:ring-0 ring-0 dark:ring-0 border-0"
required
rows={1}
tabIndex={0}
Expand All @@ -137,60 +140,58 @@ export const PlaygroundgForm = () => {
{...form.getInputProps("message")}
/>
{!hideListening && (
<div className="absolute right-0 top-4 sm:right-4">
<button
disabled={isSending}
onClick={() => {
if (!listening) {
listen({
lang: defaultSpeechToTextLanguage,
});
} else {
stop();
}
}}
type="button"
className={`p-0 mr-2 text-gray-500 ${
listening &&
"animate-pulse ring-2 ring-blue-500 rounded-full ring-opacity-50"
}`}
<button
disabled={isSending}
onClick={() => {
if (!listening) {
listen({
lang: defaultSpeechToTextLanguage,
});
} else {
stop();
}
}}
type="button"
className={`p-0 mr-2 text-gray-500 ${
listening &&
"animate-pulse ring-2 ring-blue-500 rounded-full ring-opacity-50"
}`}
>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
className="h-6 w-6"
viewBox="0 0 24 24"
>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
className="h-6 w-6"
viewBox="0 0 24 24"
>
<path d="M12 2a3 3 0 00-3 3v7a3 3 0 006 0V5a3 3 0 00-3-3z"></path>
<path d="M19 10v2a7 7 0 01-14 0v-2"></path>
<path d="M12 19L12 22"></path>
</svg>
</button>
</div>
<path d="M12 2a3 3 0 00-3 3v7a3 3 0 006 0V5a3 3 0 00-3-3z"></path>
<path d="M19 10v2a7 7 0 01-14 0v-2"></path>
<path d="M12 19L12 22"></path>
</svg>
</button>
)}
</div>
<button
disabled={isSending}
className="ml-6 rounded-md bg-black p-3 text-white disabled:opacity-40"
>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
className="h-4 w-4"
viewBox="0 0 24 24"
<button
disabled={isSending || form.values.message.length === 0}
className="mx-2 flex items-center justify-center w-10 h-10 text-white bg-black rounded-xl disabled:opacity-50"
>
<path d="M9 10L4 15 9 20"></path>
<path d="M20 4v7a4 4 0 01-4 4H4"></path>
</svg>
</button>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
className="h-6 w-6"
viewBox="0 0 24 24"
>
<path d="M9 10L4 15 9 20"></path>
<path d="M20 4v7a4 4 0 01-4 4H4"></path>
</svg>
</button>
</div>
</form>
</div>
</div>
Expand Down
6 changes: 1 addition & 5 deletions app/ui/src/components/Bot/Playground/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@ export const PlaygroundMessage = (props: Props) => {
</div>
<div className="relative flex w-[calc(100%-50px)] flex-col gap-1 md:gap-3 lg:w-[calc(100%-115px)]">
<div className="flex flex-grow flex-col gap-3">
{props.isBot ? (
<Markdown message={props.message} />
) : (
<p className="text-sm">{props.message}</p>
)}
<Markdown message={props.message} />
</div>

{props.isBot && (
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.4.2",
"version": "1.4.3",
"description": "Create chatbots with ease",
"scripts": {
"ui:dev": "pnpm run --filter ui dev",
Expand Down
12 changes: 8 additions & 4 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"scripts": {
"test": "npm run build:ts && tsc -p test/tsconfig.json && tap --ts \"test/**/*.test.ts\"",
"start:test": "npm run build:ts && fastify start dist/app.js",
"start": "npx prisma migrate deploy && fastify start app.js",
"start": "npx prisma migrate deploy && npx prisma db seed && fastify start app.js",
"seed": "npx prisma db seed",
"build:ts": "tsc && copyfiles -u 1 \"src/**/*.js \" dist",
"build": "tsc && copyfiles -u 1 \"src/**/*.js \" dist",
"db": "prisma generate",
Expand All @@ -19,7 +20,7 @@
"dev:start": "fastify start --ignore-watch=uploads,.ts$ -w -P dist/app.js"
},
"keywords": [],
"author": "",
"author": "",
"license": "MIT",
"dependencies": {
"@fastify/autoload": "^5.0.0",
Expand Down Expand Up @@ -71,6 +72,7 @@
"sitemapper": "^3.2.6",
"unique-names-generator": "^4.7.1",
"wavefile": "^11.0.0",
"ts-node": "^10.9.1",
"ytdl-core": "^4.11.5"
},
"devDependencies": {
Expand All @@ -81,7 +83,9 @@
"fastify-tsconfig": "^1.0.1",
"prisma": "5",
"tap": "^16.1.0",
"ts-node": "^10.4.0",
"typescript": "^4.5.4"
},
"prisma": {
"seed": "ts-node prisma/seed.ts"
}
}
}
50 changes: 50 additions & 0 deletions server/prisma/seed.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { PrismaClient } from "@prisma/client";
const prisma = new PrismaClient();

const MODELS = [
{
name: "Claude 2.1 (Anthropic)",
model_id: "claude-2.1-dbase",
model_type: "chat",
model_provider: "Anthropic",
stream_available: true,
local_model: false,
config: "{}",
},
{
name: "Claude Instant 1.2 (Anthropic)",
model_id: "claude-instant-1.2-dbase",
model_type: "chat",
model_provider: "Anthropic",
stream_available: true,
local_model: false,
config: "{}",
},
];

const newModels = async () => {
console.log("Seeding new models...");
for (const model of MODELS) {
await prisma.dialoqbaseModels.upsert({
where: {
model_id: model.model_id,
},
update: {},
create: model,
});
}
};

const main = async () => {
await newModels();
};

main()
.then(async () => {
await prisma.$disconnect();
})
.catch(async (e) => {
console.error(e);
await prisma.$disconnect();
process.exit(1);
});
22 changes: 22 additions & 0 deletions server/src/loader/docx.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { BufferLoader } from "langchain/document_loaders/fs/buffer";
import { Document } from "langchain/document";
import * as mammoth from "mammoth";

export class DialoqbaseDocxLoader extends BufferLoader {
constructor(filePathOrBlob: string | Blob) {
super(filePathOrBlob);
}

public async parse(
raw: Buffer,
metadata: Document["metadata"]
): Promise<Document[]> {
const data = await mammoth.extractRawText({ buffer: raw });
const text = data.value;
const meta = { source: this.filePathOrBlob };
if (text) {
return [new Document({ pageContent: text, metadata: meta })];
}
return [];
}
}
11 changes: 5 additions & 6 deletions server/src/queue/controllers/docx.controller.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { DocxLoader } from "langchain/document_loaders/fs/docx";
// import { DocxLoader } from "langchain/document_loaders/fs/docx";
import { QSource } from "../type";
import { RecursiveCharacterTextSplitter } from "langchain/text_splitter";
import { DialoqbaseVectorStore } from "../../utils/store";
import { embeddings } from "../../utils/embeddings";
import { DialoqbaseDocxLoader } from "../../loader/docx";

export const DocxQueueController = async (
source: QSource,
) => {
export const DocxQueueController = async (source: QSource) => {
console.log("loading docx");

const location = source.location!;
const loader = new DocxLoader(location);
const loader = new DialoqbaseDocxLoader(location);
const docs = await loader.load();

const textSplitter = new RecursiveCharacterTextSplitter({
Expand All @@ -25,6 +24,6 @@ export const DocxQueueController = async (
{
botId: source.botId,
sourceId: source.id,
},
}
);
};
2 changes: 1 addition & 1 deletion server/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6315,7 +6315,7 @@ ts-mixer@^6.0.3:
resolved "https://registry.yarnpkg.com/ts-mixer/-/ts-mixer-6.0.3.tgz#69bd50f406ff39daa369885b16c77a6194c7cae6"
integrity sha512-k43M7uCG1AkTyxgnmI5MPwKoUvS/bRvLvUb7+Pgpdlmok8AoqmUaZxUUw8zKM5B1lqZrt41GjYgnvAi0fppqgQ==

ts-node@^10.4.0:
ts-node@^10.9.1:
version "10.9.1"
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.1.tgz#e73de9102958af9e1f0b168a6ff320e25adcff4b"
integrity sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==
Expand Down