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.7.6 #232

Merged
merged 5 commits into from
Mar 9, 2024
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
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.7.5",
"version": "1.7.6",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
111 changes: 98 additions & 13 deletions app/ui/src/components/Common/BotForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import { YoutubeIcon } from "../Icons/YoutubeIcon";
import { ApiIcon } from "../Icons/ApiIcon";
import { SitemapIcon } from "../Icons/SitemapIcon";
import { useCreateConfig } from "../../hooks/useCreateConfig";
import { useQuery } from "@tanstack/react-query";
import api from "../../services/api";

type Props = {
createBot: (values: any) => void;
Expand All @@ -48,6 +50,9 @@ export const BotForm = ({
}: Props) => {
const { data: botConfig, status: botConfigStatus } = useCreateConfig();

const youtubeMode = Form.useWatch(["options", "youtube_mode"], form);
const url = Form.useWatch(["content"], form);

const [availableSources] = React.useState([
{
id: 1,
Expand Down Expand Up @@ -331,21 +336,36 @@ export const BotForm = ({
},
]}
>
<Input type="url" placeholder="Enter the youtube URL" />
<Input
type="url"
size="large"
placeholder="Enter the youtube URL"
/>
</Form.Item>

<p className="text-sm text-gray-500">
If you find any issues, please report them on{" "}
<a
href="https://github.com/n4ze3m/dialoqbase/issues/new?title=Github%20issue&labels=bug"
target="_blank"
rel="noreferrer"
className="font-medium text-indigo-600 hover:text-indigo-500"
>
GitHub
</a>
.
</p>
<Form.Item
name={["options", "youtube_mode"]}
label="Youtube mode"
rules={[
{
required: true,
message: "Please select a youtube mode",
},
]}
>
<Select
options={[
{
label: "Transcribe using Whisper",
value: "whisper",
},
{
label: "Youtube Transcript",
value: "transcript",
},
]}
/>
</Form.Item>
</>
),
},
Expand Down Expand Up @@ -426,6 +446,31 @@ export const BotForm = ({
const [selectedSource, _setSelectedSource] = React.useState<any>(
showEmbeddingAndModels ? null : availableSources[0]
);
const { data: transcripts, isLoading: isFetchingTranscript } = useQuery({
queryKey: [
"fetchYoutubeTranscript",
url,
youtubeMode,
selectedSource?.value,
],
queryFn: async () => {
if (Boolean(url) && youtubeMode === "transcript") {
const res = await api.get("/yt/transcript?url=" + url);
return res.data["data"] as {
name: {
simpleText: string;
};
languageCode: string;
}[];
}

return [];
},
enabled:
Boolean(url) &&
youtubeMode === "transcript" &&
selectedSource?.value === "youtube",
});

return (
<>
Expand All @@ -446,6 +491,7 @@ export const BotForm = ({
method: "get",
headers: "{}",
body: "{}",
youtube_mode: "whisper",
},
}}
>
Expand Down Expand Up @@ -533,6 +579,45 @@ export const BotForm = ({
</Row>
)}

{selectedSource &&
selectedSource.value === "youtube" &&
youtubeMode === "transcript" && (
<>
<Form.Item
name={["options", "language_code"]}
label="Select language"
rules={[
{
required: true,
message: "Please select a language",
},
]}
>
<Select
loading={isFetchingTranscript}
placeholder="Select language"
options={transcripts?.map((transcript) => ({
label: transcript.name.simpleText,
value: transcript.languageCode,
}))}
/>
</Form.Item>

<p className="text-sm text-gray-500">
If you find any issues, please report them on{" "}
<a
href="https://github.com/n4ze3m/dialoqbase/issues/new?title=Github%20issue&labels=bug"
target="_blank"
rel="noreferrer"
className="font-medium text-indigo-600 hover:text-indigo-500"
>
GitHub
</a>
.
</p>
</>
)}

<Form.Item hidden={!showEmbeddingAndModels} noStyle>
<Divider />
</Form.Item>
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.7.5",
"version": "1.7.6",
"description": "Create chatbots with ease",
"scripts": {
"ui:dev": "pnpm run --filter ui dev",
Expand Down
15 changes: 13 additions & 2 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
"keywords": [],
"author": "",
"license": "MIT",
"engines": {
"node": ">=18"
},
"dependencies": {
"@fastify/autoload": "^5.0.0",
"@fastify/cookie": "^9.1.0",
Expand All @@ -38,7 +41,11 @@
"@google-ai/generativelanguage": "^2.0.0",
"@grammyjs/files": "^1.0.4",
"@huggingface/inference": "1",
"@langchain/google-genai": "^0.0.2",
"@langchain/anthropic": "^0.1.4",
"@langchain/cohere": "^0.0.5",
"@langchain/community": "^0.0.35",
"@langchain/google-genai": "^0.0.10",
"@langchain/openai": "^0.0.18",
"@prisma/client": "^5.9.1",
"@slack/bolt": "^3.13.2",
"@supabase/supabase-js": "^2.24.0",
Expand All @@ -64,7 +71,7 @@
"html-to-text": "^9.0.5",
"ignore": "^5.2.4",
"ioredis": "^5.3.2",
"langchain": "^0.0.206",
"langchain": "^0.1.25",
"mammoth": "^1.6.0",
"pdf-parse": "^1.1.1",
"pdfjs-dist": "^3.7.107",
Expand All @@ -74,6 +81,7 @@
"ts-node": "^10.9.1",
"unique-names-generator": "^4.7.1",
"wavefile": "^11.0.0",
"yt-transcript": "^0.0.2",
"ytdl-core": "^4.11.5"
},
"devDependencies": {
Expand All @@ -86,6 +94,9 @@
"tap": "^16.1.0",
"typescript": "^4.5.4"
},
"resolutions": {
"@langchain/core": "0.1.43"
},
"prisma": {
"seed": "ts-node prisma/seed.ts"
}
Expand Down
51 changes: 32 additions & 19 deletions server/prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ const LLMS: {
model_id: "gemini-pro",
name: "Gemini Pro (Google)",
model_type: "chat",
stream_available: false,
stream_available: true,
model_provider: "Google",
local_model: false,
config: "{}",
Expand All @@ -271,24 +271,24 @@ const LLMS: {
local_model: false,
config: "{}",
},
// {
// name: "Claude 3 Opus 20240229 (Anthropic)",
// model_id: "claude-3-opus-20240229-dbase",
// model_type: "chat",
// model_provider: "Anthropic",
// stream_available: true,
// local_model: false,
// config: "{}",
// },
// {
// name: "Claude 3 Sonnet 20240229 (Anthropic)",
// model_id: "claude-3-sonnet-20240229-dbase",
// model_type: "chat",
// model_provider: "Anthropic",
// stream_available: true,
// local_model: false,
// config: "{}",
// },
{
name: "Claude 3 Opus 20240229 (Anthropic)",
model_id: "claude-3-opus-20240229-dbase",
model_type: "chat",
model_provider: "Anthropic",
stream_available: true,
local_model: false,
config: "{}",
},
{
name: "Claude 3 Sonnet 20240229 (Anthropic)",
model_id: "claude-3-sonnet-20240229-dbase",
model_type: "chat",
model_provider: "Anthropic",
stream_available: true,
local_model: false,
config: "{}",
},
];

const EMBEDDING_MODELS: {
Expand Down Expand Up @@ -469,10 +469,23 @@ const replaceOldEmbeddings = async () => {

}


const updateGeminiStreamingToTrue = async () => {
await prisma.dialoqbaseModels.update({
where: {
model_id: "gemini-pro",
},
data: {
stream_available: true,
},
});
}

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

main()
Expand Down
12 changes: 6 additions & 6 deletions server/src/chain/index.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { BaseLanguageModel } from "langchain/base_language";
import { Document } from "langchain/document";
import { BaseLanguageModel } from "@langchain/core/language_models/base";
import { Document } from "@langchain/core/documents";
import {
ChatPromptTemplate,
MessagesPlaceholder,
PromptTemplate,
} from "langchain/prompts";
import { AIMessage, BaseMessage, HumanMessage } from "langchain/schema";
import { StringOutputParser } from "langchain/schema/output_parser";
} from "@langchain/core/prompts";
import { AIMessage, BaseMessage, HumanMessage } from "@langchain/core/messages";
import { StringOutputParser } from "@langchain/core/output_parsers";
import {
Runnable,
RunnableBranch,
RunnableLambda,
RunnableMap,
RunnableSequence,
} from "langchain/schema/runnable";
} from "@langchain/core/runnables";
type RetrievalChainInput = {
chat_history: string;
question: string;
Expand Down
2 changes: 1 addition & 1 deletion server/src/embeddings/transformer-embedding.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Embeddings, EmbeddingsParams } from "langchain/embeddings/base";
import { Embeddings, EmbeddingsParams } from "@langchain/core/embeddings";
import {
piplelineTransformer,
//@ts-ignore
Expand Down
2 changes: 1 addition & 1 deletion server/src/handlers/api/v1/bot/playground/chat.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { DialoqbaseVectorStore } from "../../../../../utils/store";
import { embeddings } from "../../../../../utils/embeddings";
import { chatModelProvider } from "../../../../../utils/models";
import { DialoqbaseHybridRetrival } from "../../../../../utils/hybrid";
import { BaseRetriever } from "langchain/schema/retriever";
import { BaseRetriever } from "@langchain/core/retrievers";
import { Document } from "langchain/document";
import {
createChain,
Expand Down
22 changes: 22 additions & 0 deletions server/src/handlers/api/v1/yt/get.handler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { FastifyRequest, FastifyReply } from "fastify";
import { GetYoutubeTranscript } from "./types";
import { YtTranscript } from "yt-transcript"

const getYoutubeTranscript = async (url: string) => {
const transcript = new YtTranscript({ url });
const data = await transcript.listAllTranscripts();
return data;
}

export const getYoutubeTranscriptHandler = async (
request: FastifyRequest<GetYoutubeTranscript>,
reply: FastifyReply
) => {
const { url } = request.query;

const available = await getYoutubeTranscript(url);

return {
data: available as any
}
}
1 change: 1 addition & 0 deletions server/src/handlers/api/v1/yt/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./get.handler"
5 changes: 5 additions & 0 deletions server/src/handlers/api/v1/yt/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export type GetYoutubeTranscript = {
Querystring: {
url: string;
}
}
2 changes: 1 addition & 1 deletion server/src/handlers/bot/api.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { embeddings } from "../../utils/embeddings";
import { chatModelProvider } from "../../utils/models";
import { nextTick } from "./post.handler";
import { Document } from "langchain/document";
import { BaseRetriever } from "langchain/schema/retriever";
import { BaseRetriever } from "@langchain/core/retrievers";
import { DialoqbaseHybridRetrival } from "../../utils/hybrid";
import { createChain, groupMessagesByConversation } from "../../chain";

Expand Down
2 changes: 1 addition & 1 deletion server/src/handlers/bot/post.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ChatRequestBody } from "./types";
import { DialoqbaseVectorStore } from "../../utils/store";
import { embeddings } from "../../utils/embeddings";
import { chatModelProvider } from "../../utils/models";
import { BaseRetriever } from "langchain/schema/retriever";
import { BaseRetriever } from "@langchain/core/retrievers";
import { DialoqbaseHybridRetrival } from "../../utils/hybrid";
import { Document } from "langchain/document";
import { createChain, groupMessagesByConversation } from "../../chain";
Expand Down
2 changes: 1 addition & 1 deletion server/src/integration/handlers/discord.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { DialoqbaseVectorStore } from "../../utils/store";
import { chatModelProvider } from "../../utils/models";
import { DialoqbaseHybridRetrival } from "../../utils/hybrid";
import { Document } from "langchain/document";
import { BaseRetriever } from "langchain/schema/retriever";
import { BaseRetriever } from "@langchain/core/retrievers";
import { createChain } from "../../chain";
const prisma = new PrismaClient();

Expand Down
Loading