├── .gitignore ├── .vscode ├── extensions.json ├── launch.json └── settings.json ├── README.md ├── admin-ui ├── .env.local.example ├── .env.production ├── .eslintrc.json ├── .gitignore ├── Dockerfile ├── README.md ├── SWR │ └── useCount.tsx ├── components │ ├── APIKeyOperations.tsx │ ├── EditableField.tsx │ ├── LoginButton.tsx │ ├── LogoutButton.tsx │ ├── RateLimitForm.tsx │ ├── RateLimitModal.tsx │ ├── Stats.tsx │ └── charts │ │ ├── RequestChart.tsx │ │ ├── SWR │ │ └── SWRRequestChart.tsx │ │ └── helpers │ │ └── DurationSelector.tsx ├── constants.ts ├── layout │ ├── Navbar.tsx │ └── index.tsx ├── next.config.js ├── package.json ├── pages │ ├── _app.tsx │ ├── api-keys │ │ ├── create.tsx │ │ └── index.tsx │ ├── configuration.tsx │ ├── index.tsx │ └── logs.tsx ├── public │ ├── favicon.ico │ ├── next.svg │ ├── thirteen.svg │ └── vercel.svg ├── scripts │ └── genAntdCss.tsx ├── styles │ ├── Home.module.css │ └── globals.css ├── theme │ └── index.tsx ├── tsconfig.json ├── tsconfig.node.json └── utils │ ├── api-handlers.tsx │ ├── api-keys.tsx │ ├── api-types.tsx │ ├── charts.tsx │ └── fetcher.ts ├── btvep ├── Dockerfile ├── README.md ├── btvep │ ├── __init__.py │ ├── __main__.py │ ├── api │ │ ├── __init__.py │ │ ├── admin │ │ │ ├── __init__.py │ │ │ ├── api_keys.py │ │ │ ├── config.py │ │ │ ├── logs.py │ │ │ └── rate_limits.py │ │ ├── api_keys.py │ │ ├── chat.py │ │ ├── conversation.py │ │ └── dependencies.py │ ├── btvep_models.py │ ├── chat_helpers.py │ ├── cli │ │ ├── __init__.py │ │ ├── config.py │ │ ├── key.py │ │ ├── logs.py │ │ ├── ratelimit.py │ │ └── user.py │ ├── config.py │ ├── constants.py │ ├── db │ │ ├── __init__.py │ │ ├── api_keys.py │ │ ├── request.py │ │ ├── tables.py │ │ ├── user.py │ │ └── utils.py │ ├── filter.py │ ├── metagraph.py │ ├── models │ │ ├── key.py │ │ └── user.py │ ├── prompting.py │ ├── server.py │ └── validator_prompter.py ├── dist │ ├── btvep-0.1.0-py3-none-any.whl │ ├── btvep-0.1.0.tar.gz │ ├── btvep-0.1.1-py3-none-any.whl │ ├── btvep-0.1.1.tar.gz │ ├── btvep-0.2.0-py3-none-any.whl │ └── btvep-0.2.0.tar.gz ├── docker-compose.template.yml ├── poetry.lock ├── pyproject.toml └── tests │ ├── __init__.py │ └── test_vendpoint.py ├── chat-ui ├── .dockerignore ├── .env.local.example ├── .eslintrc.json ├── .github │ └── workflows │ │ ├── deploy-docker-image.yaml │ │ └── run-test-suite.yml ├── .gitignore ├── CONTRIBUTING.md ├── Dockerfile ├── Makefile ├── README.md ├── SECURITY.md ├── __tests__ │ └── utils │ │ └── app │ │ └── importExports.test.ts ├── components │ ├── APIKeyOperations.tsx │ ├── Button.tsx │ ├── Buttons │ │ └── SidebarActionButton │ │ │ ├── SidebarActionButton.tsx │ │ │ └── index.ts │ ├── Chat │ │ ├── Chat.tsx │ │ ├── ChatInput.tsx │ │ ├── ChatLoader.tsx │ │ ├── ChatMessage.tsx │ │ ├── ErrorMessageDiv.tsx │ │ ├── MemoizedChatMessage.tsx │ │ ├── PluginSelect.tsx │ │ ├── PromptList.tsx │ │ ├── QuerySettingsModal.tsx │ │ ├── Regenerate.tsx │ │ ├── SystemPrompt.tsx │ │ └── VariableModal.tsx │ ├── Chatbar │ │ ├── Chatbar.context.tsx │ │ ├── Chatbar.state.tsx │ │ ├── Chatbar.tsx │ │ └── components │ │ │ ├── ChatFolders.tsx │ │ │ ├── ChatbarSettings.tsx │ │ │ ├── ClearConversations.tsx │ │ │ ├── Conversation.tsx │ │ │ ├── Conversations.tsx │ │ │ ├── PluginKeys.tsx │ │ │ └── Plugins.tsx │ ├── Checkbox │ │ └── index.tsx │ ├── DropdownButton.tsx │ ├── Folder │ │ ├── Folder.tsx │ │ └── index.ts │ ├── Input.tsx │ ├── LoginButton.tsx │ ├── LogoutButton.tsx │ ├── Markdown │ │ ├── CodeBlock.tsx │ │ └── MemoizedReactMarkdown.tsx │ ├── Mobile │ │ └── Navbar.tsx │ ├── Profile │ │ └── ApiKeyModal.tsx │ ├── Promptbar │ │ ├── PromptBar.context.tsx │ │ ├── Promptbar.state.tsx │ │ ├── Promptbar.tsx │ │ ├── components │ │ │ ├── Prompt.tsx │ │ │ ├── PromptFolders.tsx │ │ │ ├── PromptModal.tsx │ │ │ ├── PromptbarSettings.tsx │ │ │ └── Prompts.tsx │ │ └── index.ts │ ├── QueryStrategySelect.tsx │ ├── RadioButton.tsx │ ├── Search │ │ ├── Search.tsx │ │ └── index.ts │ ├── Select.tsx │ ├── Settings │ │ ├── Import.tsx │ │ ├── Key.tsx │ │ └── SettingDialog.tsx │ ├── Sidebar │ │ ├── Sidebar.tsx │ │ ├── SidebarButton.tsx │ │ ├── components │ │ │ └── OpenCloseButton.tsx │ │ └── index.ts │ └── Spinner │ │ ├── Spinner.tsx │ │ └── index.ts ├── docs │ ├── chatpdf.md │ ├── google_search.md │ ├── scholar-ai.md │ └── what-to-watch.md ├── hooks │ ├── useAPIFetch.tsx │ ├── useApi.ts │ ├── useCreateReducer.ts │ └── useFetch.ts ├── k8s │ └── chatbot-ui.yaml ├── license ├── next-i18next.config.js ├── next.config.js ├── package-lock.json ├── package.json ├── pages │ ├── _app.tsx │ ├── _document.tsx │ ├── api │ │ ├── chat.ts │ │ ├── google.ts │ │ ├── home │ │ │ ├── home.context.tsx │ │ │ ├── home.state.tsx │ │ │ ├── home.tsx │ │ │ └── index.ts │ │ ├── models.ts │ │ ├── plugin.ts │ │ └── plugins │ │ │ ├── chatpdf.ts │ │ │ ├── google-search.ts │ │ │ ├── index.ts │ │ │ ├── open-weather.ts │ │ │ ├── scholar-ai.ts │ │ │ ├── what-to-watch.ts │ │ │ └── world-news.ts │ ├── index.tsx │ └── profile.tsx ├── postcss.config.js ├── prettier.config.js ├── public │ ├── favicon.ico │ ├── locales │ │ ├── ar │ │ │ ├── chat.json │ │ │ ├── common.json │ │ │ ├── markdown.json │ │ │ ├── promptbar.json │ │ │ ├── settings.json │ │ │ └── sidebar.json │ │ ├── bn │ │ │ ├── chat.json │ │ │ ├── common.json │ │ │ ├── markdown.json │ │ │ ├── promptbar.json │ │ │ ├── settings.json │ │ │ └── sidebar.json │ │ ├── ca │ │ │ ├── chat.json │ │ │ ├── common.json │ │ │ ├── markdown.json │ │ │ ├── promptbar.json │ │ │ └── sidebar.json │ │ ├── de │ │ │ ├── chat.json │ │ │ ├── common.json │ │ │ ├── markdown.json │ │ │ ├── promptbar.json │ │ │ ├── settings.json │ │ │ └── sidebar.json │ │ ├── en │ │ │ └── common.json │ │ ├── es │ │ │ ├── chat.json │ │ │ ├── common.json │ │ │ ├── markdown.json │ │ │ ├── promptbar.json │ │ │ ├── settings.json │ │ │ └── sidebar.json │ │ ├── fi │ │ │ ├── chat.json │ │ │ ├── common.json │ │ │ ├── markdown.json │ │ │ ├── promptbar.json │ │ │ ├── settings.json │ │ │ └── sidebar.json │ │ ├── fr │ │ │ ├── chat.json │ │ │ ├── common.json │ │ │ ├── markdown.json │ │ │ ├── promptbar.json │ │ │ ├── settings.json │ │ │ └── sidebar.json │ │ ├── he │ │ │ ├── chat.json │ │ │ ├── common.json │ │ │ ├── markdown.json │ │ │ ├── promptbar.json │ │ │ ├── settings.json │ │ │ └── sidebar.json │ │ ├── id │ │ │ ├── chat.json │ │ │ ├── common.json │ │ │ ├── markdown.json │ │ │ ├── promptbar.json │ │ │ ├── settings.json │ │ │ └── sidebar.json │ │ ├── it │ │ │ ├── chat.json │ │ │ ├── common.json │ │ │ ├── markdown.json │ │ │ ├── promptbar.json │ │ │ ├── settings.json │ │ │ └── sidebar.json │ │ ├── ja │ │ │ ├── chat.json │ │ │ ├── common.json │ │ │ ├── markdown.json │ │ │ ├── promptbar.json │ │ │ ├── settings.json │ │ │ └── sidebar.json │ │ ├── ko │ │ │ ├── chat.json │ │ │ ├── common.json │ │ │ ├── markdown.json │ │ │ ├── promptbar.json │ │ │ ├── settings.json │ │ │ └── sidebar.json │ │ ├── pl │ │ │ ├── chat.json │ │ │ ├── common.json │ │ │ ├── markdown.json │ │ │ ├── promptbar.json │ │ │ ├── settings.json │ │ │ └── sidebar.json │ │ ├── pt │ │ │ ├── chat.json │ │ │ ├── common.json │ │ │ ├── markdown.json │ │ │ ├── promptbar.json │ │ │ ├── settings.json │ │ │ └── sidebar.json │ │ ├── ro │ │ │ ├── chat.json │ │ │ ├── common.json │ │ │ ├── markdown.json │ │ │ ├── promptbar.json │ │ │ ├── settings.json │ │ │ └── sidebar.json │ │ ├── ru │ │ │ ├── chat.json │ │ │ ├── common.json │ │ │ ├── markdown.json │ │ │ ├── promptbar.json │ │ │ ├── settings.json │ │ │ └── sidebar.json │ │ ├── si │ │ │ ├── chat.json │ │ │ ├── common.json │ │ │ ├── markdown.json │ │ │ ├── promptbar.json │ │ │ ├── settings.json │ │ │ └── sidebar.json │ │ ├── sv │ │ │ ├── chat.json │ │ │ ├── common.json │ │ │ ├── markdown.json │ │ │ ├── promptbar.json │ │ │ ├── settings.json │ │ │ └── sidebar.json │ │ ├── te │ │ │ ├── chat.json │ │ │ ├── common.json │ │ │ ├── markdown.json │ │ │ ├── promptbar.json │ │ │ ├── settings.json │ │ │ └── sidebar.json │ │ ├── tr │ │ │ ├── chat.json │ │ │ ├── common.json │ │ │ ├── markdown.json │ │ │ ├── promptbar.json │ │ │ └── sidebar.json │ │ ├── vi │ │ │ ├── chat.json │ │ │ ├── common.json │ │ │ ├── markdown.json │ │ │ ├── promptbar.json │ │ │ ├── settings.json │ │ │ └── sidebar.json │ │ └── zh │ │ │ ├── chat.json │ │ │ ├── common.json │ │ │ ├── markdown.json │ │ │ ├── promptbar.json │ │ │ ├── settings.json │ │ │ └── sidebar.json │ ├── screenshot.png │ └── screenshots │ │ └── screenshot-0402023.jpg ├── styles │ └── globals.css ├── tailwind.config.js ├── tsconfig.json ├── types │ ├── chat.ts │ ├── data.ts │ ├── env.ts │ ├── error.ts │ ├── export.ts │ ├── folder.ts │ ├── google.ts │ ├── index.ts │ ├── openai.ts │ ├── plugin.ts │ ├── prompt.ts │ ├── settings.ts │ └── storage.ts ├── utils │ ├── app │ │ ├── api.ts │ │ ├── clean.ts │ │ ├── codeblock.ts │ │ ├── const.ts │ │ ├── conversation.ts │ │ ├── folders.ts │ │ ├── importExport.ts │ │ ├── prompts.ts │ │ └── settings.ts │ ├── data │ │ └── throttle.ts │ └── server │ │ └── google.ts ├── vitest.config.ts └── yarn.lock ├── docs ├── README.md ├── auth0 │ ├── README.md │ ├── application-allowed-settings.png │ ├── auth0-api-audience.png │ ├── auth0-domain.png │ ├── create-application.png │ ├── new-api-form.png │ └── sidebar-navigation-applications-apis.png ├── cli.md ├── docker.md └── requests.md └── temp.txt /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__ 2 | conda-meta 3 | .env 4 | btvep*.db 5 | config.json 6 | config.bak.json 7 | .DS_Store 8 | dump.rdb 9 | docker-compose.yml -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": ["ms-python.black-formatter"] 3 | } 4 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "FastAPI", 6 | "type": "python", 7 | "request": "launch", 8 | "module": "uvicorn", 9 | "args": [ 10 | "btvep.server:app", 11 | "--host", 12 | "0.0.0.0", 13 | "--port", 14 | "8000", 15 | "--reload" 16 | ], 17 | "jinja": true, 18 | "console": "integratedTerminal", 19 | "justMyCode": false 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "[python]": { 3 | "editor.defaultFormatter": "ms-python.black-formatter" 4 | }, 5 | "python.formatting.provider": "none" 6 | } 7 | -------------------------------------------------------------------------------- /admin-ui/.env.local.example: -------------------------------------------------------------------------------- 1 | NEXT_PUBLIC_API_BASE_URL=https://validator-api.fabhed.dev 2 | NEXT_PUBLIC_AUTH0_DOMAIN= 3 | NEXT_PUBLIC_AUTH0_CLIENT_ID= 4 | NEXT_PUBLIC_AUTH0_REDIRECT_URI=http://localhost:3000 5 | NEXT_PUBLIC_AUTH0_AUDIENCE=http://localhost:8000 6 | -------------------------------------------------------------------------------- /admin-ui/.env.production: -------------------------------------------------------------------------------- 1 | NEXT_PUBLIC_API_BASE_URL=https://chat.nichetensor.com/btvep/ 2 | NEXT_PUBLIC_AUTH0_DOMAIN=dev-qo8eke55w2hw4pak.us.auth0.com 3 | NEXT_PUBLIC_AUTH0_CLIENT_ID=Qu4Gn0VphAOMwIumAzpDibPGONo512Hc 4 | NEXT_PUBLIC_AUTH0_REDIRECT_URI=https://chat.nichetensor.com/admin/ 5 | NEXT_PUBLIC_AUTH0_AUDIENCE=https://dev-qo8eke55w2hw4pak.us.auth0.com/api/v2/ 6 | -------------------------------------------------------------------------------- /admin-ui/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "next/core-web-vitals" 3 | } 4 | -------------------------------------------------------------------------------- /admin-ui/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # next.js 12 | /.next/ 13 | /out/ 14 | 15 | # production 16 | /build 17 | 18 | # misc 19 | .DS_Store 20 | *.pem 21 | .idea/ 22 | .vscode/ 23 | 24 | # debug 25 | npm-debug.log* 26 | yarn-debug.log* 27 | yarn-error.log* 28 | .pnpm-debug.log* 29 | 30 | # local env files 31 | .env*.local 32 | 33 | # vercel 34 | .vercel 35 | 36 | # typescript 37 | *.tsbuildinfo 38 | next-env.d.ts 39 | 40 | # lock files 41 | package-lock.json 42 | yarn.lock 43 | pnpm-lock.yaml 44 | 45 | public/antd.min.css -------------------------------------------------------------------------------- /admin-ui/Dockerfile: -------------------------------------------------------------------------------- 1 | # ---- Base Node ---- 2 | FROM node:19-alpine AS base 3 | WORKDIR /app 4 | COPY package*.json ./ 5 | 6 | # ---- Dependencies ---- 7 | FROM base AS dependencies 8 | RUN npm ci 9 | 10 | # ---- Build ---- 11 | FROM dependencies AS build 12 | COPY . . 13 | RUN npm run build 14 | 15 | # ---- Production ---- 16 | FROM node:19-alpine AS production 17 | WORKDIR /app 18 | COPY --from=dependencies /app/node_modules ./node_modules 19 | 20 | # Copy the build output from the "build" stage 21 | COPY --from=build /app/.next ./.next 22 | COPY --from=build /app/public ./public 23 | COPY --from=build /app/package*.json ./ 24 | COPY --from=build /app/next.config.js ./next.config.js 25 | 26 | # Expose the port the app will run on 27 | EXPOSE 3001 28 | 29 | # Start your Next.js app in production 30 | CMD ["npm", "start", "--", "-p", "3001"] 31 | -------------------------------------------------------------------------------- /admin-ui/README.md: -------------------------------------------------------------------------------- 1 | This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). 2 | 3 | ## Getting Started 4 | 5 | First, run the development server: 6 | 7 | ```bash 8 | npm run dev 9 | # or 10 | yarn dev 11 | ``` 12 | 13 | Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. 14 | 15 | You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file. 16 | 17 | [API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`. 18 | 19 | The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages. 20 | 21 | This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font. 22 | 23 | ## Learn More 24 | 25 | To learn more about Next.js, take a look at the following resources: 26 | 27 | - [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. 28 | - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. 29 | 30 | You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! 31 | 32 | ## Deploy on Vercel 33 | 34 | The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. 35 | 36 | Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. 37 | -------------------------------------------------------------------------------- /admin-ui/SWR/useCount.tsx: -------------------------------------------------------------------------------- 1 | import useSWR from "swr"; 2 | import fetcher from "../utils/fetcher"; 3 | 4 | interface CommonFilters { 5 | key?: string; 6 | responder_hotkey?: string; 7 | is_api_success?: boolean; 8 | is_success?: boolean; 9 | start?: number; 10 | end?: number; 11 | unique_api_keys?: boolean; 12 | } 13 | 14 | export const useCount = (filters: CommonFilters) => { 15 | const queryString = Object.keys(filters) 16 | .map( 17 | (key) => 18 | `${encodeURIComponent(key)}=${encodeURIComponent( 19 | filters[key as keyof CommonFilters] || "" 20 | )}` 21 | ) 22 | .join("&"); 23 | 24 | const { 25 | data: countData, 26 | error, 27 | isLoading, 28 | } = useSWR(`/admin/logs/count?${queryString}`, fetcher); 29 | 30 | return { 31 | count: countData?.count, 32 | isLoading: isLoading, 33 | error, 34 | }; 35 | }; 36 | -------------------------------------------------------------------------------- /admin-ui/components/LoginButton.tsx: -------------------------------------------------------------------------------- 1 | import { useAuth0 } from "@auth0/auth0-react"; 2 | import { Button } from "antd"; 3 | const LoginButton = () => { 4 | const { loginWithRedirect } = useAuth0(); 5 | 6 | return ; 7 | }; 8 | 9 | export default LoginButton; 10 | -------------------------------------------------------------------------------- /admin-ui/components/LogoutButton.tsx: -------------------------------------------------------------------------------- 1 | import { useAuth0 } from "@auth0/auth0-react"; 2 | import { IconLogout } from "@tabler/icons-react"; 3 | import { Button } from "antd"; 4 | 5 | const LogoutButton = () => { 6 | const { logout } = useAuth0(); 7 | 8 | return ( 9 | 22 | ); 23 | }; 24 | 25 | export default LogoutButton; 26 | -------------------------------------------------------------------------------- /admin-ui/components/RateLimitModal.tsx: -------------------------------------------------------------------------------- 1 | import { Form, Input, Modal, Typography, message } from "antd"; 2 | import { useEffect, useState } from "react"; 3 | import { RateLimit, RateLimitForm } from "./RateLimitForm"; 4 | import { ApiKeyDataType } from "../pages/api-keys"; 5 | import axios from "axios"; 6 | import { mutate } from "swr"; 7 | import { RateLimitEntry } from "../utils/api-types"; 8 | import React from "react"; 9 | 10 | const { Paragraph, Title } = Typography; 11 | 12 | export const RateLimitModal = ({ 13 | apiKey, 14 | open, 15 | setOpen, 16 | }: { 17 | apiKey: ApiKeyDataType | null; 18 | open: boolean; 19 | setOpen: (open: boolean) => void; 20 | }) => { 21 | const [enabled, setEnabled] = useState(false); 22 | const [rateLimits, setRateLimits] = useState([]); 23 | useEffect(() => { 24 | if (!apiKey) return; 25 | setEnabled(apiKey.rate_limits_enabled || false); 26 | setRateLimits(apiKey.rate_limits ? JSON.parse(apiKey.rate_limits) : []); 27 | }, [apiKey]); 28 | 29 | if (!apiKey) return null; 30 | 31 | const save = async (values: { 32 | rate_limits_enabled?: boolean; 33 | rate_limits?: RateLimitEntry[]; 34 | }) => { 35 | try { 36 | await axios.patch(`/admin/api-keys/${apiKey.id}/`, values); 37 | message.success("Successfully saved changes"); 38 | mutate("/admin/api-keys/"); 39 | } catch (err) { 40 | message.error("Failed to save changes"); 41 | console.error(err); 42 | } 43 | }; 44 | 45 | return ( 46 | <> 47 | setOpen(false)} 50 | footer={null} 51 | width="90vw" 52 | > 53 | { 57 | setEnabled(enabled); 58 | save({ rate_limits_enabled: enabled }); 59 | // update in api 60 | }} 61 | rateLimits={rateLimits} 62 | onRateLimitsChange={setRateLimits} 63 | onSave={(rateLimits) => save({ rate_limits: rateLimits })} 64 | > 65 | You are viewing the rate limits for the API key: 66 | 67 |
{apiKey?.api_key}
68 |
69 |
70 | 71 | ); 72 | }; 73 | -------------------------------------------------------------------------------- /admin-ui/components/Stats.tsx: -------------------------------------------------------------------------------- 1 | import { Card, Col, Row, Statistic } from "antd"; 2 | import { DateTime } from "luxon"; 3 | import { useCount } from "../SWR/useCount"; 4 | 5 | export default function Stats() { 6 | const { count: count24h, isLoading: count24hIsLoading } = useCount({ 7 | start: DateTime.now().minus({ days: 1 }).toUnixInteger()!, 8 | }); 9 | const { count: count24hKeys, isLoading: count24hKeysIsLoading } = useCount({ 10 | start: DateTime.now().minus({ days: 1 }).toUnixInteger()!, 11 | unique_api_keys: true, 12 | }); 13 | 14 | return ( 15 | 16 | 17 | 18 | 24 | 25 | 26 | 27 | 28 | 34 | 35 | 36 | 37 | ); 38 | } 39 | -------------------------------------------------------------------------------- /admin-ui/components/charts/helpers/DurationSelector.tsx: -------------------------------------------------------------------------------- 1 | import { Select } from "antd"; 2 | import { Duration } from "luxon"; 3 | import React from "react"; 4 | 5 | const { Option } = Select; 6 | 7 | export const DurationSelectors = ({ 8 | bucketDuration, 9 | setBucketDuration, 10 | historyDuration, 11 | setHistoryDuration, 12 | }) => { 13 | const minWidth = 100; 14 | return ( 15 |
23 | Granularity: 24 | 36 | 37 | History Duration: 38 | 51 |
52 | ); 53 | }; 54 | -------------------------------------------------------------------------------- /admin-ui/constants.ts: -------------------------------------------------------------------------------- 1 | export const site_name = "Validator Endpoint"; 2 | export const github_repo_url = "https://github.com/fabhed/validator-endpoint"; 3 | -------------------------------------------------------------------------------- /admin-ui/layout/Navbar.tsx: -------------------------------------------------------------------------------- 1 | import { MenuFoldOutlined, MenuUnfoldOutlined } from "@ant-design/icons"; 2 | import { Button, Layout, theme } from "antd"; 3 | import "antd/dist/reset.css"; 4 | const { Header } = Layout; 5 | import { Typography } from "antd"; 6 | import { relative } from "path"; 7 | const { Title } = Typography; 8 | 9 | export default function Navbar({ siderCollapsed, setCollapsed }) { 10 | const { 11 | token: { colorBgContainer }, 12 | } = theme.useToken(); 13 | return ( 14 |
21 |
62 | ); 63 | } 64 | -------------------------------------------------------------------------------- /admin-ui/next.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('next').NextConfig} */ 2 | const nextConfig = { 3 | reactStrictMode: true, 4 | transpilePackages: ['antd'], 5 | }; 6 | 7 | module.exports = nextConfig; 8 | -------------------------------------------------------------------------------- /admin-ui/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "create-next-app-antd", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "next dev", 7 | "build": "next build", 8 | "start": "next start", 9 | "lint": "next lint", 10 | "predev": "ts-node --project ./tsconfig.node.json ./scripts/genAntdCss.tsx", 11 | "prebuild": "cross-env NODE_ENV=production ts-node --project ./tsconfig.node.json ./scripts/genAntdCss.tsx" 12 | }, 13 | "devDependencies": { 14 | "@ant-design/cssinjs": "^1.3.0", 15 | "@ant-design/static-style-extract": "~1.0.1", 16 | "@next/font": "^13.1.1", 17 | "@types/luxon": "^3.3.0", 18 | "@types/node": "^18.11.17", 19 | "@types/react": "^18.0.26", 20 | "@types/react-dom": "^18.0.10", 21 | "antd": "^5.1.0", 22 | "cross-env": "^7.0.3", 23 | "eslint": "^8.30.0", 24 | "eslint-config-next": "^13.1.1", 25 | "fs": "0.0.1-security", 26 | "next": "^13.1.1", 27 | "react": "^18.2.0", 28 | "react-dom": "^18.2.0", 29 | "ts-node": "^10.9.1", 30 | "tslib": "^2.5.0", 31 | "typescript": "^4.9.4" 32 | }, 33 | "dependencies": { 34 | "@ant-design/colors": "^7.0.0", 35 | "@auth0/auth0-react": "^2.2.0", 36 | "@tabler/icons-react": "^2.40.0", 37 | "axios": "^1.4.0", 38 | "dayjs": "^1.11.8", 39 | "luxon": "^3.3.0", 40 | "react-highlight-words": "^0.20.0", 41 | "recharts": "^2.7.1", 42 | "swr": "^2.1.5" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /admin-ui/pages/_app.tsx: -------------------------------------------------------------------------------- 1 | import "../public/antd.min.css"; 2 | import "../styles/globals.css"; 3 | import type { AppProps } from "next/app"; 4 | import withTheme from "../theme"; 5 | 6 | import axios from "axios"; 7 | import Layout from "../layout"; 8 | import { Auth0Provider, useAuth0 } from '@auth0/auth0-react'; 9 | 10 | // Set the API base URL from the environment variable 11 | 12 | 13 | axios.defaults.baseURL = process.env.NEXT_PUBLIC_API_BASE_URL; 14 | const AUTH0_DOMAIN = process.env.NEXT_PUBLIC_AUTH0_DOMAIN || ''; 15 | const AUTH0_CLIENT_ID = process.env.NEXT_PUBLIC_AUTH0_CLIENT_ID || ''; 16 | 17 | 18 | 19 | if (!AUTH0_CLIENT_ID || !AUTH0_DOMAIN) { 20 | throw new Error( 21 | 'Please define AUTH0_CLIENT_ID and AUTH0_DOMAIN in your .env.local file', 22 | ); 23 | } 24 | 25 | export default function App({ Component, pageProps }: AppProps) { 26 | return withTheme( 27 | 28 | 40 | 41 | 42 | 43 | 44 | 45 | ); 46 | } 47 | 48 | const AuthProviderSetup = ({ children }) => { 49 | const { getAccessTokenSilently, isAuthenticated, loginWithRedirect } = useAuth0(); 50 | 51 | const fetchAccessToken = async () => { 52 | if (isAuthenticated) { 53 | try { 54 | const { access_token } = await getAccessTokenSilently({ 55 | detailedResponse: true, 56 | }); 57 | axios.defaults.headers.common['Authorization'] = `Bearer ${access_token}`; 58 | } catch (error) { 59 | console.error('Error fetching access token:', error); 60 | } 61 | } 62 | }; 63 | 64 | // Fetch access token on component mount 65 | fetchAccessToken(); 66 | 67 | return <>{children}; 68 | }; 69 | -------------------------------------------------------------------------------- /admin-ui/pages/index.tsx: -------------------------------------------------------------------------------- 1 | import { Space } from "antd"; 2 | import Stats from "../components/Stats"; 3 | import SWRRequestChart from "../components/charts/SWR/SWRRequestChart"; 4 | 5 | export default function Home() { 6 | return ( 7 | <> 8 |
9 | 10 | 11 |
12 | 13 |
14 |
15 |
16 | 17 | ); 18 | } 19 | -------------------------------------------------------------------------------- /admin-ui/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabhed/validator-endpoint/4572ba711392b82320f4e7f76ee09aa50803908f/admin-ui/public/favicon.ico -------------------------------------------------------------------------------- /admin-ui/public/next.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /admin-ui/public/thirteen.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /admin-ui/public/vercel.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /admin-ui/scripts/genAntdCss.tsx: -------------------------------------------------------------------------------- 1 | import fs from "fs"; 2 | import { extractStyle } from "@ant-design/static-style-extract"; 3 | import withTheme from "../theme"; 4 | 5 | const outputPath = "./public/antd.min.css"; 6 | 7 | // 1. default theme 8 | 9 | // const css = extractStyle(); 10 | 11 | // 2. With custom theme 12 | 13 | const css = extractStyle(withTheme); 14 | 15 | fs.writeFileSync(outputPath, css); 16 | 17 | console.log(`🎉 Antd CSS generated at ${outputPath}`); 18 | -------------------------------------------------------------------------------- /admin-ui/styles/Home.module.css: -------------------------------------------------------------------------------- 1 | .main { 2 | display: flex; 3 | flex-direction: column; 4 | justify-content: space-between; 5 | align-items: center; 6 | padding: 6rem; 7 | } 8 | -------------------------------------------------------------------------------- /admin-ui/styles/globals.css: -------------------------------------------------------------------------------- 1 | html, 2 | body { 3 | background: #f5f5f5; 4 | min-height: 100vh; 5 | } 6 | -------------------------------------------------------------------------------- /admin-ui/theme/index.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { ConfigProvider } from "antd"; 3 | import { blue } from "@ant-design/colors"; 4 | 5 | const withTheme = (node: JSX.Element) => ( 6 | 15 | {node} 16 | 17 | ); 18 | 19 | export default withTheme; 20 | -------------------------------------------------------------------------------- /admin-ui/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": ["dom", "dom.iterable", "esnext"], 5 | "allowJs": true, 6 | "skipLibCheck": true, 7 | "strict": true, 8 | "forceConsistentCasingInFileNames": true, 9 | "noEmit": true, 10 | "esModuleInterop": true, 11 | "module": "esnext", 12 | "moduleResolution": "node", 13 | "resolveJsonModule": true, 14 | "isolatedModules": true, 15 | "jsx": "preserve", 16 | "incremental": true, 17 | "noImplicitAny": false 18 | }, 19 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], 20 | "exclude": ["node_modules"] 21 | } 22 | -------------------------------------------------------------------------------- /admin-ui/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "strictNullChecks": true, 4 | "module": "NodeNext", 5 | "jsx": "react", 6 | "esModuleInterop": true 7 | }, 8 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"] 9 | } 10 | -------------------------------------------------------------------------------- /admin-ui/utils/api-handlers.tsx: -------------------------------------------------------------------------------- 1 | export function getErrorMessageFromResponse(error: any) { 2 | const { data } = error.response; 3 | if (typeof data.detail === "string") { 4 | return data.detail; 5 | } 6 | return data.detail[0].msg; 7 | } 8 | -------------------------------------------------------------------------------- /admin-ui/utils/api-keys.tsx: -------------------------------------------------------------------------------- 1 | export function generateCurlCommand({ 2 | prompt, 3 | apiKey, 4 | url, 5 | uids, 6 | top_n, 7 | }: { 8 | prompt: string; 9 | apiKey: string; 10 | url: string; 11 | uids?: number[]; 12 | top_n?: number; 13 | }) { 14 | const body = { 15 | messages: [{ role: "user", content: prompt }], 16 | uids, 17 | top_n, 18 | }; 19 | const curlCommand = `curl ${url}/chat \\ 20 | -H "Content-Type: application/json" \\ 21 | -H "Authorization: Bearer ${apiKey}" \\ 22 | -H "Endpoint-Version: 2023-05-19" \\ 23 | -d '${JSON.stringify(body, undefined, " ")}'`; 24 | return curlCommand; 25 | } 26 | -------------------------------------------------------------------------------- /admin-ui/utils/api-types.tsx: -------------------------------------------------------------------------------- 1 | // API Key In Database 2 | interface ApiKeyInDB { 3 | id: number; 4 | api_key: string; 5 | api_key_hint: string; 6 | name: string; 7 | request_count: number; 8 | valid_until: number; 9 | credits: number; 10 | enabled: boolean; 11 | rate_limits: string; 12 | created_at: number; 13 | updated_at: number; 14 | } 15 | 16 | // Message 17 | interface Message { 18 | role: "user" | "system" | "assistant"; 19 | content: string; 20 | } 21 | 22 | // Body for Chat Post 23 | interface BodyChatChatPost { 24 | uid: number; 25 | messages: Message[]; 26 | } 27 | 28 | // Body for creating API Key 29 | interface BodyCreateApiKeyAdminApiKeysPost { 30 | name: string; 31 | valid_until: number; 32 | credits: number; 33 | enabled: boolean; 34 | } 35 | 36 | // Body for editing API Key 37 | interface BodyEditApiKeyAdminApiKeysQueryPatch { 38 | api_key_hint: string; 39 | name: string; 40 | request_count: number; 41 | valid_until: string; 42 | credits: number; 43 | enabled: boolean; 44 | } 45 | 46 | // Chat Response 47 | interface ChatResponse { 48 | choices: ResponseMessage[]; 49 | } 50 | 51 | // Config Value 52 | interface ConfigValue { 53 | key: string; 54 | value: string; 55 | } 56 | 57 | // HTTP Validation Error 58 | interface HTTPValidationError { 59 | detail: ValidationError[]; 60 | } 61 | 62 | // Log Entry 63 | export interface RequestLogEntry { 64 | api_key: string; 65 | timestamp: number; 66 | responder_hotkey: string; 67 | } 68 | 69 | // Rate Limit Entry 70 | export interface RateLimitEntry { 71 | times: number; 72 | seconds: number; 73 | } 74 | 75 | // Response Message 76 | interface ResponseMessage { 77 | index: number; 78 | responder_hotkey: string; 79 | message: Message; 80 | } 81 | 82 | // Validation Error 83 | interface ValidationError { 84 | loc: (string | number)[]; 85 | msg: string; 86 | type: string; 87 | } 88 | 89 | export {}; 90 | -------------------------------------------------------------------------------- /admin-ui/utils/fetcher.ts: -------------------------------------------------------------------------------- 1 | import axios from "axios"; 2 | 3 | // Fetcher function for use with SWR 4 | const fetcher = (url: string) => { 5 | return axios.get(url).then((res) => res.data); 6 | }; 7 | export default fetcher; 8 | -------------------------------------------------------------------------------- /btvep/Dockerfile: -------------------------------------------------------------------------------- 1 | # We will use the official Python 3.10 image from Docker Hub 2 | FROM python:3.10-slim-buster 3 | 4 | # Set a directory for our application 5 | WORKDIR /app 6 | 7 | # Install system level dependencies 8 | RUN apt-get update && apt-get install -y \ 9 | gcc \ 10 | g++ \ 11 | libffi-dev \ 12 | libssl-dev \ 13 | build-essential \ 14 | && rm -rf /var/lib/apt/lists/* 15 | 16 | # Install poetry for package management 17 | RUN pip install poetry 18 | 19 | # Set Path for poetry 20 | ENV PATH="${PATH}:/root/.poetry/bin" 21 | 22 | # Copy the rest of our application 23 | COPY . /app 24 | 25 | # Install dependencies without creating a virtual environment inside the container 26 | RUN poetry config virtualenvs.create false \ 27 | && poetry install 28 | 29 | 30 | # Run the application 31 | CMD ["btvep", "start", "--port", "8000"] 32 | -------------------------------------------------------------------------------- /btvep/README.md: -------------------------------------------------------------------------------- 1 | # btvep 2 | 3 | ## Getting started 4 | 5 | ```bash 6 | # Install with pip 7 | python3 -m pip install https://github.com/fabhed/validator-endpoint/raw/main/btvep/dist/btvep-0.2.0-py3-none-any.whl 8 | # Set your hotkey mnemonic (quotes are needed since the mnemonic has spaces in it) 9 | btvep config set hotkey_mnemonic "my_validators_secret_mnemonic_phrase_here" 10 | # Create an API key 11 | btvep key create 12 | # Start the server 13 | btvep start --port 8000 14 | ``` 15 | 16 | As an alternative to the above approach you can also use docker: [Docker Guide](../docs/docker.md) 17 | 18 | ## Tutorials 19 | 20 | - [Colab Notebook Tutorial](https://colab.research.google.com/drive/1RRQhxSmGiULEZNj0gYswa2JksZ56cGa1?usp=sharing): A step-by-step guide on how to use our project in a Colab notebook. 21 | 22 | ## Requirements 23 | 24 | - Python 3.10 25 | - If Rate limiting is used [Redis](https://redis.io/docs/getting-started/installation/) is also required 26 | 27 | ## Dev requirements 28 | 29 | - Poetry: https://python-poetry.org/docs/ 30 | 31 | ## Dev setup 32 | 33 | ```bash 34 | # Clone the repo 35 | git clone https://github.com/fabhed/validator-endpoint.git 36 | cd validator-endpoint/btvep 37 | 38 | # Install depedencies 39 | poetry install 40 | 41 | # Launch the shell enviornment 42 | poetry shell 43 | 44 | # Run your editor 45 | code . 46 | 47 | # You can now run the cli 48 | btvep --help 49 | 50 | # Run the server with auto reloading 51 | btvep start --reload 52 | 53 | # You can also directly execute this command to avoid having to launch a poetry shell 54 | poetry run btvep start --reload 55 | ``` 56 | 57 | ### Generate docs 58 | 59 | ```bash 60 | # Run under ./btvep folder 61 | poetry run typer btvep.cli utils docs --output docs/cli.md --name btvep 62 | ``` 63 | 64 | ### Build .whl files in /dist 65 | 66 | ```bash 67 | # Run under ./btvep folder 68 | poetry build 69 | ``` 70 | 71 | ### grpcio dependency (from bittensor) arm fix 72 | 73 | ```bash 74 | # Run under ./btvep folder 75 | python3 -m pip install --no-binary :all: grpcio --ignore-installed 76 | ``` 77 | -------------------------------------------------------------------------------- /btvep/btvep/__init__.py: -------------------------------------------------------------------------------- 1 | __app_name__ = "btvep" 2 | __version__ = "0.1.0" 3 | 4 | from btvep import cli, db 5 | -------------------------------------------------------------------------------- /btvep/btvep/__main__.py: -------------------------------------------------------------------------------- 1 | """btvep entry point""" 2 | 3 | from btvep import __app_name__, cli 4 | 5 | 6 | def main(): 7 | cli.app(prog_name=__app_name__) 8 | 9 | 10 | if __name__ == "__main__": 11 | main() 12 | -------------------------------------------------------------------------------- /btvep/btvep/api/__init__.py: -------------------------------------------------------------------------------- 1 | from fastapi import APIRouter, Depends 2 | 3 | from btvep.api.dependencies import ( 4 | VerifyAPIKeyAndLimit, 5 | authenticate_user, 6 | authenticate_admin, 7 | get_db, 8 | ) 9 | from btvep.api.admin import ( 10 | router as admin_router, 11 | ) 12 | from .api_keys import router as key_router 13 | from .conversation import router as conversation_router 14 | from .chat import router as chat_router 15 | 16 | # Compose routers into a single router 17 | 18 | 19 | all_endpoints = APIRouter() 20 | 21 | all_endpoints.include_router( 22 | admin_router, 23 | prefix="/admin", 24 | tags=["Admin"], 25 | dependencies=[Depends(get_db), Depends(authenticate_admin)], 26 | ) 27 | 28 | all_endpoints.include_router( 29 | key_router, 30 | prefix="/api-keys", 31 | dependencies=[Depends(get_db), Depends(authenticate_user)], 32 | ) 33 | 34 | all_endpoints.include_router( 35 | conversation_router, dependencies=[Depends(get_db), Depends(authenticate_user)] 36 | ) 37 | all_endpoints.include_router( 38 | chat_router, dependencies=[Depends(get_db), Depends(lambda: VerifyAPIKeyAndLimit())] 39 | ) 40 | -------------------------------------------------------------------------------- /btvep/btvep/api/admin/__init__.py: -------------------------------------------------------------------------------- 1 | from fastapi import APIRouter 2 | 3 | from .api_keys import router as key_router 4 | from .logs import router as logs_router 5 | from .config import router as config_router 6 | from .rate_limits import router as ratelimit_router 7 | 8 | # Compose all routers into a single router 9 | router = APIRouter() 10 | router.include_router(key_router, prefix="/api-keys") 11 | router.include_router(config_router, prefix="/config") 12 | router.include_router(logs_router, prefix="/logs") 13 | router.include_router(ratelimit_router, prefix="/rate-limits") 14 | -------------------------------------------------------------------------------- /btvep/btvep/api/admin/config.py: -------------------------------------------------------------------------------- 1 | import json 2 | from typing import List 3 | from fastapi import APIRouter, HTTPException 4 | from pydantic import BaseModel 5 | from btvep.btvep_models import RateLimitEntry 6 | from btvep.config import Config, cast_str_to_bool 7 | 8 | router = APIRouter() 9 | 10 | 11 | class ConfigValue(BaseModel): 12 | key: str 13 | value: str | List[RateLimitEntry] 14 | 15 | 16 | @router.get("/") 17 | async def get_config(): 18 | config = Config().load(hide_mnemonic=True) 19 | return json.loads(config.to_json()) 20 | 21 | 22 | @router.get("/{key}") 23 | async def get_config_value(key: str): 24 | config = Config().load(hide_mnemonic=True) 25 | if key in config.__dict__: 26 | return {key: config.__dict__[key]} 27 | else: 28 | raise HTTPException(status_code=400, detail=f"Unknown config key: {key}") 29 | 30 | 31 | @router.post("/") 32 | async def set_config_value(config_value: ConfigValue): 33 | key = config_value.key 34 | value = config_value.value 35 | config = Config().load() 36 | 37 | if key in config.__dict__: 38 | if isinstance(config.__dict__[key], bool): 39 | value = cast_str_to_bool(value) 40 | config.__dict__[key] = value 41 | try: 42 | config.validate(cli_mode=False) 43 | except ValueError as e: 44 | raise HTTPException(status_code=400, detail=str(e)) 45 | config.save() 46 | return {key: config.load().__dict__[key]} 47 | else: 48 | raise HTTPException(status_code=400, detail=f"Unknown config key: {key}") 49 | -------------------------------------------------------------------------------- /btvep/btvep/api/api_keys.py: -------------------------------------------------------------------------------- 1 | from typing import List, Optional 2 | 3 | from fastapi import APIRouter, Body, Depends, HTTPException 4 | from playhouse.shortcuts import model_to_dict 5 | from pydantic import BaseModel 6 | from btvep.api.dependencies import authenticate_user 7 | 8 | from btvep.db import api_keys 9 | from btvep.db.user import User 10 | from btvep.models.key import ApiKeyInDB 11 | 12 | router = APIRouter() 13 | 14 | 15 | class ApiKeyRequest(BaseModel): 16 | name: Optional[str] = "New API Key" 17 | default_query_strategy: Optional[str] = None 18 | 19 | 20 | @router.post("/", status_code=201, response_model=ApiKeyInDB) 21 | def create_api_key( 22 | request: ApiKeyRequest, 23 | user: User = Depends(authenticate_user), 24 | ): 25 | """ 26 | Create a new API key. 27 | """ 28 | api_key = api_keys.insert(name=request.name, user_id=user.id) 29 | return model_to_dict(api_key) 30 | 31 | 32 | @router.get("/", response_model=List[ApiKeyInDB]) 33 | def list_api_keys(user: User = Depends(authenticate_user)): 34 | """ 35 | List all API keys. 36 | """ 37 | return api_keys.get_all_by_user_id(user.id) 38 | 39 | 40 | @router.delete("/{query}") 41 | def delete_api_key(query: str, user: User = Depends(authenticate_user)): 42 | """ 43 | Deletes an API key. 44 | """ 45 | count = api_keys.delete(query, user.id) 46 | if count == 0: 47 | raise HTTPException(status_code=404, detail=f"Key {query} not found") 48 | return {"detail": f"Deleted key {query}"} 49 | 50 | 51 | @router.patch("/{query}") 52 | def edit_api_key( 53 | query: str, 54 | request: ApiKeyRequest, 55 | user: User = Depends(authenticate_user), 56 | ): 57 | """ 58 | Edit an API key. 59 | """ 60 | fields_to_set_to_null = [] 61 | if request.default_query_strategy is None: 62 | fields_to_set_to_null.append("default_query_strategy") 63 | 64 | api_keys.update( 65 | query=query, 66 | user_id=user.id, 67 | # Only allow name and default_query_strategy to be updated 68 | name=request.name, 69 | default_query_strategy=request.default_query_strategy, 70 | fields_to_nullify=fields_to_set_to_null, 71 | ) 72 | updated_key = api_keys.get(query) 73 | if updated_key is None: 74 | raise HTTPException(status_code=404, detail=f"Key {query} not found") 75 | return updated_key 76 | -------------------------------------------------------------------------------- /btvep/btvep/api/conversation.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated, List 2 | from fastapi import APIRouter, Body, Depends, Header 3 | from btvep.api.dependencies import authenticate_user 4 | from btvep.chat_helpers import ( 5 | process_responses, 6 | query_network, 7 | raise_for_all_failed_responses, 8 | setup_async_loop, 9 | ) 10 | 11 | from btvep.constants import DEFAULT_UIDS 12 | from btvep.btvep_models import ( 13 | ChatResponse, 14 | Message, 15 | ) 16 | from btvep.db.user import User 17 | 18 | router = APIRouter() 19 | 20 | 21 | @router.post("/conversation") 22 | async def conversation( 23 | authorization: Annotated[str | None, Header()] = None, 24 | uids: Annotated[List[int] | None, Body()] = DEFAULT_UIDS, 25 | top_n: Annotated[ 26 | int | None, 27 | Body( 28 | description="Query top miners based on incentive in the network. If set to for example 5, the top 5 miners will be sent the request. This parameter takes precidence over the uids parameter." 29 | ), 30 | ] = None, 31 | in_parallel: Annotated[int | None, Body()] = None, 32 | respond_on_first_success: Annotated[bool | None, Body()] = True, 33 | messages: Annotated[List[Message] | None, Body()] = None, 34 | user: User = Depends(authenticate_user), 35 | ) -> ChatResponse: 36 | setup_async_loop() 37 | prompter_responses = await query_network( 38 | messages, uids, top_n, in_parallel, respond_on_first_success 39 | ) 40 | choices, failed_responses, all_failed = process_responses( 41 | prompter_responses, messages, authorization 42 | ) 43 | print(all_failed, choices, failed_responses) 44 | 45 | # Increment user request counts (specific to conversation function) 46 | User.update( 47 | { 48 | "api_request_count": user.api_request_count + 1, 49 | "request_count": user.request_count + len(prompter_responses), 50 | } 51 | ).where(User.id == user.id).execute() 52 | 53 | if all_failed: 54 | raise_for_all_failed_responses(failed_responses) 55 | 56 | return {"choices": choices, "failed_responses": failed_responses} 57 | -------------------------------------------------------------------------------- /btvep/btvep/btvep_models.py: -------------------------------------------------------------------------------- 1 | from typing import List, Literal, Optional 2 | from pydantic import BaseModel, Field 3 | 4 | 5 | # RateLimit but with pydantic 6 | class RateLimitEntry(BaseModel): 7 | times: int = Field(..., example=10) 8 | seconds: int = Field(..., example=60) 9 | 10 | 11 | class Message(BaseModel): 12 | role: Literal["user", "system", "assistant"] 13 | content: str 14 | 15 | 16 | class ChatResponseChoice(BaseModel): 17 | """Message with an index and responder hotkey""" 18 | 19 | index: int 20 | uid: int 21 | responder_hotkey: Optional[str] 22 | message: Message 23 | response_ms: Optional[int] 24 | 25 | 26 | class FailedMinerResponse(BaseModel): 27 | """Message with an index and responder hotkey""" 28 | 29 | index: int 30 | uid: int 31 | responder_hotkey: Optional[str] 32 | error: Optional[str] 33 | response_ms: Optional[int] 34 | 35 | 36 | class ChatResponse(BaseModel): 37 | choices: List[ChatResponseChoice] 38 | failed_responses: List[FailedMinerResponse] 39 | -------------------------------------------------------------------------------- /btvep/btvep/cli/__init__.py: -------------------------------------------------------------------------------- 1 | """This module provides the CLI""" 2 | 3 | from typing import Optional 4 | 5 | import typer 6 | from typing_extensions import Annotated 7 | 8 | from btvep import __app_name__, __version__, db 9 | 10 | from . import key 11 | from . import config 12 | from . import ratelimit 13 | from . import logs 14 | from . import user 15 | 16 | app = typer.Typer(help="Bitensor Validator Endpoint CLI", rich_markup_mode="rich") 17 | 18 | 19 | def _version_callback(value: bool) -> None: 20 | if value: 21 | typer.echo(f"{__app_name__} v{__version__}") 22 | raise typer.Exit() 23 | 24 | 25 | @app.callback(no_args_is_help=True) 26 | def main( 27 | version: Optional[bool] = typer.Option( 28 | None, 29 | "--version", 30 | "-v", 31 | help="Show the application's version and exit.", 32 | callback=_version_callback, 33 | is_eager=True, 34 | ), 35 | ) -> None: 36 | """btvep entry point""" 37 | db.tables.create_all() 38 | return 39 | 40 | 41 | @app.command() 42 | def start( 43 | port: Annotated[ 44 | int, 45 | typer.Option( 46 | help="The port to listen on.", 47 | ), 48 | ] = 8000, 49 | reload: Annotated[ 50 | bool, 51 | typer.Option( 52 | "--reload", 53 | "-r", 54 | help="Enable auto-reload on changes (for development).", 55 | ), 56 | ] = False, 57 | ): 58 | """ 59 | Start the API server. 60 | """ 61 | import uvicorn 62 | 63 | uvicorn.run("btvep.server:app", host="0.0.0.0", port=port, reload=reload) 64 | 65 | 66 | app.add_typer(key.app, name="key") 67 | app.add_typer(config.app, name="config") 68 | app.add_typer(ratelimit.app, name="ratelimit") 69 | app.add_typer(logs.app, name="logs") 70 | app.add_typer(user.app, name="user") 71 | -------------------------------------------------------------------------------- /btvep/btvep/cli/user.py: -------------------------------------------------------------------------------- 1 | import typer 2 | 3 | from btvep.db.user import User 4 | 5 | app = typer.Typer(help="Manage users.") 6 | 7 | 8 | @app.callback(no_args_is_help=True) 9 | def main(): 10 | pass 11 | 12 | 13 | @app.command("list") 14 | def list_users(): 15 | table = User.tabulate([user for user in User.select().dicts()]) 16 | print(table) 17 | 18 | 19 | @app.command("edit") 20 | def edit_user( 21 | user_id: str = typer.Argument(..., help="User ID"), 22 | is_admin: bool = typer.Option(..., help="Option --is-admin OR --no-is-admin"), 23 | ): 24 | try: 25 | user = User.get(User.id == user_id) 26 | user.is_admin = is_admin 27 | user.save() 28 | print(f"User updated.") 29 | except User.DoesNotExist: 30 | print(f"User {user_id} not found.") 31 | -------------------------------------------------------------------------------- /btvep/btvep/constants.py: -------------------------------------------------------------------------------- 1 | from typing import Annotated, List 2 | 3 | DEFAULT_UIDS: Annotated[ 4 | List[int], "Neuron UIDs to use if none is specified in request." 5 | ] = [0] 6 | DEFAULT_NETUID: Annotated[str, "NETUID to prompt"] = 1 7 | COST: Annotated[str, "Credit Cost per request"] = 1 8 | -------------------------------------------------------------------------------- /btvep/btvep/db/__init__.py: -------------------------------------------------------------------------------- 1 | from . import api_keys, utils, tables, request 2 | -------------------------------------------------------------------------------- /btvep/btvep/db/request.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import time 3 | from peewee import * 4 | from tabulate import tabulate 5 | 6 | from btvep.db.api_keys import ApiKey 7 | from btvep.db.user import User 8 | 9 | from .utils import db 10 | 11 | 12 | class Request(Model): 13 | id = AutoField() 14 | api_key = ForeignKeyField(ApiKey, field="api_key", backref="requests", null=True) 15 | user = ForeignKeyField(User, field="id", backref="requests", null=True) 16 | timestamp = IntegerField(default=lambda: int(time.time())) 17 | prompt = TextField() 18 | 19 | ### API fields - before request is sent to the bittensor network ### 20 | is_api_success = BooleanField() 21 | api_error = TextField(null=True) 22 | # api request id is the id of the request in the validator-endpoint api. 23 | # This can be useful since multiple request rows can be created for one api request, 24 | # since the api request makes multiple bittensor requests. 25 | api_request_id = TextField() 26 | 27 | ### Fields from DendriteCall class ### 28 | response = TextField(null=True) 29 | responder_hotkey = TextField(null=True) 30 | is_success = BooleanField(null=True) 31 | return_message = TextField(null=True) 32 | elapsed_time = FloatField(null=True) 33 | src_version = IntegerField(null=True) 34 | dest_version = IntegerField(null=True) 35 | return_code = TextField(null=True) 36 | 37 | class Meta: 38 | database = db 39 | 40 | @staticmethod 41 | def tabulate(requests): 42 | """Print a list of requests in a table.""" 43 | return tabulate( 44 | requests, 45 | headers="keys", 46 | ) 47 | 48 | 49 | db.create_tables([Request]) 50 | -------------------------------------------------------------------------------- /btvep/btvep/db/tables.py: -------------------------------------------------------------------------------- 1 | from .utils import db 2 | from .api_keys import ApiKey 3 | 4 | 5 | def create_all(): 6 | db.create_tables([ApiKey]) 7 | -------------------------------------------------------------------------------- /btvep/btvep/db/user.py: -------------------------------------------------------------------------------- 1 | import json 2 | import time 3 | 4 | from peewee import BooleanField, DateTimeField, IntegerField, TextField 5 | from tabulate import tabulate 6 | 7 | from .utils import BaseModel, db 8 | 9 | 10 | class User(BaseModel): 11 | id = TextField(primary_key=True) 12 | # Number of requests to the bittensor network 13 | request_count = IntegerField(default=0) 14 | is_admin = IntegerField(default=0) 15 | # Number of requests to the validator-endpoint api (one api request can make multiple bittensor requests) 16 | api_request_count = IntegerField(default=0) 17 | enabled = BooleanField(default=True) 18 | created_at = DateTimeField(default=lambda: int(time.time())) 19 | updated_at = DateTimeField(default=lambda: int(time.time())) 20 | 21 | def __str__(self): 22 | return json.dumps(self.__dict__["__data__"], indent=4, default=str) 23 | 24 | @staticmethod 25 | def tabulate(users): 26 | """Print a list of Users in a table.""" 27 | return tabulate( 28 | users, 29 | headers="keys", 30 | ) 31 | 32 | 33 | db.create_tables([User]) 34 | -------------------------------------------------------------------------------- /btvep/btvep/db/utils.py: -------------------------------------------------------------------------------- 1 | from contextvars import ContextVar 2 | import os 3 | import peewee 4 | 5 | DB_PATH = os.path.join(os.path.dirname(__file__), "../../btvep.db") 6 | DB_PATH = os.path.abspath(DB_PATH) 7 | 8 | # https://fastapi.tiangolo.com/advanced/sql-databases-peewee/#make-peewee-async-compatible-peeweeconnectionstate 9 | db_state_default = {"closed": None, "conn": None, "ctx": None, "transactions": None} 10 | db_state = ContextVar("db_state", default=db_state_default.copy()) 11 | 12 | 13 | class PeeweeConnectionState(peewee._ConnectionState): 14 | def __init__(self, **kwargs): 15 | super().__setattr__("_state", db_state) 16 | super().__init__(**kwargs) 17 | 18 | def __setattr__(self, name, value): 19 | self._state.get()[name] = value 20 | 21 | def __getattr__(self, name): 22 | return self._state.get()[name] 23 | 24 | 25 | db = peewee.SqliteDatabase(DB_PATH, check_same_thread=False) 26 | db._state = PeeweeConnectionState() 27 | 28 | 29 | class BaseModel(peewee.Model): 30 | class Meta: 31 | database = db 32 | -------------------------------------------------------------------------------- /btvep/btvep/filter.py: -------------------------------------------------------------------------------- 1 | import concurrent.futures 2 | import logging 3 | from typing import List 4 | 5 | 6 | class Filter: 7 | def safe_check(self, input: str, timeout_seconds: int = 5): 8 | """If moderation request takes longer than timeout, simply allow it.""" 9 | with concurrent.futures.ThreadPoolExecutor() as executor: 10 | future = executor.submit(self.check, input) 11 | try: 12 | output = future.result(timeout=timeout_seconds) 13 | return output 14 | except concurrent.futures.TimeoutError: 15 | logging.warning("OpenAI filter timed out. Allowing request.") 16 | return { 17 | "response": None, 18 | "any_flagged": False, 19 | } 20 | 21 | def check(self, input: str | List[str]): 22 | raise NotImplementedError 23 | 24 | 25 | import openai 26 | 27 | 28 | class OpenAIFilter(Filter): 29 | def __init__(self, api_key): 30 | self.api_key = api_key 31 | 32 | def check(self, input: str | List[str]): 33 | response = openai.Moderation.create(input=input, api_key=self.api_key) 34 | return { 35 | "response": response, 36 | # Results include a flagged boolean for each input, look at all of them 37 | "any_flagged": any([result["flagged"] for result in response["results"]]), 38 | } 39 | -------------------------------------------------------------------------------- /btvep/btvep/metagraph.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import time 3 | from typing import Optional 4 | import bittensor 5 | 6 | 7 | class MetagraphSyncer: 8 | def __init__( 9 | self, netuid: int, rest_seconds: int = 60, extra_fail_rest_seconds: int = 60 10 | ): 11 | self.last_sync_success = None 12 | self.netuid = netuid 13 | self.is_syncing = False 14 | self.rest_seconds = rest_seconds 15 | self.extra_fail_rest_seconds = extra_fail_rest_seconds 16 | self.metagraph: Optional[bittensor.metagraph] = None 17 | 18 | def sync(self): 19 | subtensor = bittensor.subtensor() 20 | self.is_syncing = True 21 | try: 22 | sync_start = time.time() 23 | metagraph: bittensor.metagraph = subtensor.metagraph(netuid=self.netuid) 24 | self.metagraph = metagraph 25 | self.last_sync_success = time.time() 26 | logging.info( 27 | f"Synced metagraph for netuid {self.netuid} (took {self.last_sync_success - sync_start:.2f} seconds)", 28 | ) 29 | return metagraph 30 | except Exception as e: 31 | logging.warning("Could not sync metagraph: ", e) 32 | raise e # Reraise the exception to be handled by the caller 33 | finally: 34 | self.is_syncing = False 35 | return None 36 | 37 | def start_sync_thread(self): 38 | self.last_sync_success = time.time() 39 | 40 | # Run in a separate thread 41 | def loop(): 42 | while True: 43 | try: 44 | self.sync() 45 | except Exception as e: 46 | time.sleep(self.extra_fail_rest_seconds) 47 | time.sleep(self.rest_seconds) 48 | 49 | import threading 50 | 51 | thread = threading.Thread(target=loop, daemon=True) 52 | thread.start() 53 | logging.info("Started metagraph sync thread") 54 | return thread 55 | -------------------------------------------------------------------------------- /btvep/btvep/models/key.py: -------------------------------------------------------------------------------- 1 | from typing import Optional 2 | from datetime import datetime 3 | from pydantic import BaseModel 4 | 5 | 6 | class ApiKeyCreate(BaseModel): 7 | name: Optional[str] = None 8 | valid_until: Optional[int] = -1 9 | credits: Optional[int] = -1 10 | enabled: Optional[bool] = True 11 | 12 | 13 | class ApiKeyInDB(BaseModel): 14 | id: int 15 | api_key: str 16 | api_key_hint: str 17 | name: Optional[str] = None 18 | request_count: int 19 | valid_until: int 20 | credits: int 21 | enabled: bool 22 | rate_limits: Optional[str] = None 23 | rate_limits_enabled: bool = None 24 | default_query_strategy: Optional[str] = None 25 | created_at: int 26 | updated_at: int 27 | 28 | 29 | class ApiKeyUpdate(BaseModel): 30 | api_key_hint: Optional[str] = None 31 | name: Optional[str] = None 32 | request_count: Optional[int] = None 33 | valid_until: Optional[int] = None 34 | credits: Optional[int] = None 35 | enabled: Optional[bool] = None 36 | -------------------------------------------------------------------------------- /btvep/btvep/models/user.py: -------------------------------------------------------------------------------- 1 | from pydantic import BaseModel 2 | 3 | 4 | class UserInDB(BaseModel): 5 | id: int 6 | request_count: int 7 | enabled: bool 8 | created_at: int 9 | updated_at: int 10 | is_admin: int 11 | -------------------------------------------------------------------------------- /btvep/btvep/server.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import rich 3 | import uvicorn 4 | from fastapi import FastAPI, Request 5 | from fastapi.middleware.cors import CORSMiddleware 6 | from fastapi.responses import JSONResponse 7 | 8 | from btvep.chat_helpers import ChatResponseException 9 | 10 | logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.INFO) 11 | 12 | from btvep.api import all_endpoints 13 | from btvep.api.dependencies import ( 14 | InitializeRateLimiting, 15 | ) 16 | from btvep.config import Config 17 | from btvep.db.tables import create_all as create_all_tables 18 | from btvep.db.utils import DB_PATH 19 | from btvep.validator_prompter import ValidatorPrompter 20 | 21 | create_all_tables() 22 | config = Config().load().validate() 23 | 24 | # Give info around configuration at server start 25 | print("Config:") 26 | rich.print_json(config.to_json(hide_mnemonic=True)) 27 | print("Using SQLite database at", DB_PATH) 28 | 29 | # Initialize the validator prompter for bittensor 30 | ValidatorPrompter(config.hotkey_mnemonic) 31 | 32 | app = FastAPI() 33 | 34 | # Add CORS middleware 35 | app.add_middleware( 36 | CORSMiddleware, 37 | allow_origins=[ 38 | "*" 39 | ], # Allows all origins. You can change this to allow specific domains. 40 | allow_credentials=True, 41 | allow_methods=[ 42 | "*" 43 | ], # Allows all methods. You can change this to allow specific HTTP methods. 44 | allow_headers=[ 45 | "*" 46 | ], # Allows all headers. You can change this to allow specific headers. 47 | ) 48 | 49 | app.include_router(all_endpoints) 50 | 51 | 52 | @app.exception_handler(ChatResponseException) 53 | async def unicorn_exception_handler(request: Request, exc: ChatResponseException): 54 | return JSONResponse( 55 | status_code=exc.status_code, 56 | content={"detail": exc.detail, "failed_responses": exc.failed_responses}, 57 | ) 58 | 59 | 60 | @app.on_event("startup") 61 | async def startup(): 62 | if config.rate_limiting_enabled: 63 | await InitializeRateLimiting() 64 | 65 | 66 | if __name__ == "__main__": 67 | uvicorn.run(app, host="0.0.0.0", port=8000) 68 | -------------------------------------------------------------------------------- /btvep/dist/btvep-0.1.0-py3-none-any.whl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabhed/validator-endpoint/4572ba711392b82320f4e7f76ee09aa50803908f/btvep/dist/btvep-0.1.0-py3-none-any.whl -------------------------------------------------------------------------------- /btvep/dist/btvep-0.1.0.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabhed/validator-endpoint/4572ba711392b82320f4e7f76ee09aa50803908f/btvep/dist/btvep-0.1.0.tar.gz -------------------------------------------------------------------------------- /btvep/dist/btvep-0.1.1-py3-none-any.whl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabhed/validator-endpoint/4572ba711392b82320f4e7f76ee09aa50803908f/btvep/dist/btvep-0.1.1-py3-none-any.whl -------------------------------------------------------------------------------- /btvep/dist/btvep-0.1.1.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabhed/validator-endpoint/4572ba711392b82320f4e7f76ee09aa50803908f/btvep/dist/btvep-0.1.1.tar.gz -------------------------------------------------------------------------------- /btvep/dist/btvep-0.2.0-py3-none-any.whl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabhed/validator-endpoint/4572ba711392b82320f4e7f76ee09aa50803908f/btvep/dist/btvep-0.2.0-py3-none-any.whl -------------------------------------------------------------------------------- /btvep/dist/btvep-0.2.0.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabhed/validator-endpoint/4572ba711392b82320f4e7f76ee09aa50803908f/btvep/dist/btvep-0.2.0.tar.gz -------------------------------------------------------------------------------- /btvep/docker-compose.template.yml: -------------------------------------------------------------------------------- 1 | version: '3.9' 2 | 3 | services: 4 | redis: 5 | image: redis:latest 6 | restart: always 7 | container_name: "btvep_redis" 8 | api: 9 | build: 10 | context: . 11 | dockerfile: Dockerfile 12 | restart: always 13 | container_name: "btvep_api" 14 | volumes: 15 | - .:/app 16 | ports: 17 | - 8000:8000 18 | depends_on: 19 | - redis 20 | environment: 21 | HOTKEY_MNEMONIC: "my_validators_secret_mnemonic_phrase_here" 22 | REDIS_URL: redis://redis:6379 -------------------------------------------------------------------------------- /btvep/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "btvep" 3 | version = "0.2.0" 4 | description = "Validator endpoint for bittensor" 5 | authors = ["Your Name "] 6 | license = "MIT" 7 | readme = "README.md" 8 | 9 | [tool.poetry.scripts] 10 | btvep = "btvep.cli:app" 11 | 12 | [tool.poetry.dependencies] 13 | python = ">=3.10,<3.11" 14 | typer = {extras = ["all"], version = "^0.9.0"} 15 | tabulate = "^0.9.0" 16 | fastapi = "0.99.1" 17 | uvicorn = "^0.22.0" 18 | bittensor = "6.0.1" 19 | peewee = "^3.16.2" 20 | fastapi-limiter = "^0.1.5" 21 | dateparser = "^1.1.8" 22 | pydantic = "^1.10.8" 23 | openai = "^0.27.8" 24 | torch = ">=2.0.0, !=2.0.1" 25 | pyjwt = "^2.8.0" 26 | 27 | [tool.poetry.dev-dependencies] 28 | pytest = "^7.3.1" 29 | 30 | 31 | 32 | [build-system] 33 | requires = ["poetry-core"] 34 | build-backend = "poetry.core.masonry.api" 35 | -------------------------------------------------------------------------------- /btvep/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabhed/validator-endpoint/4572ba711392b82320f4e7f76ee09aa50803908f/btvep/tests/__init__.py -------------------------------------------------------------------------------- /btvep/tests/test_vendpoint.py: -------------------------------------------------------------------------------- 1 | from typer.testing import CliRunner 2 | 3 | from btvep import __app_name__, __version__ 4 | from btvep import cli 5 | 6 | runner = CliRunner() 7 | 8 | 9 | def test_version(): 10 | result = runner.invoke(cli.app, ["--version"]) 11 | assert result.exit_code == 0 12 | assert f"{__app_name__} v{__version__}\n" in result.stdout 13 | -------------------------------------------------------------------------------- /chat-ui/.dockerignore: -------------------------------------------------------------------------------- 1 | .env 2 | .env.local 3 | node_modules 4 | test-results 5 | -------------------------------------------------------------------------------- /chat-ui/.env.local.example: -------------------------------------------------------------------------------- 1 | NEXT_PUBLIC_AUTH0_DOMAIN= 2 | NEXT_PUBLIC_AUTH0_CLIENT_ID= 3 | NEXT_PUBLIC_VALIDATOR_ENDPOINT_BASE_URL= 4 | NEXT_PUBLIC_AUTH0_AUDIENCE= 5 | NEXT_PUBLIC_AUTH0_REDIRECT_URI= 6 | 7 | # Uncomment the next line to overwrite the default system prompt 8 | #NEXT_PUBLIC_DEFAULT_SYSTEM_PROMPT= 9 | NEXT_PUBLIC_CHATPDF_API_KEY= 10 | WEATHER_API_KEY= -------------------------------------------------------------------------------- /chat-ui/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "next/core-web-vitals" 3 | } 4 | -------------------------------------------------------------------------------- /chat-ui/.github/workflows/run-test-suite.yml: -------------------------------------------------------------------------------- 1 | name: Run Unit Tests 2 | on: 3 | push: 4 | branches: 5 | - main 6 | pull_request: 7 | branches: 8 | - main 9 | 10 | jobs: 11 | test: 12 | runs-on: ubuntu-latest 13 | container: 14 | image: node:16 15 | 16 | steps: 17 | - name: Checkout code 18 | uses: actions/checkout@v2 19 | 20 | - name: Install dependencies 21 | run: npm ci 22 | 23 | - name: Run Vitest Suite 24 | run: npm test 25 | -------------------------------------------------------------------------------- /chat-ui/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | /test-results 11 | 12 | # next.js 13 | /.next/ 14 | /out/ 15 | /dist 16 | 17 | # production 18 | /build 19 | 20 | # misc 21 | .DS_Store 22 | *.pem 23 | 24 | # debug 25 | npm-debug.log* 26 | yarn-debug.log* 27 | yarn-error.log* 28 | .pnpm-debug.log* 29 | 30 | # local env files 31 | .env*.local 32 | 33 | # vercel 34 | .vercel 35 | 36 | # typescript 37 | *.tsbuildinfo 38 | next-env.d.ts 39 | .idea 40 | pnpm-lock.yaml 41 | -------------------------------------------------------------------------------- /chat-ui/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | **Welcome to Chatbot UI!** 4 | 5 | We appreciate your interest in contributing to our project. 6 | 7 | Before you get started, please read our guidelines for contributing. 8 | 9 | ## Types of Contributions 10 | 11 | We welcome the following types of contributions: 12 | 13 | - Bug fixes 14 | - New features 15 | - Documentation improvements 16 | - Code optimizations 17 | - Translations 18 | - Tests 19 | 20 | ## Getting Started 21 | 22 | To get started, fork the project on GitHub and clone it locally on your machine. Then, create a new branch to work on your changes. 23 | 24 | ``` 25 | git clone https://github.com/mckaywrigley/chatbot-ui.git 26 | cd chatbot-ui 27 | git checkout -b my-branch-name 28 | 29 | ``` 30 | 31 | Before submitting your pull request, please make sure your changes pass our automated tests and adhere to our code style guidelines. 32 | 33 | ## Pull Request Process 34 | 35 | 1. Fork the project on GitHub. 36 | 2. Clone your forked repository locally on your machine. 37 | 3. Create a new branch from the main branch. 38 | 4. Make your changes on the new branch. 39 | 5. Ensure that your changes adhere to our code style guidelines and pass our automated tests. 40 | 6. Commit your changes and push them to your forked repository. 41 | 7. Submit a pull request to the main branch of the main repository. 42 | 43 | ## Contact 44 | 45 | If you have any questions or need help getting started, feel free to reach out to me on [Twitter](https://twitter.com/mckaywrigley). 46 | -------------------------------------------------------------------------------- /chat-ui/Dockerfile: -------------------------------------------------------------------------------- 1 | # ---- Base Node ---- 2 | FROM node:19-alpine AS base 3 | WORKDIR /app 4 | COPY package*.json ./ 5 | 6 | # ---- Dependencies ---- 7 | FROM base AS dependencies 8 | RUN npm ci 9 | 10 | # ---- Build ---- 11 | FROM dependencies AS build 12 | COPY . . 13 | RUN npm run build 14 | 15 | # ---- Production ---- 16 | FROM node:19-alpine AS production 17 | WORKDIR /app 18 | COPY --from=dependencies /app/node_modules ./node_modules 19 | COPY --from=build /app/.next ./.next 20 | COPY --from=build /app/public ./public 21 | COPY --from=build /app/package*.json ./ 22 | COPY --from=build /app/next.config.js ./next.config.js 23 | COPY --from=build /app/next-i18next.config.js ./next-i18next.config.js 24 | 25 | # Expose the port the app will run on 26 | EXPOSE 3000 27 | 28 | # Start the application 29 | CMD ["npm", "start"] 30 | -------------------------------------------------------------------------------- /chat-ui/Makefile: -------------------------------------------------------------------------------- 1 | include .env 2 | 3 | .PHONY: all 4 | 5 | build: 6 | docker build -t chatbot-ui . 7 | 8 | run: 9 | export $(cat .env | xargs) 10 | docker stop chatbot-ui || true && docker rm chatbot-ui || true 11 | docker run --name chatbot-ui --rm -e OPENAI_API_KEY=${OPENAI_API_KEY} -p 3000:3000 chatbot-ui 12 | 13 | logs: 14 | docker logs -f chatbot-ui 15 | 16 | push: 17 | docker tag chatbot-ui:latest ${DOCKER_USER}/chatbot-ui:${DOCKER_TAG} 18 | docker push ${DOCKER_USER}/chatbot-ui:${DOCKER_TAG} -------------------------------------------------------------------------------- /chat-ui/components/Button.tsx: -------------------------------------------------------------------------------- 1 | import { MouseEventHandler } from 'react'; 2 | 3 | import { twMerge } from 'tailwind-merge'; 4 | 5 | interface Props { 6 | onClick: MouseEventHandler; 7 | children: React.ReactNode; 8 | className?: string; 9 | } 10 | 11 | const Button = ({ onClick, children, className }: Props) => { 12 | return ( 13 | 22 | ); 23 | }; 24 | 25 | export default Button; 26 | -------------------------------------------------------------------------------- /chat-ui/components/Buttons/SidebarActionButton/SidebarActionButton.tsx: -------------------------------------------------------------------------------- 1 | import { MouseEventHandler, ReactElement } from 'react'; 2 | 3 | interface Props { 4 | handleClick: MouseEventHandler; 5 | children: ReactElement; 6 | } 7 | 8 | const SidebarActionButton = ({ handleClick, children }: Props) => ( 9 | 15 | ); 16 | 17 | export default SidebarActionButton; 18 | -------------------------------------------------------------------------------- /chat-ui/components/Buttons/SidebarActionButton/index.ts: -------------------------------------------------------------------------------- 1 | export { default } from './SidebarActionButton'; 2 | -------------------------------------------------------------------------------- /chat-ui/components/Chat/ChatLoader.tsx: -------------------------------------------------------------------------------- 1 | import { IconRobot } from '@tabler/icons-react'; 2 | import { FC } from 'react'; 3 | 4 | interface Props { } 5 | 6 | export const ChatLoader: FC = () => { 7 | return ( 8 |
12 |
13 |
14 | 15 |
16 | 17 |
18 |
19 | ); 20 | }; 21 | -------------------------------------------------------------------------------- /chat-ui/components/Chat/ErrorMessageDiv.tsx: -------------------------------------------------------------------------------- 1 | import { IconCircleX } from '@tabler/icons-react'; 2 | import { FC } from 'react'; 3 | 4 | import { ErrorMessage } from '@/types/error'; 5 | 6 | interface Props { 7 | error: ErrorMessage; 8 | } 9 | 10 | export const ErrorMessageDiv: FC = ({ error }) => { 11 | return ( 12 |
13 |
14 | 15 |
16 |
{error.title}
17 | {error.messageLines.map((line, index) => ( 18 |
19 | {' '} 20 | {line}{' '} 21 |
22 | ))} 23 |
24 | {error.code ? Code: {error.code} : ''} 25 |
26 |
27 | ); 28 | }; 29 | -------------------------------------------------------------------------------- /chat-ui/components/Chat/MemoizedChatMessage.tsx: -------------------------------------------------------------------------------- 1 | import { FC, memo } from "react"; 2 | import { ChatMessage, Props } from "./ChatMessage"; 3 | 4 | export const MemoizedChatMessage: FC = memo( 5 | ChatMessage, 6 | (prevProps, nextProps) => ( 7 | prevProps.message.content === nextProps.message.content 8 | ) 9 | ); 10 | -------------------------------------------------------------------------------- /chat-ui/components/Chat/PromptList.tsx: -------------------------------------------------------------------------------- 1 | import { FC, MutableRefObject } from 'react'; 2 | 3 | import { Prompt } from '@/types/prompt'; 4 | 5 | interface Props { 6 | prompts: Prompt[]; 7 | activePromptIndex: number; 8 | onSelect: () => void; 9 | onMouseOver: (index: number) => void; 10 | promptListRef: MutableRefObject; 11 | } 12 | 13 | export const PromptList: FC = ({ 14 | prompts, 15 | activePromptIndex, 16 | onSelect, 17 | onMouseOver, 18 | promptListRef, 19 | }) => { 20 | return ( 21 |
    25 | {prompts.map((prompt, index) => ( 26 |
  • { 34 | e.preventDefault(); 35 | e.stopPropagation(); 36 | onSelect(); 37 | }} 38 | onMouseEnter={() => onMouseOver(index)} 39 | > 40 | {prompt.name} 41 |
  • 42 | ))} 43 |
44 | ); 45 | }; 46 | -------------------------------------------------------------------------------- /chat-ui/components/Chat/Regenerate.tsx: -------------------------------------------------------------------------------- 1 | import { IconRefresh } from '@tabler/icons-react'; 2 | import { FC } from 'react'; 3 | 4 | import { useTranslation } from 'next-i18next'; 5 | 6 | interface Props { 7 | onRegenerate: () => void; 8 | } 9 | 10 | export const Regenerate: FC = ({ onRegenerate }) => { 11 | const { t } = useTranslation('chat'); 12 | return ( 13 |
14 |
15 | {t('Sorry, there was an error.')} 16 |
17 | 24 |
25 | ); 26 | }; 27 | -------------------------------------------------------------------------------- /chat-ui/components/Chatbar/Chatbar.context.tsx: -------------------------------------------------------------------------------- 1 | import { Dispatch, createContext } from 'react'; 2 | 3 | import { ActionType } from '@/hooks/useCreateReducer'; 4 | 5 | import { Conversation } from '@/types/chat'; 6 | import { SupportedExportFormats } from '@/types/export'; 7 | import { PluginKey } from '@/types/plugin'; 8 | 9 | import { ChatbarInitialState } from './Chatbar.state'; 10 | 11 | export interface ChatbarContextProps { 12 | state: ChatbarInitialState; 13 | dispatch: Dispatch>; 14 | handleDeleteConversation: (conversation: Conversation) => void; 15 | handleClearConversations: () => void; 16 | handleExportData: () => void; 17 | handleImportConversations: (data: SupportedExportFormats) => void; 18 | handlePluginKeyChange: (pluginKey: PluginKey) => void; 19 | handleClearPluginKey: (pluginKey: PluginKey) => void; 20 | handleApiKeyChange: (apiKey: string) => void; 21 | handlePluginsChange: (plugins: string[]) => void; 22 | } 23 | 24 | const ChatbarContext = createContext(undefined!); 25 | 26 | export default ChatbarContext; 27 | -------------------------------------------------------------------------------- /chat-ui/components/Chatbar/Chatbar.state.tsx: -------------------------------------------------------------------------------- 1 | import { Conversation } from '@/types/chat'; 2 | 3 | export interface ChatbarInitialState { 4 | searchTerm: string; 5 | filteredConversations: Conversation[]; 6 | } 7 | 8 | export const initialState: ChatbarInitialState = { 9 | searchTerm: '', 10 | filteredConversations: [], 11 | }; 12 | -------------------------------------------------------------------------------- /chat-ui/components/Chatbar/components/ChatFolders.tsx: -------------------------------------------------------------------------------- 1 | import { useContext } from 'react'; 2 | 3 | import { FolderInterface } from '@/types/folder'; 4 | 5 | import HomeContext from '@/pages/api/home/home.context'; 6 | 7 | import Folder from '@/components/Folder'; 8 | 9 | import { ConversationComponent } from './Conversation'; 10 | 11 | interface Props { 12 | searchTerm: string; 13 | } 14 | 15 | export const ChatFolders = ({ searchTerm }: Props) => { 16 | const { 17 | state: { folders, conversations }, 18 | handleUpdateConversation, 19 | } = useContext(HomeContext); 20 | 21 | const handleDrop = (e: any, folder: FolderInterface) => { 22 | if (e.dataTransfer) { 23 | const conversation = JSON.parse(e.dataTransfer.getData('conversation')); 24 | handleUpdateConversation(conversation, { 25 | key: 'folderId', 26 | value: folder.id, 27 | }); 28 | } 29 | }; 30 | 31 | const ChatFolders = (currentFolder: FolderInterface) => { 32 | return ( 33 | conversations && 34 | conversations 35 | .filter((conversation) => conversation.folderId) 36 | .map((conversation, index) => { 37 | if (conversation.folderId === currentFolder.id) { 38 | return ( 39 |
40 | 41 |
42 | ); 43 | } 44 | }) 45 | ); 46 | }; 47 | 48 | return ( 49 |
50 | {folders 51 | .filter((folder) => folder.type === 'chat') 52 | .sort((a, b) => a.name.localeCompare(b.name)) 53 | .map((folder, index) => ( 54 | 61 | ))} 62 |
63 | ); 64 | }; 65 | -------------------------------------------------------------------------------- /chat-ui/components/Chatbar/components/ClearConversations.tsx: -------------------------------------------------------------------------------- 1 | import { IconCheck, IconTrash, IconX } from '@tabler/icons-react'; 2 | import { FC, useState } from 'react'; 3 | 4 | import { useTranslation } from 'next-i18next'; 5 | 6 | import { SidebarButton } from '@/components/Sidebar/SidebarButton'; 7 | 8 | interface Props { 9 | onClearConversations: () => void; 10 | } 11 | 12 | export const ClearConversations: FC = ({ onClearConversations }) => { 13 | const [isConfirming, setIsConfirming] = useState(false); 14 | 15 | const { t } = useTranslation('sidebar'); 16 | 17 | const handleClearConversations = () => { 18 | onClearConversations(); 19 | setIsConfirming(false); 20 | }; 21 | 22 | return isConfirming ? ( 23 |
24 | 25 | 26 |
27 | {t('Are you sure?')} 28 |
29 | 30 |
31 | { 35 | e.stopPropagation(); 36 | handleClearConversations(); 37 | }} 38 | /> 39 | 40 | { 44 | e.stopPropagation(); 45 | setIsConfirming(false); 46 | }} 47 | /> 48 |
49 |
50 | ) : ( 51 | } 54 | onClick={() => setIsConfirming(true)} 55 | /> 56 | ); 57 | }; 58 | -------------------------------------------------------------------------------- /chat-ui/components/Chatbar/components/Conversations.tsx: -------------------------------------------------------------------------------- 1 | import { Conversation } from '@/types/chat'; 2 | 3 | import { ConversationComponent } from './Conversation'; 4 | 5 | interface Props { 6 | conversations: Conversation[]; 7 | } 8 | 9 | export const Conversations = ({ conversations }: Props) => { 10 | return ( 11 |
12 | {conversations 13 | .filter((conversation) => !conversation.folderId) 14 | .slice() 15 | .reverse() 16 | .map((conversation, index) => ( 17 | 18 | ))} 19 |
20 | ); 21 | }; 22 | -------------------------------------------------------------------------------- /chat-ui/components/Checkbox/index.tsx: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | 3 | interface CheckboxProps { 4 | label: string; 5 | checked: boolean; 6 | onChange: (e: React.ChangeEvent) => void; 7 | } 8 | 9 | const Checkbox: React.FC = ({ label, checked, onChange }) => { 10 | 11 | return ( 12 |
13 | 19 | 20 |
21 | ); 22 | }; 23 | 24 | export default Checkbox; 25 | -------------------------------------------------------------------------------- /chat-ui/components/DropdownButton.tsx: -------------------------------------------------------------------------------- 1 | interface Props { 2 | onClick?: () => void; 3 | children: React.ReactNode; 4 | } 5 | 6 | const DropdownButton = ({ onClick, children }: Props) => { 7 | return ( 8 | 14 | ); 15 | }; 16 | 17 | export default DropdownButton; 18 | -------------------------------------------------------------------------------- /chat-ui/components/Folder/index.ts: -------------------------------------------------------------------------------- 1 | export { default } from './Folder'; 2 | -------------------------------------------------------------------------------- /chat-ui/components/Input.tsx: -------------------------------------------------------------------------------- 1 | export const Input = ({ 2 | placeholder, 3 | value, 4 | onChange, 5 | type, 6 | }: JSX.IntrinsicElements['input']) => { 7 | return ( 8 | 15 | ); 16 | }; 17 | -------------------------------------------------------------------------------- /chat-ui/components/LoginButton.tsx: -------------------------------------------------------------------------------- 1 | import { useAuth0 } from '@auth0/auth0-react'; 2 | 3 | const LoginButton = () => { 4 | const { loginWithRedirect } = useAuth0(); 5 | 6 | return ( 7 | 13 | ); 14 | }; 15 | 16 | export default LoginButton; 17 | -------------------------------------------------------------------------------- /chat-ui/components/LogoutButton.tsx: -------------------------------------------------------------------------------- 1 | import { useAuth0 } from '@auth0/auth0-react'; 2 | import { IconLogout } from '@tabler/icons-react'; 3 | 4 | import DropdownButton from './DropdownButton'; 5 | 6 | const LogoutButton = () => { 7 | const { logout } = useAuth0(); 8 | 9 | return ( 10 | 12 | logout({ logoutParams: { returnTo: window.location.origin } }) 13 | } 14 | > 15 | 16 | Log Out 17 | 18 | ); 19 | }; 20 | 21 | export default LogoutButton; 22 | -------------------------------------------------------------------------------- /chat-ui/components/Markdown/MemoizedReactMarkdown.tsx: -------------------------------------------------------------------------------- 1 | import { FC, memo } from 'react'; 2 | import ReactMarkdown, { Options } from 'react-markdown'; 3 | 4 | export const MemoizedReactMarkdown: FC = memo( 5 | ReactMarkdown, 6 | (prevProps, nextProps) => ( 7 | prevProps.children === nextProps.children 8 | ) 9 | ); 10 | -------------------------------------------------------------------------------- /chat-ui/components/Mobile/Navbar.tsx: -------------------------------------------------------------------------------- 1 | import { IconPlus } from '@tabler/icons-react'; 2 | import { FC } from 'react'; 3 | 4 | import { Conversation } from '@/types/chat'; 5 | 6 | interface Props { 7 | selectedConversation: Conversation; 8 | onNewConversation: () => void; 9 | } 10 | 11 | export const Navbar: FC = ({ 12 | selectedConversation, 13 | onNewConversation, 14 | }) => { 15 | return ( 16 | 28 | ); 29 | }; 30 | -------------------------------------------------------------------------------- /chat-ui/components/Promptbar/PromptBar.context.tsx: -------------------------------------------------------------------------------- 1 | import { Dispatch, createContext } from 'react'; 2 | 3 | import { ActionType } from '@/hooks/useCreateReducer'; 4 | 5 | import { Prompt } from '@/types/prompt'; 6 | 7 | import { PromptbarInitialState } from './Promptbar.state'; 8 | 9 | export interface PromptbarContextProps { 10 | state: PromptbarInitialState; 11 | dispatch: Dispatch>; 12 | handleCreatePrompt: () => void; 13 | handleDeletePrompt: (prompt: Prompt) => void; 14 | handleUpdatePrompt: (prompt: Prompt) => void; 15 | } 16 | 17 | const PromptbarContext = createContext(undefined!); 18 | 19 | export default PromptbarContext; 20 | -------------------------------------------------------------------------------- /chat-ui/components/Promptbar/Promptbar.state.tsx: -------------------------------------------------------------------------------- 1 | import { Prompt } from '@/types/prompt'; 2 | 3 | export interface PromptbarInitialState { 4 | searchTerm: string; 5 | filteredPrompts: Prompt[]; 6 | } 7 | 8 | export const initialState: PromptbarInitialState = { 9 | searchTerm: '', 10 | filteredPrompts: [], 11 | }; 12 | -------------------------------------------------------------------------------- /chat-ui/components/Promptbar/components/PromptFolders.tsx: -------------------------------------------------------------------------------- 1 | import { useContext } from 'react'; 2 | 3 | import { FolderInterface } from '@/types/folder'; 4 | 5 | import HomeContext from '@/pages/api/home/home.context'; 6 | 7 | import Folder from '@/components/Folder'; 8 | import { PromptComponent } from '@/components/Promptbar/components/Prompt'; 9 | 10 | import PromptbarContext from '../PromptBar.context'; 11 | 12 | export const PromptFolders = () => { 13 | const { 14 | state: { folders }, 15 | } = useContext(HomeContext); 16 | 17 | const { 18 | state: { searchTerm, filteredPrompts }, 19 | handleUpdatePrompt, 20 | } = useContext(PromptbarContext); 21 | 22 | const handleDrop = (e: any, folder: FolderInterface) => { 23 | if (e.dataTransfer) { 24 | const prompt = JSON.parse(e.dataTransfer.getData('prompt')); 25 | 26 | const updatedPrompt = { 27 | ...prompt, 28 | folderId: folder.id, 29 | }; 30 | 31 | handleUpdatePrompt(updatedPrompt); 32 | } 33 | }; 34 | 35 | const PromptFolders = (currentFolder: FolderInterface) => 36 | filteredPrompts 37 | .filter((p) => p.folderId) 38 | .map((prompt, index) => { 39 | if (prompt.folderId === currentFolder.id) { 40 | return ( 41 |
42 | 43 |
44 | ); 45 | } 46 | }); 47 | 48 | return ( 49 |
50 | {folders 51 | .filter((folder) => folder.type === 'prompt') 52 | .sort((a, b) => a.name.localeCompare(b.name)) 53 | .map((folder, index) => ( 54 | 61 | ))} 62 |
63 | ); 64 | }; 65 | -------------------------------------------------------------------------------- /chat-ui/components/Promptbar/components/PromptbarSettings.tsx: -------------------------------------------------------------------------------- 1 | import { FC } from 'react'; 2 | 3 | interface Props {} 4 | 5 | export const PromptbarSettings: FC = () => { 6 | return
; 7 | }; 8 | -------------------------------------------------------------------------------- /chat-ui/components/Promptbar/components/Prompts.tsx: -------------------------------------------------------------------------------- 1 | import { FC } from 'react'; 2 | 3 | import { Prompt } from '@/types/prompt'; 4 | 5 | import { PromptComponent } from './Prompt'; 6 | 7 | interface Props { 8 | prompts: Prompt[]; 9 | } 10 | 11 | export const Prompts: FC = ({ prompts }) => { 12 | return ( 13 |
14 | {prompts 15 | .slice() 16 | .reverse() 17 | .map((prompt, index) => ( 18 | 19 | ))} 20 |
21 | ); 22 | }; 23 | -------------------------------------------------------------------------------- /chat-ui/components/Promptbar/index.ts: -------------------------------------------------------------------------------- 1 | export { default } from './Promptbar'; 2 | -------------------------------------------------------------------------------- /chat-ui/components/RadioButton.tsx: -------------------------------------------------------------------------------- 1 | interface RadioButtonProps { 2 | label: string; // Label text for the radio button 3 | id: string; // Unique ID for the radio button (should match with htmlFor in the label) 4 | name: string; // Name attribute (to group radio buttons) 5 | value: string; // Value attribute 6 | checked: boolean; // If the radio button is currently checked 7 | onChange: (e: React.ChangeEvent) => void; // Change event handler 8 | disabled?: boolean; // Optional: If the radio button is disabled 9 | } 10 | 11 | export const RadioButton: React.FC = ({ 12 | label, 13 | id, 14 | name, 15 | value, 16 | checked, 17 | onChange, 18 | disabled, 19 | }) => { 20 | return ( 21 |
22 | 32 | 38 |
39 | ); 40 | }; 41 | -------------------------------------------------------------------------------- /chat-ui/components/Search/Search.tsx: -------------------------------------------------------------------------------- 1 | import { IconX } from '@tabler/icons-react'; 2 | import { FC } from 'react'; 3 | 4 | import { useTranslation } from 'next-i18next'; 5 | 6 | interface Props { 7 | placeholder: string; 8 | searchTerm: string; 9 | onSearch: (searchTerm: string) => void; 10 | } 11 | const Search: FC = ({ placeholder, searchTerm, onSearch }) => { 12 | const { t } = useTranslation('sidebar'); 13 | 14 | const handleSearchChange = (e: React.ChangeEvent) => { 15 | onSearch(e.target.value); 16 | }; 17 | 18 | const clearSearch = () => { 19 | onSearch(''); 20 | }; 21 | 22 | return ( 23 |
24 | 31 | 32 | {searchTerm && ( 33 | 38 | )} 39 |
40 | ); 41 | }; 42 | 43 | export default Search; 44 | -------------------------------------------------------------------------------- /chat-ui/components/Search/index.ts: -------------------------------------------------------------------------------- 1 | export { default } from './Search'; 2 | -------------------------------------------------------------------------------- /chat-ui/components/Select.tsx: -------------------------------------------------------------------------------- 1 | // Select.tsx 2 | import React from 'react'; 3 | 4 | type DefaultOptionType = { 5 | label: string; 6 | value: string; 7 | }; 8 | 9 | interface SelectProps { 10 | options: T[]; 11 | getOptionLabel?: (option: T) => string; 12 | getOptionValue?: (option: T) => string; 13 | className?: string; 14 | value?: string | number; 15 | onChange?: (event: React.ChangeEvent) => void; 16 | disabled?: boolean; 17 | [x: string]: any; // This allows for any additional props. 18 | } 19 | 20 | export const Select = ({ 21 | options, 22 | getOptionLabel = (option: T) => option.label, 23 | getOptionValue = (option: T) => option.value, 24 | className, 25 | ...props 26 | }: SelectProps) => { 27 | const defaultClass = 28 | 'w-full flex-1 rounded-md border border-neutral-600 bg-[#202123] px-4 py-3 pr-10 text-[14px] leading-3 text-white'; 29 | 30 | return ( 31 | 38 | ); 39 | }; 40 | -------------------------------------------------------------------------------- /chat-ui/components/Settings/Import.tsx: -------------------------------------------------------------------------------- 1 | import { IconFileImport } from '@tabler/icons-react'; 2 | import { FC } from 'react'; 3 | 4 | import { useTranslation } from 'next-i18next'; 5 | 6 | import { SupportedExportFormats } from '@/types/export'; 7 | 8 | import { SidebarButton } from '../Sidebar/SidebarButton'; 9 | 10 | interface Props { 11 | onImport: (data: SupportedExportFormats) => void; 12 | } 13 | 14 | export const Import: FC = ({ onImport }) => { 15 | const { t } = useTranslation('sidebar'); 16 | return ( 17 | <> 18 | { 25 | if (!e.target.files?.length) return; 26 | 27 | const file = e.target.files[0]; 28 | const reader = new FileReader(); 29 | reader.onload = (e) => { 30 | let json = JSON.parse(e.target?.result as string); 31 | onImport(json); 32 | }; 33 | reader.readAsText(file); 34 | }} 35 | /> 36 | 37 | } 40 | onClick={() => { 41 | const importFile = document.querySelector( 42 | '#import-file', 43 | ) as HTMLInputElement; 44 | if (importFile) { 45 | importFile.click(); 46 | } 47 | }} 48 | /> 49 | 50 | ); 51 | }; 52 | -------------------------------------------------------------------------------- /chat-ui/components/Sidebar/SidebarButton.tsx: -------------------------------------------------------------------------------- 1 | import { FC } from 'react'; 2 | 3 | interface Props { 4 | text: string; 5 | icon: JSX.Element; 6 | iconRight?: JSX.Element; 7 | onClick: () => void; 8 | textClassName?: string; 9 | } 10 | 11 | export const SidebarButton: FC = ({ 12 | text, 13 | icon, 14 | iconRight, 15 | onClick, 16 | textClassName, 17 | }) => { 18 | return ( 19 | 29 | ); 30 | }; 31 | -------------------------------------------------------------------------------- /chat-ui/components/Sidebar/components/OpenCloseButton.tsx: -------------------------------------------------------------------------------- 1 | import { IconArrowBarLeft, IconArrowBarRight } from '@tabler/icons-react'; 2 | 3 | interface Props { 4 | onClick: any; 5 | side: 'left' | 'right'; 6 | } 7 | 8 | export const CloseSidebarButton = ({ onClick, side }: Props) => { 9 | return ( 10 | <> 11 | 21 |
25 | 26 | ); 27 | }; 28 | 29 | export const OpenSidebarButton = ({ onClick, side }: Props) => { 30 | return ( 31 | 41 | ); 42 | }; 43 | -------------------------------------------------------------------------------- /chat-ui/components/Sidebar/index.ts: -------------------------------------------------------------------------------- 1 | export { default } from './Sidebar'; 2 | -------------------------------------------------------------------------------- /chat-ui/components/Spinner/Spinner.tsx: -------------------------------------------------------------------------------- 1 | import { FC } from 'react'; 2 | 3 | import { twMerge } from 'tailwind-merge'; 4 | 5 | interface Props { 6 | className?: string; 7 | } 8 | 9 | const Spinner = ({ className }: Props) => { 10 | return ( 11 |
17 | ); 18 | }; 19 | 20 | export default Spinner; 21 | -------------------------------------------------------------------------------- /chat-ui/components/Spinner/index.ts: -------------------------------------------------------------------------------- 1 | export { default } from './Spinner'; 2 | -------------------------------------------------------------------------------- /chat-ui/docs/chatpdf.md: -------------------------------------------------------------------------------- 1 | # Chatwithpdf Plugin 2 | 3 | Join millions of students, researchers and professionals to instantly answer questions and understand research with AI 4 | 5 | ## How It Works 6 | 7 | 1. Prepare for exams, get help with homework and answer multiple choice questions. 8 | 9 | 2. Scientific papers, academic articles and books. Get the information you need for your research. 10 | 11 | 3. Legal contracts, financial reports, manuals and training material. Ask any question to any PDF and get insights fast. 12 | 13 | 4. Works worldwide! ChatPDF accepts PDFs in any language and can chat in any language. 14 | 15 | 5. Answers contain references to their source in the original PDF document. No more flipping pages. 16 | 17 | 6. Fast, easy, free & secure! Files are stored in a secure cloud storage and will never be shared. 18 | 19 | ## Usage 20 | 21 | 1. Incorporate the Chatpdf plugin into your project 22 | 23 | 2. Access the plugin in the search tools dropdown of your Chatbot UI. 24 | 25 | 3. Enter one or more keywords or phrases that describe the research topic you're interested in. 26 | 27 | 4. The plugin will return a list of paper abstracts related to your keywords. Browse through the summaries to find the information you need. 28 | 29 | ## Note 30 | 31 | To obtain the most accurate and relevant results, consider refining your keywords or using specific terms related to your research topic. 32 | 33 | While the Chatpdf plugin provides abstracts, access to full papers or citations may require further actions, such as visiting the source website. -------------------------------------------------------------------------------- /chat-ui/docs/google_search.md: -------------------------------------------------------------------------------- 1 | # Google Search Tool 2 | 3 | Use the Google Search API to search the web in Chatbot UI. 4 | 5 | ## How To Enable 6 | 7 | 1. Create a new project at https://console.developers.google.com/apis/dashboard 8 | 9 | 2. Create a new API key at https://console.developers.google.com/apis/credentials 10 | 11 | 3. Enable the Custom Search API at https://console.developers.google.com/apis/library/customsearch.googleapis.com 12 | 13 | 4. Create a new Custom Search Engine at https://cse.google.com/cse/all 14 | 15 | 5. Add your API Key and your Custom Search Engine ID to your .env.local file 16 | 17 | 6. You can now select the Google Search Tool in the search tools dropdown 18 | 19 | ## Usage Limits 20 | 21 | Google gives you 100 free searches per day. You can increase this limit by creating a billing account. 22 | -------------------------------------------------------------------------------- /chat-ui/docs/scholar-ai.md: -------------------------------------------------------------------------------- 1 | # ScholarAI Plugin 2 | 3 | The ScholarAI plugin empowers you to retrieve pertinent paper abstracts by performing keyword searches. Whether you're a researcher, student, or simply curious about a particular topic, this plugin makes it easy to access academic knowledge on demand. 4 | 5 | ## How It Works 6 | 7 | 1. ScholarAI plugin to search for academic papers by entering specific keywords related to your area of interest. 8 | 9 | 2. The plugin will fetch abstracts of papers matching your search criteria, providing you with concise summaries of relevant research. 10 | 11 | ## Usage 12 | 13 | 1. Incorporate the ScholarAI plugin into your project 14 | 15 | 2. Access the plugin in the search tools dropdown of your Chatbot UI. 16 | 17 | 3. Enter one or more keywords or phrases that describe the research topic you're interested in. 18 | 19 | 4. The plugin will return a list of paper abstracts related to your keywords. Browse through the summaries to find the information you need. 20 | 21 | ## Note 22 | 23 | To obtain the most accurate and relevant results, consider refining your keywords or using specific terms related to your research topic. 24 | 25 | While the ScholarAI plugin provides abstracts, access to full papers or citations may require further actions, such as visiting the source website. -------------------------------------------------------------------------------- /chat-ui/docs/what-to-watch.md: -------------------------------------------------------------------------------- 1 | # What to Watch Plugin 2 | 3 | The What to Watch Plugin simplifies the process of obtaining comprehensive information about a TV show by its name. Whether you're a film enthusiast or just looking for your next binge-worthy series, this plugin provides quick access to essential details. 4 | 5 | ## How It Works 6 | 7 | 1. Use the What to Watch Plugin to perform searches based on the name of the TV show you're interested in. 8 | 9 | 2. The plugin will fetch a wealth of information about the TV show, including its synopsis, cast, release date, genre, and more. 10 | 11 | ## Usage 12 | 13 | 1. Incorporate the What to Watch plugin into your project 14 | 15 | 2. Access the plugin in the search tools dropdown of your Chatbot UI. 16 | 17 | 3. Enter the name of the TV show you want to learn more about. 18 | 19 | 4. The plugin will return a detailed summary of the TV show, including its plot, cast and crew, episode list, release history, and other relevant information. 20 | 21 | ## Note 22 | 23 | Ensure the accuracy of the TV show's name to obtain the most precise results. 24 | 25 | While the plugin provides comprehensive show details, accessing streaming platforms or additional information may require further actions. -------------------------------------------------------------------------------- /chat-ui/hooks/useAPIFetch.tsx: -------------------------------------------------------------------------------- 1 | import { useAuth0 } from '@auth0/auth0-react'; 2 | 3 | export function useAPIFetch() { 4 | const { getAccessTokenSilently } = useAuth0(); 5 | 6 | async function customFetch(url: string, options: RequestInit = {}) { 7 | const token = await getAccessTokenSilently(); 8 | 9 | const fetchOptions = { 10 | ...options, 11 | headers: { 12 | ...options.headers, 13 | Authorization: `Bearer ${token}`, 14 | 'Content-Type': 'application/json', 15 | }, 16 | }; 17 | 18 | return fetch( 19 | process.env.NEXT_PUBLIC_VALIDATOR_ENDPOINT_BASE_URL + url, 20 | fetchOptions, 21 | ).then(async (response) => { 22 | if (!response.ok) { 23 | console.error(await response.json()); 24 | throw new Error('Network response was not ok'); 25 | } 26 | return response.json(); 27 | }); 28 | } 29 | 30 | return customFetch; 31 | } 32 | -------------------------------------------------------------------------------- /chat-ui/hooks/useApi.ts: -------------------------------------------------------------------------------- 1 | import { useEffect, useState } from 'react'; 2 | import useSWR, { KeyedMutator } from 'swr'; 3 | import { BlockingData } from 'swr/_internal'; 4 | import { Config } from 'tailwindcss'; 5 | 6 | interface UseApiResponseType { 7 | loading: boolean, 8 | data: any; 9 | error: Error | undefined; 10 | mutate: Function; 11 | } 12 | 13 | 14 | /** 15 | * Re-usable SWR api implementation. 16 | * 17 | * @param {string} url 18 | * @param {object} params 19 | * @returns object 20 | */ 21 | function useApi(url:string | null, params = {}): UseApiResponseType { 22 | const usp = new URLSearchParams(params); 23 | const [cacheData, setCacheData] = useState<[] | Object>(); 24 | 25 | // Create a stable key for SWR 26 | usp.sort(); 27 | const qs = usp.toString(); 28 | 29 | const { data, error, mutate } = useSWR(url && `${url}${qs?'?'+qs:''}`, fetcher); 30 | 31 | const isLoading = !error && !data; 32 | 33 | useEffect(() => { 34 | if(isLoading) return; 35 | setCacheData(data); 36 | }, [data]); 37 | 38 | return { 39 | loading: !error && !data, 40 | data: cacheData, 41 | error, 42 | mutate 43 | }; 44 | } 45 | 46 | 47 | const fetcher = async (url: string) => { 48 | const res = await fetch(url, {method: 'GET'}) 49 | 50 | if (!res.ok) { 51 | const error = new Error('An error occurred while fetching the data.') 52 | throw error 53 | } 54 | 55 | return res.json() 56 | } 57 | 58 | 59 | export default useApi; -------------------------------------------------------------------------------- /chat-ui/hooks/useCreateReducer.ts: -------------------------------------------------------------------------------- 1 | import { useMemo, useReducer } from 'react'; 2 | 3 | // Extracts property names from initial state of reducer to allow typesafe dispatch objects 4 | export type FieldNames = { 5 | [K in keyof T]: T[K] extends string ? K : K; 6 | }[keyof T]; 7 | 8 | // Returns the Action Type for the dispatch object to be used for typing in things like context 9 | export type ActionType = 10 | | { type: 'reset' } 11 | | { type?: 'change'; field: FieldNames; value: any }; 12 | 13 | // Returns a typed dispatch and state 14 | export const useCreateReducer = ({ initialState }: { initialState: T }) => { 15 | type Action = 16 | | { type: 'reset' } 17 | | { type?: 'change'; field: FieldNames; value: any }; 18 | 19 | const reducer = (state: T, action: Action) => { 20 | if (!action.type) return { ...state, [action.field]: action.value }; 21 | 22 | if (action.type === 'reset') return initialState; 23 | 24 | throw new Error(); 25 | }; 26 | 27 | const [state, dispatch] = useReducer(reducer, initialState); 28 | 29 | return useMemo(() => ({ state, dispatch }), [state, dispatch]); 30 | }; 31 | -------------------------------------------------------------------------------- /chat-ui/k8s/chatbot-ui.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: chatbot-ui 5 | --- 6 | apiVersion: v1 7 | kind: Secret 8 | metadata: 9 | namespace: chatbot-ui 10 | name: chatbot-ui 11 | type: Opaque 12 | data: 13 | OPENAI_API_KEY: 14 | --- 15 | apiVersion: apps/v1 16 | kind: Deployment 17 | metadata: 18 | namespace: chatbot-ui 19 | name: chatbot-ui 20 | labels: 21 | app: chatbot-ui 22 | spec: 23 | replicas: 1 24 | selector: 25 | matchLabels: 26 | app: chatbot-ui 27 | template: 28 | metadata: 29 | labels: 30 | app: chatbot-ui 31 | spec: 32 | containers: 33 | - name: chatbot-ui 34 | image: /chatbot-ui:latest 35 | resources: {} 36 | ports: 37 | - containerPort: 3000 38 | env: 39 | - name: OPENAI_API_KEY 40 | valueFrom: 41 | secretKeyRef: 42 | name: chatbot-ui 43 | key: OPENAI_API_KEY 44 | --- 45 | kind: Service 46 | apiVersion: v1 47 | metadata: 48 | namespace: chatbot-ui 49 | name: chatbot-ui 50 | labels: 51 | app: chatbot-ui 52 | spec: 53 | ports: 54 | - name: http 55 | protocol: TCP 56 | port: 80 57 | targetPort: 3000 58 | selector: 59 | app: chatbot-ui 60 | type: ClusterIP 61 | -------------------------------------------------------------------------------- /chat-ui/license: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Mckay Wrigley 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /chat-ui/next-i18next.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | i18n: { 3 | defaultLocale: 'en', 4 | locales: [ 5 | "bn", 6 | "de", 7 | "en", 8 | "es", 9 | "fr", 10 | "he", 11 | "id", 12 | "it", 13 | "ja", 14 | "ko", 15 | "pl", 16 | "pt", 17 | "ru", 18 | "ro", 19 | "sv", 20 | "te", 21 | "vi", 22 | "zh", 23 | "ar", 24 | "tr", 25 | "ca", 26 | "fi", 27 | ], 28 | }, 29 | localePath: 30 | typeof window === 'undefined' 31 | ? require('path').resolve('./public/locales') 32 | : '/public/locales', 33 | }; 34 | -------------------------------------------------------------------------------- /chat-ui/next.config.js: -------------------------------------------------------------------------------- 1 | const { i18n } = require('./next-i18next.config'); 2 | 3 | /** @type {import('next').NextConfig} */ 4 | const nextConfig = { 5 | i18n, 6 | reactStrictMode: true, 7 | 8 | webpack(config, { isServer, dev }) { 9 | config.experiments = { 10 | asyncWebAssembly: true, 11 | layers: true, 12 | }; 13 | 14 | return config; 15 | }, 16 | images: { 17 | remotePatterns: [ 18 | { 19 | // auth0 username/password avatars 20 | hostname: 's.gravatar.com', 21 | }, 22 | { 23 | // Google avatars 24 | hostname: 'lh3.googleusercontent.com', 25 | }, 26 | { 27 | // Github Avatars 28 | hostname: 'avatars.githubusercontent.com', 29 | }, 30 | ], 31 | }, 32 | }; 33 | 34 | module.exports = nextConfig; 35 | -------------------------------------------------------------------------------- /chat-ui/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ai-chatbot-starter", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "next dev", 7 | "build": "next build", 8 | "start": "next start", 9 | "lint": "next lint", 10 | "format": "prettier --write .", 11 | "test": "vitest", 12 | "coverage": "vitest run --coverage" 13 | }, 14 | "dependencies": { 15 | "@auth0/auth0-react": "^2.2.0", 16 | "@dqbd/tiktoken": "^1.0.2", 17 | "@tabler/icons-react": "^2.9.0", 18 | "@tanstack/react-query": "^4.32.6", 19 | "eventsource-parser": "^0.1.0", 20 | "i18next": "^22.4.13", 21 | "luxon": "^3.4.0", 22 | "next": "13.2.4", 23 | "next-i18next": "^13.2.2", 24 | "openai": "^3.2.1", 25 | "react": "18.2.0", 26 | "react-dom": "18.2.0", 27 | "react-hot-toast": "^2.4.0", 28 | "react-i18next": "^12.2.0", 29 | "react-markdown": "^8.0.5", 30 | "react-syntax-highlighter": "^15.5.0", 31 | "rehype-mathjax": "^4.0.2", 32 | "remark-gfm": "^3.0.1", 33 | "remark-math": "^5.1.1", 34 | "swr": "^2.2.2", 35 | "tailwind-merge": "^1.14.0", 36 | "uuid": "^9.0.0" 37 | }, 38 | "devDependencies": { 39 | "@mozilla/readability": "^0.4.4", 40 | "@tailwindcss/typography": "^0.5.9", 41 | "@trivago/prettier-plugin-sort-imports": "^4.1.1", 42 | "@types/jsdom": "^21.1.1", 43 | "@types/luxon": "^3.3.1", 44 | "@types/node": "18.15.0", 45 | "@types/react": "18.0.28", 46 | "@types/react-dom": "18.0.11", 47 | "@types/react-syntax-highlighter": "^15.5.6", 48 | "@types/uuid": "^9.0.1", 49 | "@vitest/coverage-c8": "^0.29.7", 50 | "autoprefixer": "^10.4.14", 51 | "endent": "^2.1.0", 52 | "eslint": "8.36.0", 53 | "eslint-config-next": "13.2.4", 54 | "gpt-3-encoder": "^1.1.4", 55 | "jsdom": "^21.1.1", 56 | "postcss": "^8.4.21", 57 | "prettier": "^2.8.7", 58 | "prettier-plugin-tailwindcss": "^0.2.5", 59 | "tailwindcss": "^3.2.7", 60 | "typescript": "4.9.5", 61 | "vitest": "^0.29.7" 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /chat-ui/pages/_app.tsx: -------------------------------------------------------------------------------- 1 | import { Auth0Provider } from '@auth0/auth0-react'; 2 | import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; 3 | import { Toaster } from 'react-hot-toast'; 4 | 5 | import { appWithTranslation } from 'next-i18next'; 6 | import type { AppProps } from 'next/app'; 7 | import { Inter } from 'next/font/google'; 8 | 9 | import { AUTH0_CLIENT_ID, AUTH0_DOMAIN } from '@/utils/app/const'; 10 | 11 | import '@/styles/globals.css'; 12 | 13 | if (!AUTH0_CLIENT_ID || !AUTH0_DOMAIN) { 14 | throw new Error( 15 | 'Please define AUTH0_CLIENT_ID and AUTH0_DOMAIN in your .env.local file', 16 | ); 17 | } 18 | 19 | const inter = Inter({ subsets: ['latin'] }); 20 | 21 | function App({ Component, pageProps }: AppProps<{}>) { 22 | const queryClient = new QueryClient(); 23 | 24 | return ( 25 |
26 | 27 | 39 | 40 | 41 | 42 | 43 |
44 | ); 45 | } 46 | 47 | export default appWithTranslation(App); 48 | -------------------------------------------------------------------------------- /chat-ui/pages/_document.tsx: -------------------------------------------------------------------------------- 1 | import { DocumentProps, Head, Html, Main, NextScript } from 'next/document'; 2 | 3 | import i18nextConfig from '../next-i18next.config'; 4 | 5 | type Props = DocumentProps & { 6 | // add custom document props 7 | }; 8 | 9 | export default function Document(props: Props) { 10 | const currentLocale = 11 | props.__NEXT_DATA__.locale ?? i18nextConfig.i18n.defaultLocale; 12 | return ( 13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | ); 24 | } 25 | -------------------------------------------------------------------------------- /chat-ui/pages/api/home/home.context.tsx: -------------------------------------------------------------------------------- 1 | import { Dispatch, createContext } from 'react'; 2 | 3 | import { ActionType } from '@/hooks/useCreateReducer'; 4 | 5 | import { Conversation } from '@/types/chat'; 6 | import { KeyValuePair } from '@/types/data'; 7 | import { FolderType } from '@/types/folder'; 8 | 9 | import { HomeInitialState } from './home.state'; 10 | 11 | export interface HomeContextProps { 12 | state: HomeInitialState; 13 | dispatch: Dispatch>; 14 | handleNewConversation: () => void; 15 | handleCreateFolder: (name: string, type: FolderType) => void; 16 | handleDeleteFolder: (folderId: string) => void; 17 | handleUpdateFolder: (folderId: string, name: string) => void; 18 | handleSelectConversation: (conversation: Conversation) => void; 19 | handleUpdateConversation: ( 20 | conversation: Conversation, 21 | data: KeyValuePair, 22 | ) => void; 23 | } 24 | 25 | const HomeContext = createContext(undefined!); 26 | 27 | export default HomeContext; 28 | -------------------------------------------------------------------------------- /chat-ui/pages/api/home/home.state.tsx: -------------------------------------------------------------------------------- 1 | import { Conversation, Message } from '@/types/chat'; 2 | import { ErrorMessage } from '@/types/error'; 3 | import { FolderInterface } from '@/types/folder'; 4 | import { PluginKey } from '@/types/plugin'; 5 | import { Prompt } from '@/types/prompt'; 6 | 7 | export interface HomeInitialState { 8 | apiKey: string; 9 | pluginKeys: PluginKey[]; 10 | loading: boolean; 11 | lightMode: 'light' | 'dark'; 12 | messageIsStreaming: boolean; 13 | modelError: ErrorMessage | null; 14 | folders: FolderInterface[]; 15 | conversations: Conversation[]; 16 | selectedConversation: Conversation | undefined; 17 | currentMessage: Message | undefined; 18 | prompts: Prompt[]; 19 | temperature: number; 20 | showChatbar: boolean; 21 | showPromptbar: boolean; 22 | currentFolder: FolderInterface | undefined; 23 | messageError: boolean; 24 | searchTerm: string; 25 | serverSideApiKeyIsSet: boolean; 26 | serverSidePluginKeysSet: boolean; 27 | api: string; 28 | selectedPlugins: string[]; 29 | publicPDFLink: string; 30 | } 31 | 32 | export const initialState: HomeInitialState = { 33 | apiKey: '', 34 | loading: false, 35 | pluginKeys: [], 36 | lightMode: 'dark', 37 | messageIsStreaming: false, 38 | modelError: null, 39 | folders: [], 40 | conversations: [], 41 | selectedConversation: undefined, 42 | currentMessage: undefined, 43 | prompts: [], 44 | temperature: 1, 45 | showPromptbar: true, 46 | showChatbar: true, 47 | currentFolder: undefined, 48 | messageError: false, 49 | searchTerm: '', 50 | serverSideApiKeyIsSet: false, 51 | serverSidePluginKeysSet: false, 52 | api: 'bitapai', 53 | selectedPlugins: [], 54 | publicPDFLink: "src_tDP4qdu6bZZA6xsUIW9F6", 55 | }; 56 | -------------------------------------------------------------------------------- /chat-ui/pages/api/home/index.ts: -------------------------------------------------------------------------------- 1 | export { default, getServerSideProps } from './home'; 2 | -------------------------------------------------------------------------------- /chat-ui/pages/api/plugins/chatpdf.ts: -------------------------------------------------------------------------------- 1 | import axios from "axios" 2 | 3 | export const runPlugin = async ({ sourceId, text }: { sourceId:string, text: string }) => { 4 | console.log(sourceId, text); 5 | const config = { 6 | headers: { 7 | "x-api-key": `${process.env.NEXT_PUBLIC_CHATPDF_API_KEY}`, 8 | "Content-Type": "application/json", 9 | }, 10 | }; 11 | 12 | const data = { 13 | "sourceId": sourceId, 14 | "messages": [ 15 | { 16 | "role": "user", 17 | "content": text 18 | } 19 | ] 20 | }; 21 | 22 | console.log("\n", data, config); 23 | 24 | const res = await fetch("https://api.chatpdf.com/v1/chats/message",{ 25 | method: "POST", 26 | headers: { 27 | "x-api-key": `${process.env.NEXT_PUBLIC_CHATPDF_API_KEY}`, 28 | "Content-Type": "application/json", 29 | }, 30 | body: JSON.stringify(data) 31 | }) 32 | .then(response => response.json()) 33 | .catch((error) => { 34 | console.log("error"); 35 | console.error("Error:", error.message); 36 | console.log("Response:", error.response.data); 37 | }); 38 | console.log("res->",res); 39 | return res; 40 | }; 41 | 42 | export default { 43 | id: 'chatpdf', 44 | name: 'ChatPDF', 45 | description: 'Helpful for students, researchers, and professionals', 46 | parameters: { 47 | sourceId: { 48 | type: 'string', 49 | description: 'This parameter is already given', 50 | }, 51 | text: { 52 | type: 'string', 53 | description: 'This parameter is already given', 54 | }, 55 | }, 56 | run: runPlugin, 57 | }; -------------------------------------------------------------------------------- /chat-ui/pages/api/plugins/google-search.ts: -------------------------------------------------------------------------------- 1 | export const runPlugin = async ({ q }: { q?: string }) => { 2 | const resp: any = await fetch( 3 | `https://www.googleapis.com/customsearch/v1?key=${process.env.GOOGLE_SEARCH_API_KEY}&cx=${process.env.GOOGLE_SEARCH_ENGINE_ID}&q=${q}`, 4 | ).then((res) => res.json()); 5 | 6 | // extract 'htmlTitle', 'link', 'displayLink', 'htmlSnippet','htmlFormattedUrl', 'pagemap' from resp.items 7 | const items = resp.items.map((item: any) => { 8 | return { 9 | title: item.title, 10 | htmlTitle: item.htmlTitle, 11 | link: item.link, 12 | displayLink: item.displayLink, 13 | snippet: item.snippet, 14 | htmlSnippet: item.htmlSnippet, 15 | formattedUrl: item.formattedUrl, 16 | htmlFormattedUrl: item.htmlFormattedUrl, 17 | }; 18 | }); 19 | 20 | return ( 21 | "Here's the google search result for the user query:\n" + 22 | items.join('\n') + 23 | "\n\nNow, I need you to analyze these search results and provide a detailed summary. Here's what you should focus on:\n" + 24 | "- The main idea or theme of each search result\n" + 25 | "- Any common patterns or themes across the search results\n" + 26 | "- Noteworthy or surprising details from the search results\n" + 27 | "- Any other insights or conclusions you can draw from the search results\n\n" + 28 | "Remember, your goal is to provide the search result in bullets as well as a comprehensive and understandable summary of these search results below." 29 | ); 30 | }; 31 | 32 | export default { 33 | id: 'google-search', 34 | name: 'Google Search', 35 | description: 'Searches Google for the given query and returns the results.', 36 | parameters: { 37 | q: { 38 | type: 'string', 39 | description: 'Query', 40 | }, 41 | }, 42 | run: runPlugin, 43 | }; 44 | -------------------------------------------------------------------------------- /chat-ui/pages/api/plugins/index.ts: -------------------------------------------------------------------------------- 1 | import { NextApiRequest, NextApiResponse } from 'next'; 2 | 3 | import googleSearch from './google-search'; 4 | import weather from './open-weather'; 5 | import news from './world-news'; 6 | import chatpdf from './chatpdf'; 7 | import whatToWatch from './what-to-watch'; 8 | import scholarAi from './scholar-ai'; 9 | 10 | export const plugins = [weather, news, googleSearch, chatpdf, whatToWatch, scholarAi]; 11 | 12 | export default (req: NextApiRequest, res: NextApiResponse) => { 13 | res.json( 14 | plugins.map((plugin) => ({ 15 | id: plugin.id, 16 | name: plugin.name, 17 | description: plugin.description, 18 | parameters: plugin.parameters, 19 | })), 20 | ); 21 | }; 22 | -------------------------------------------------------------------------------- /chat-ui/pages/api/plugins/open-weather.ts: -------------------------------------------------------------------------------- 1 | export const runPlugin = async ({ 2 | latitude, 3 | longitude, 4 | }: { 5 | latitude?: number; 6 | longitude?: number; 7 | }) => { 8 | const resp: any = await fetch( 9 | `https://api.openweathermap.org/data/3.0/onecall?lat=${latitude}&lon=${longitude}&appid=${process.env.WEATHER_API_KEY}&units=metric`, 10 | ).then((res) => res.json()); 11 | delete resp.minutely; 12 | delete resp.hourly; 13 | return { 14 | lat: resp.lat, 15 | lon: resp.lon, 16 | timezone: resp.timezone, 17 | timezone_offset: resp.timezone_offset, 18 | current: { 19 | dt: resp.current.dt, 20 | sunrise: resp.current.sunrise, 21 | sunset: resp.current.sunset, 22 | temp: resp.current.temp + '°C', 23 | feels_like: resp.current.feels_like + '°C', 24 | pressure: resp.current.pressure + 'hPa', 25 | humidity: resp.current.humidity + '%', 26 | dew_point: resp.current.dew_point + '°C', 27 | uvi: resp.current.uvi, 28 | clouds: resp.current.clouds + '%', 29 | visibility: resp.current.visibility + 'm', 30 | wind_speed: resp.current.wind_speed + 'm/s', 31 | wind_deg: resp.current.wind_deg + '°', 32 | weather: resp.current.weather, 33 | }, 34 | }; 35 | }; 36 | 37 | export default { 38 | id: 'weather', 39 | name: 'Weather', 40 | description: 41 | 'Provides weather forecast based on location. Includes temperature, precipitation, cloud cover, wind and much more.', 42 | parameters: { 43 | latitude: { 44 | type: 'decimal', 45 | description: 'Latitude of the location to get weather forecast for.', 46 | }, 47 | longitude: { 48 | type: 'decimal', 49 | description: 'Longitude of the location to get weather forecast for.', 50 | }, 51 | }, 52 | run: runPlugin, 53 | }; 54 | -------------------------------------------------------------------------------- /chat-ui/pages/api/plugins/scholar-ai.ts: -------------------------------------------------------------------------------- 1 | const extractKeywords = (chatbotQuery: string): string => { 2 | // Define a list of common stop words to exclude 3 | const stopWords = [ 4 | 'a', 5 | 'an', 6 | 'the', 7 | 'in', 8 | 'on', 9 | 'at', 10 | 'of', 11 | 'for', 12 | 'with', 13 | 'to', 14 | 'and', 15 | 'or', 16 | ]; 17 | 18 | const words = chatbotQuery.split(/\s+/); 19 | 20 | const keywords = words.filter((word) => { 21 | const lowercasedWord = word.toLowerCase(); 22 | return !stopWords.includes(lowercasedWord); 23 | }); 24 | 25 | const keywordsString = keywords.join(' '); 26 | 27 | return keywordsString; 28 | }; 29 | 30 | export const runPlugin = async ({ query }: { query: string }): Promise => { 31 | const keywords = extractKeywords(query); 32 | try { 33 | const resp = await fetch( 34 | `https://scholar-ai.net/api/abstracts?keywords=${encodeURIComponent( 35 | keywords, 36 | )}&query=${encodeURIComponent(query)}`, 37 | ).then((res) => res.json()); 38 | 39 | if (resp && resp.paper_data) { 40 | const abstracts = resp.paper_data; 41 | 42 | const response = abstracts.map((abstract: any) => ({ 43 | title: abstract.title, 44 | abstract: abstract.abstract, 45 | doi: abstract.doi, 46 | pdf_url: abstract.pdf_url, 47 | publicationDate: abstract.publicationDate, 48 | cited_by_count: abstract.cited_by_count, 49 | creators: abstract.creators.join(', '), 50 | })); 51 | 52 | // You can return the processed response to the user 53 | return response; 54 | } else { 55 | return ''; 56 | } 57 | } catch (err) { 58 | console.error('Error:', err); 59 | return null; 60 | } 61 | }; 62 | 63 | export default { 64 | id: 'scholar-ai', 65 | name: 'ScholarAI', 66 | description: 'Get relevant paper abstracts by keywords search', 67 | parameters: { 68 | query: { 69 | type: 'string', 70 | description: 'The user query', 71 | required: true, 72 | }, 73 | }, 74 | run: runPlugin, 75 | }; -------------------------------------------------------------------------------- /chat-ui/pages/api/plugins/what-to-watch.ts: -------------------------------------------------------------------------------- 1 | export const runPlugin = async ({ 2 | show_name, 3 | }: { 4 | show_name: string; 5 | }): Promise => { 6 | try { 7 | const response_data: any = await fetch( 8 | `https://whattowatch.dev/shows/details/${encodeURIComponent(show_name)}`, 9 | ).then((res) => res.json()); 10 | 11 | if (response_data?.result) { 12 | const { 13 | name, 14 | genres, 15 | overview, 16 | first_air_date, 17 | last_air_date, 18 | number_of_seasons, 19 | number_of_episodes, 20 | vote_average, 21 | production_companies, 22 | production_countries, 23 | languages, 24 | homepage, 25 | } = response_data.result; 26 | 27 | const data = ` 28 | Name: ${name} 29 | Genres: ${genres 30 | .map((genre: { name: string }) => genre.name) 31 | .join(', ')} 32 | Overview: ${overview} 33 | First Air Date: ${first_air_date} 34 | Last Air Date: ${last_air_date} 35 | Number of Seasons: ${number_of_seasons} 36 | Number of Episodes: ${number_of_episodes} 37 | Average Vote: ${vote_average} 38 | Production Companies: ${production_companies 39 | .map((company: { name: string }) => company.name) 40 | .join(', ')} 41 | Production Countries: ${production_countries 42 | .map((country: { name: string }) => country.name) 43 | .join(', ')} 44 | Languages: ${languages.join(', ')} 45 | Homepage: ${homepage} 46 | `; 47 | return data; 48 | } else { 49 | return 'TV show details not found.'; 50 | } 51 | } catch (err) { 52 | console.error(err); 53 | return 'An error occurred while fetching TV show details.'; 54 | } 55 | }; 56 | 57 | export default { 58 | id: 'what-to-watch', 59 | name: 'What To Watch', 60 | description: 'Get details of a TV show by name.', 61 | parameters: { 62 | show_name: { 63 | type: 'string', 64 | description: 'show_name', 65 | }, 66 | }, 67 | run: runPlugin, 68 | }; -------------------------------------------------------------------------------- /chat-ui/pages/index.tsx: -------------------------------------------------------------------------------- 1 | export { default, getServerSideProps } from './api/home'; 2 | -------------------------------------------------------------------------------- /chat-ui/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | }; 7 | -------------------------------------------------------------------------------- /chat-ui/prettier.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | trailingComma: 'all', 3 | singleQuote: true, 4 | plugins: [ 5 | 'prettier-plugin-tailwindcss', 6 | '@trivago/prettier-plugin-sort-imports', 7 | ], 8 | importOrder: [ 9 | 'react', // React 10 | '^react-.*$', // React-related imports 11 | '^next', // Next-related imports 12 | '^next-.*$', // Next-related imports 13 | '^next/.*$', // Next-related imports 14 | '^.*/hooks/.*$', // Hooks 15 | '^.*/services/.*$', // Services 16 | '^.*/utils/.*$', // Utils 17 | '^.*/types/.*$', // Types 18 | '^.*/pages/.*$', // Components 19 | '^.*/components/.*$', // Components 20 | '^[./]', // Other imports 21 | '.*', // Any uncaught imports 22 | ], 23 | importOrderSeparation: true, 24 | importOrderSortSpecifiers: true, 25 | }; 26 | -------------------------------------------------------------------------------- /chat-ui/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabhed/validator-endpoint/4572ba711392b82320f4e7f76ee09aa50803908f/chat-ui/public/favicon.ico -------------------------------------------------------------------------------- /chat-ui/public/locales/ar/chat.json: -------------------------------------------------------------------------------- 1 | { 2 | "OpenAI API Key Required": " (أوبن أيه أي) OpenAI API Key (مطلوب (مفتاح واجهة برمجة تطبيقات ", 3 | "Please set your OpenAI API key in the bottom left of the sidebar.": "يرجى تعيين مفتاح واجهة برمجة تطبيقات أوبن أيه أي الخاص بك في الجزء السفلي الأيسر من الشريط الجانبي", 4 | "Stop Generating": "إيقاف التوليد", 5 | "Prompt limit is {{maxLength}} characters": "حرفًا {{maxLength}} حد المطالبة هو", 6 | "System Prompt": "مطالبة النظام", 7 | "You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.": "أنت شات جبت نموذج لغة كبير تم تدريبه بواسطة أوبن أيه أي. اتبع تعليمات المستخدم بعناية. الرد باستخدام الماركداون", 8 | "Enter a prompt": "أدخل المطالبة", 9 | "Regenerate response": "إعادة توليد الرد", 10 | "Sorry, there was an error.": "عذرًا، حدث خطأ", 11 | "Model": "النموذج", 12 | "Conversation": "المحادثة", 13 | "OR": "أو", 14 | "Loading...": "...جاري التحميل", 15 | "Type a message...": "...اكتب رسالة", 16 | "Error fetching models.": "خطأ في جلب النماذج", 17 | "AI": "الذكاء الاصطناعي", 18 | "You": "أنت", 19 | "Cancel": "Cancel", 20 | "Save & Submit": "Save & Submit", 21 | "Make sure your OpenAI API key is set in the bottom left of the sidebar.": "تأكد من تعيين مفتاح واجهة برمجة تطبيقات الخاص بك في الجزء السفلي الأيسر من الشريط", 22 | "If you completed this step, OpenAI may be experiencing issues.": "من مشاكل OpenAI إذا اكتملت هذه الخطوة، فقد يعاني", 23 | 24 | "click if using a .env.local file": ".env.local انقر إذا كنت تستخدم ملف", 25 | 26 | "Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.": "حرفًا {{maxLength}} حد الرسالة هو {{valueLength}} لقد أدخلت ", 27 | 28 | "Please enter a message": "يرجى إدخال رسالة", 29 | "Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.": "Chatbot UI هي مجموعة متقدمة للدردشة تستخدم", 30 | "Are you sure you want to clear all messages?": "هل أنت متأكد أنك تريد مسح كافة الرسائل؟", 31 | "Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.": "القيم الأعلى مثل 0.8 ستجعل الإخراج أكثر عشوائية، في حين أن القيم الأقل مثل 0.2 ستجعله أكثر تركيزًا وتحديدًا." 32 | } 33 | -------------------------------------------------------------------------------- /chat-ui/public/locales/ar/common.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /chat-ui/public/locales/ar/markdown.json: -------------------------------------------------------------------------------- 1 | { 2 | "Copy code": "نسخ الكود", 3 | "Copied!": "تم النسخ!", 4 | "Enter file name": "أدخل اسم الملف" 5 | } 6 | -------------------------------------------------------------------------------- /chat-ui/public/locales/ar/promptbar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New prompt": "مطلب جديد", 3 | "New folder": "مجلد جديد", 4 | "No prompts.": "لا يوجد مطالبات.", 5 | "Search prompts...": "...البحث عن مطالبات", 6 | "Name": "الاسم", 7 | "Description": "الوصف", 8 | "A description for your prompt.": "وصف لمطلبك", 9 | "Prompt": "مطلب", 10 | "Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}": "محتوى المطلب. استخدم {{}} للإشارة إلى متغير. مثال: {{الاسم}} هي {{صفة}} {{اسم}}", 11 | "Save": "حفظ" 12 | } 13 | -------------------------------------------------------------------------------- /chat-ui/public/locales/ar/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Dark mode": "الوضع الداكن", 3 | "Light mode": "الوضع الفاتح" 4 | } 5 | -------------------------------------------------------------------------------- /chat-ui/public/locales/ar/sidebar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New folder": "مجلد جديد", 3 | "New chat": "محادثة جديدة", 4 | "No conversations.": "لا يوجد محادثات", 5 | "Search conversations...": "...البحث عن المحادثات", 6 | "OpenAI API Key": " (أوبن أيه أي) OpenAI API Key (مفتاح واجهة برمجة تطبيقات)", 7 | "Import data": "استيراد المحادثات", 8 | "Are you sure?": "هل أنت متأكد؟", 9 | "Clear conversations": "مسح المحادثات", 10 | "Export data": "تصدير المحادثات", 11 | "Dark mode": "الوضع الداكن", 12 | "Light mode": "الوضع الفاتح" 13 | } 14 | -------------------------------------------------------------------------------- /chat-ui/public/locales/bn/common.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /chat-ui/public/locales/bn/markdown.json: -------------------------------------------------------------------------------- 1 | { 2 | "Copy code": "কোড কপি করুন", 3 | "Copied!": "কপি করা হয়েছে!", 4 | "Enter file name": "ফাইল নাম লিখুন" 5 | } 6 | -------------------------------------------------------------------------------- /chat-ui/public/locales/bn/promptbar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New prompt": "নতুন prompt", 3 | "New folder": "নতুন ফোল্ডার", 4 | "No prompts.": "কোনো prompts নেই।", 5 | "Search prompts...": "prompts অনুসন্ধান হচ্ছে...", 6 | "Name": "নাম", 7 | "Description": "বর্ণনা", 8 | "A description for your prompt.": "আপনার Prompt জন্য একটি বিবরণ লিখুন.", 9 | "Prompt": "Prompt", 10 | "Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}": "Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}", 11 | "Save": "সংরক্ষণ করুন" 12 | } 13 | -------------------------------------------------------------------------------- /chat-ui/public/locales/bn/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Dark mode": "ডার্ক মোড", 3 | "Light mode": "লাইট মোড" 4 | } 5 | -------------------------------------------------------------------------------- /chat-ui/public/locales/bn/sidebar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New folder": "নতুন ফোল্ডার", 3 | "New chat": "নতুন আড্ডা", 4 | "No conversations.": "কোনো আলাপচারিতা নেই।", 5 | "Search conversations...": "আলাপচারিতা খুঁজুন...", 6 | "OpenAI API Key": "OpenAI API Key", 7 | "Import data": "আলাপচারিতা ইমপোর্ট", 8 | "Are you sure?": "আপনি কি নিশ্চিত?", 9 | "Clear conversations": "কথোপকথন পরিষ্কার করুন", 10 | "Export data": "আলাপচারিতা এক্সপোর্ট" 11 | } 12 | -------------------------------------------------------------------------------- /chat-ui/public/locales/ca/common.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /chat-ui/public/locales/ca/markdown.json: -------------------------------------------------------------------------------- 1 | { 2 | "Copy code": "Copiar codi", 3 | "Copied!": "Copiat!", 4 | "Enter file name": "Introdueix el nom de l'arxiu" 5 | } 6 | -------------------------------------------------------------------------------- /chat-ui/public/locales/ca/promptbar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New prompt": "Nou prompt", 3 | "New folder": "Nova carpeta", 4 | "No prompts.": "No hi ha prompts.", 5 | "Search prompts...": "Cerca prompts...", 6 | "Name": "Nom", 7 | "Description": "Descripció", 8 | "A description for your prompt.": "Descripció del teu prompt.", 9 | "Prompt": "Prompt", 10 | "Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}": "Contingut del missatge. Utilitza {{}} per indicar una variable. Ex: {{nom}} és un {{adjectiu}} {{substantiu}}", 11 | "Save": "Guardar" 12 | } 13 | -------------------------------------------------------------------------------- /chat-ui/public/locales/ca/sidebar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New folder": "Nova carpeta", 3 | "New chat": "Nova conversa", 4 | "No conversations.": "No hi ha converses.", 5 | "Search conversations...": "Cerca converses...", 6 | "OpenAI API Key": "Clau d'API d'OpenAI", 7 | "Import data": "Importar converses", 8 | "Are you sure?": "Estàs segur?", 9 | "Clear conversations": "Esborrar converses", 10 | "Export data": "Exportar converses", 11 | "Dark mode": "Mode fosc", 12 | "Light mode": "Mode clar" 13 | } 14 | -------------------------------------------------------------------------------- /chat-ui/public/locales/de/common.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /chat-ui/public/locales/de/markdown.json: -------------------------------------------------------------------------------- 1 | { 2 | "Copy code": "Code kopieren", 3 | "Copied!": "Kopiert!", 4 | "Enter file name": "Dateinamen eingeben" 5 | } 6 | -------------------------------------------------------------------------------- /chat-ui/public/locales/de/promptbar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New prompt": "New prompt", 3 | "New folder": "New folder", 4 | "No prompts.": "No prompts.", 5 | "Search prompts...": "Search prompts...", 6 | "Name": "Name", 7 | "Description": "Description", 8 | "A description for your prompt.": "A description for your prompt.", 9 | "Prompt": "Prompt", 10 | "Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}": "Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}", 11 | "Save": "Save" 12 | } 13 | -------------------------------------------------------------------------------- /chat-ui/public/locales/de/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Dark mode": "Dark Mode", 3 | "Light mode": "Light Mode" 4 | } 5 | -------------------------------------------------------------------------------- /chat-ui/public/locales/de/sidebar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New folder": "Neuer Ordner", 3 | "New chat": "Neue Konversation", 4 | "No conversations.": "Keine Konversationen.", 5 | "Search conversations...": "Konversationen suchen...", 6 | "OpenAI API Key": "OpenAI API-Schlüssel", 7 | "Import data": "Konversationen importieren", 8 | "Are you sure?": "Bist du sicher?", 9 | "Clear conversations": "Konversationen löschen", 10 | "Export data": "Konversationen exportieren" 11 | } 12 | -------------------------------------------------------------------------------- /chat-ui/public/locales/en/common.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /chat-ui/public/locales/es/common.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /chat-ui/public/locales/es/markdown.json: -------------------------------------------------------------------------------- 1 | { 2 | "Copy code": "Copiar código", 3 | "Copied!": "¡Copiado!", 4 | "Enter file name": "Ingrese el nombre del archivo" 5 | } 6 | -------------------------------------------------------------------------------- /chat-ui/public/locales/es/promptbar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New prompt": "Nuevo prompt", 3 | "New folder": "Nueva carpeta", 4 | "No prompts.": "No hay prompts.", 5 | "Search prompts...": "Buscar prompts...", 6 | "Name": "Nombre", 7 | "Description": "Descripción", 8 | "A description for your prompt.": "Descripción de su prompt.", 9 | "Prompt": "Prompt", 10 | "Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}": "Contenido del prompt. Utilice {{}} para indicar una variable. Ej: {{nombre}} es un {{adjetivo}} {{nombre}}", 11 | "Save": "Guardar" 12 | } 13 | -------------------------------------------------------------------------------- /chat-ui/public/locales/es/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Dark mode": "Modo oscuro", 3 | "Light mode": "Modo claro" 4 | } 5 | -------------------------------------------------------------------------------- /chat-ui/public/locales/es/sidebar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New folder": "Nueva carpeta", 3 | "New chat": "Nueva conversación", 4 | "No conversations.": "No hay conversaciones.", 5 | "Search conversations...": "Buscar conversaciones...", 6 | "OpenAI API Key": "Llave de API de OpenAI", 7 | "Import data": "Importar conversaciones", 8 | "Are you sure?": "¿Estás seguro?", 9 | "Clear conversations": "Borrar conversaciones", 10 | "Export data": "Exportar conversaciones" 11 | } 12 | -------------------------------------------------------------------------------- /chat-ui/public/locales/fi/common.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /chat-ui/public/locales/fi/markdown.json: -------------------------------------------------------------------------------- 1 | { 2 | "Copy code": "Kopioi koodi", 3 | "Copied!": "Kopioitu!", 4 | "Enter file name": "Syötä tiedostonimi" 5 | } 6 | -------------------------------------------------------------------------------- /chat-ui/public/locales/fi/promptbar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New prompt": "Uusi prompt", 3 | "New folder": "Uusi kansio", 4 | "No prompts.": "Ei prompteja.", 5 | "Search prompts...": "Hae prompteista...", 6 | "Name": "Nimi", 7 | "Description": "Kuvaus", 8 | "A description for your prompt.": "Promptisi kuvaus.", 9 | "Prompt": "Prompt", 10 | "Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}": "Promptin sisältö. Käytä {{}} muuttujien merkitsemiseen. Esim: {{nimi}} on {{adjektiivi}} {{substantiivi}}", 11 | "Save": "Tallenna" 12 | } 13 | -------------------------------------------------------------------------------- /chat-ui/public/locales/fi/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Settings": "Asetukset", 3 | "Theme": "Teema", 4 | "Dark mode": "Tumma teema", 5 | "Light mode": "Vaalea teema", 6 | "Save": "Tallenna" 7 | } 8 | -------------------------------------------------------------------------------- /chat-ui/public/locales/fi/sidebar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New folder": "Uusi kansio", 3 | "New chat": "Uusi keskustelu", 4 | "No conversations.": "Ei keskusteluja.", 5 | "Search conversations...": "Hae keskusteluista...", 6 | "OpenAI API Key": "OpenAI API-avain", 7 | "Import data": "Tuo keskusteluita", 8 | "Are you sure?": "Oletko varma?", 9 | "Clear conversations": "Tyhjennä keskustelut", 10 | "Export data": "Vie keskustelut", 11 | "Settings": "Asetukset", 12 | "Plugin Keys": "Plugin-avaimet" 13 | } 14 | -------------------------------------------------------------------------------- /chat-ui/public/locales/fr/chat.json: -------------------------------------------------------------------------------- 1 | { 2 | "OpenAI API Key Required": "Clé API OpenAI requise", 3 | "Please set your OpenAI API key in the bottom left of the sidebar.": "Veuillez saisir votre clé API OpenAI dans le coin inférieur gauche de la barre latérale.", 4 | "Stop Generating": "Interrompre la génération", 5 | "Prompt limit is {{maxLength}} characters": "La limite du prompt est de {{maxLength}} caractères", 6 | "System Prompt": "Prompt du système", 7 | "You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.": "Vous êtes ChatGPT, un grand modèle linguistique entraîné par OpenAI. Suivez attentivement les instructions de l'utilisateur. Répondez en utilisant Markdown.", 8 | "Enter a prompt": "Entrez un prompt", 9 | "Regenerate response": "Régénérer la réponse", 10 | "Sorry, there was an error.": "Désolé, une erreur est survenue.", 11 | "Model": "Modèle", 12 | "Conversation": "Conversation", 13 | "OR": "OU", 14 | "Loading...": "Chargement...", 15 | "Type a message...": "Tapez un message...", 16 | "Error fetching models.": "Erreur lors de la récupération des modèles.", 17 | "AI": "IA", 18 | "You": "Vous", 19 | "Cancel": "Cancel", 20 | "Save & Submit": "Save & Submit", 21 | "Make sure your OpenAI API key is set in the bottom left of the sidebar.": "Assurez-vous que votre clé API OpenAI est définie dans le coin inférieur gauche de la barre latérale.", 22 | "If you completed this step, OpenAI may be experiencing issues.": "Si vous avez effectué cette étape, OpenAI peut rencontrer des problèmes.", 23 | "click if using a .env.local file": "click if using a .env.local file", 24 | "Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.": "La limite de message est de {{maxLength}} caractères. Vous avez saisi {{valueLength}} caractères.", 25 | "Please enter a message": "Veuillez entrer un message", 26 | "Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.": "Chatbot UI est un kit de chatbot avancé pour les modèles de chat d'OpenAI visant à imiter l'interface et les fonctionnalités de ChatGPT.", 27 | "Are you sure you want to clear all messages?": "Êtes-vous sûr de vouloir effacer tous les messages ?" 28 | } 29 | -------------------------------------------------------------------------------- /chat-ui/public/locales/fr/common.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /chat-ui/public/locales/fr/markdown.json: -------------------------------------------------------------------------------- 1 | { 2 | "Copy code": "Copier le code", 3 | "Copied!": "Copié !", 4 | "Enter file name": "Entrez le nom du fichier" 5 | } 6 | -------------------------------------------------------------------------------- /chat-ui/public/locales/fr/promptbar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New prompt": "New prompt", 3 | "New folder": "New folder", 4 | "No prompts.": "No prompts.", 5 | "Search prompts...": "Search prompts...", 6 | "Name": "Name", 7 | "Description": "Description", 8 | "A description for your prompt.": "A description for your prompt.", 9 | "Prompt": "Prompt", 10 | "Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}": "Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}", 11 | "Save": "Save" 12 | } 13 | -------------------------------------------------------------------------------- /chat-ui/public/locales/fr/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Dark mode": "Mode sombre", 3 | "Light mode": "Mode clair" 4 | } 5 | -------------------------------------------------------------------------------- /chat-ui/public/locales/fr/sidebar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New folder": "Nouveau dossier", 3 | "New chat": "Nouvelle discussion", 4 | "No conversations.": "Aucune conversation.", 5 | "Search conversations...": "Rechercher des conversations...", 6 | "OpenAI API Key": "Clé API OpenAI", 7 | "Import data": "Importer des conversations", 8 | "Are you sure?": "Êtes-vous sûr ?", 9 | "Clear conversations": "Effacer les conversations", 10 | "Export data": "Exporter les conversations" 11 | } 12 | -------------------------------------------------------------------------------- /chat-ui/public/locales/he/chat.json: -------------------------------------------------------------------------------- 1 | { 2 | "OpenAI API Key Required": "מפתח openAI API", 3 | "Please set your OpenAI API key in the bottom left of the sidebar.": "עליך להזין את המפתח האישי שלך בצידו השמאלי התחתון של תפריט הניווט.", 4 | "Stop Generating": "עצור תהליך הפקת התשובה", 5 | "Prompt limit is {{maxLength}} characters": "אורך התשובה מוגבל ל {{maxLength}} תווים", 6 | "System Prompt": "הגדרת בסיס לכל תשובה של המערכת", 7 | "You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.": "You are Hebrew speaking ChatGPT, a large language model trained by OpenAI which responds in Hebrew to any question or User comment. Follow the user's instructions carefully. Respond in Hebrew using markdown.", 8 | "Enter a prompt": "הקלד הודעה", 9 | "Regenerate response": "הפק תשובה מחדש", 10 | "Sorry, there was an error.": "התנצלותנו הכנה, המערכת מדווחת על תקלה", 11 | "Model": "מודל", 12 | "Conversation": "שיחה", 13 | "OR": "או", 14 | "Loading...": "טוען...", 15 | "Type a message...": "הקלד הודעתך...", 16 | "Error fetching models.": "תקלה באיחזור רשימת המודלים", 17 | "AI": "המערכת", 18 | "You": "אתה", 19 | "Cancel": "Cancel", 20 | "Save & Submit": "Save & Submit", 21 | "Make sure your OpenAI API key is set in the bottom left of the sidebar.": "עליך לוודא שמפתח האישי שלך מוזן בתפריט מצד שמאל", 22 | "If you completed this step, OpenAI may be experiencing issues.": "אם טרם השלמת חלק זה יש סבירות גבוהה להתרחשות תקלה", 23 | "click if using a .env.local file": "click if using a .env.local file", 24 | "Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.": "מגבלת תווים היא {{maxLength}}. אתה הקלדת עד עכשיו {{valueLength}} תווים.", 25 | "Please enter a message": "הקלד את הודעתך", 26 | "Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.": "מערכת הצאטבוט היא ערכה מתקדמת לניהול שיחה המכוונת לחקות את המראה והפונקציונאלית של ChatGPT", 27 | "Are you sure you want to clear all messages?": "האם אתה בטוח שברצונך למחוק את כל ההודעות?" 28 | } 29 | -------------------------------------------------------------------------------- /chat-ui/public/locales/he/common.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /chat-ui/public/locales/he/markdown.json: -------------------------------------------------------------------------------- 1 | { 2 | "Copy code": "העתק קוד", 3 | "Copied!": "נשמר בזכרון", 4 | "Enter file name": "הקלד שם לקובץ" 5 | } 6 | -------------------------------------------------------------------------------- /chat-ui/public/locales/he/promptbar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New prompt": "פקודת מכונה חדשה", 3 | "New folder": "תיקיה חדשה", 4 | "No prompts.": "לא נמצאו פקודות מכונות", 5 | "Search prompts...": "חיפוש פקודות...", 6 | "Name": "שם", 7 | "Description": "תיאור", 8 | "A description for your prompt.": "תיאור שורת הפקודה למכונה", 9 | "Prompt": "פקודה", 10 | "Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}": "תיאור הפקודה. השתמש {{}} להגדרת משתנים. לדוגמא {{שם משתנה}} הוא {{תואר}} {{שם עצם}}", 11 | "Save": "Save" 12 | } 13 | -------------------------------------------------------------------------------- /chat-ui/public/locales/he/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Dark mode": "מצב כהה", 3 | "Light mode": "מצב בהיר" 4 | } 5 | -------------------------------------------------------------------------------- /chat-ui/public/locales/he/sidebar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New folder": "תיקיה חדשה", 3 | "New chat": "שיחה חדשה", 4 | "No conversations.": "אין שיחות חדשות", 5 | "Search conversations...": "חיפוש שיחות...", 6 | "OpenAI API Key": "מפתח אישי ל openAI", 7 | "Import data": "ייבוא שיחות", 8 | "Are you sure?": "אתה בטוח?", 9 | "Clear conversations": "ניקוי שיחות", 10 | "Export data": "ייצוא שיחות" 11 | } 12 | -------------------------------------------------------------------------------- /chat-ui/public/locales/id/chat.json: -------------------------------------------------------------------------------- 1 | { 2 | "OpenAI API Key Required": "Memerlukan Kunci API OpenAI", 3 | "Please set your OpenAI API key in the bottom left of the sidebar.": "Silakan atur kunci API OpenAI Anda di bagian kiri bawah bilah sisi.", 4 | "Stop Generating": "Berhenti Menghasilkan", 5 | "Prompt limit is {{maxLength}} characters": "Batas karakter untuk prompt adalah {{maxLength}} karakter", 6 | "System Prompt": "Prompt Sistem", 7 | "You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.": "Anda adalah ChatGPT, model bahasa besar yang dilatih oleh OpenAI. Ikuti instruksi pengguna dengan hati-hati. Balas menggunakan markdown.", 8 | "Enter a prompt": "Masukkan sebuah prompt", 9 | "Regenerate response": "Hasilkan kembali respons", 10 | "Sorry, there was an error.": "Maaf, terjadi kesalahan.", 11 | "Model": "Model", 12 | "Conversation": "Percakapan", 13 | "OR": "ATAU", 14 | "Loading...": "Memuat...", 15 | "Type a message...": "Ketik sebuah pesan...", 16 | "Error fetching models.": "Kesalahan dalam mengambil model.", 17 | "AI": "AI", 18 | "You": "Anda", 19 | "Cancel": "Cancel", 20 | "Save & Submit": "Save & Submit", 21 | "Make sure your OpenAI API key is set in the bottom left of the sidebar.": "Pastikan kunci API OpenAI Anda diatur di bagian kiri bawah bilah sisi.", 22 | "If you completed this step, OpenAI may be experiencing issues.": "Jika Anda telah menyelesaikan langkah ini, OpenAI mungkin mengalami masalah.", 23 | "click if using a .env.local file": "klik jika menggunakan file .env.local", 24 | "Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.": "Batas karakter untuk pesan adalah {{maxLength}} karakter. Anda telah memasukkan {{valueLength}} karakter.", 25 | "Please enter a message": "Silakan masukkan sebuah pesan", 26 | "Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.": "Chatbot UI adalah kit chatbot canggih untuk model obrolan OpenAI yang bertujuan meniru antarmuka dan fungsionalitas ChatGPT.", 27 | "Are you sure you want to clear all messages?": "Apakah Anda yakin ingin menghapus semua pesan?" 28 | } 29 | -------------------------------------------------------------------------------- /chat-ui/public/locales/id/common.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /chat-ui/public/locales/id/markdown.json: -------------------------------------------------------------------------------- 1 | { 2 | "Copy code": "Salin kode", 3 | "Copied!": "Kode disalin!", 4 | "Enter file name": "Masukkan nama file" 5 | } 6 | -------------------------------------------------------------------------------- /chat-ui/public/locales/id/promptbar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New prompt": "New prompt", 3 | "New folder": "New folder", 4 | "No prompts.": "No prompts.", 5 | "Search prompts...": "Search prompts...", 6 | "Name": "Name", 7 | "Description": "Description", 8 | "A description for your prompt.": "A description for your prompt.", 9 | "Prompt": "Prompt", 10 | "Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}": "Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}", 11 | "Save": "Save" 12 | } 13 | -------------------------------------------------------------------------------- /chat-ui/public/locales/id/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Dark mode": "Mode gelap", 3 | "Light mode": "Mode terang" 4 | } 5 | -------------------------------------------------------------------------------- /chat-ui/public/locales/id/sidebar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New folder": "Folder baru", 3 | "New chat": "Percakapan baru", 4 | "No conversations.": "Tidak ada percakapan.", 5 | "Search conversations...": "Cari percakapan...", 6 | "OpenAI API Key": "Kunci API OpenAI", 7 | "Import data": "Impor percakapan", 8 | "Are you sure?": "Apakah Anda yakin?", 9 | "Clear conversations": "Hapus percakapan", 10 | "Export data": "Ekspor percakapan" 11 | } 12 | -------------------------------------------------------------------------------- /chat-ui/public/locales/it/common.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /chat-ui/public/locales/it/markdown.json: -------------------------------------------------------------------------------- 1 | { 2 | "Copy code": "Copia codice", 3 | "Copied!": "Copiato!", 4 | "Enter file name": "Inserisci il nome del file" 5 | } 6 | -------------------------------------------------------------------------------- /chat-ui/public/locales/it/promptbar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New prompt": "Nuovo prompt", 3 | "New folder": "Nuova cartella", 4 | "No prompts.": "Nessun prompt.", 5 | "Search prompts...": "Cerca prompts...", 6 | "Name": "Nome", 7 | "Description": "Descrizione", 8 | "A description for your prompt.": "Descrizione del tuo prompt.", 9 | "Prompt": "Prompt", 10 | "Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}": "Contenuto del prompt. Utilizza {{}} per indicare una variabile. Per esempio: {{nome}} è un {{aggettivo}} {{sostantivo}}", 11 | "Save": "Salva" 12 | } 13 | -------------------------------------------------------------------------------- /chat-ui/public/locales/it/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Dark mode": "Modalità scura", 3 | "Light mode": "Modalità chiara" 4 | } 5 | -------------------------------------------------------------------------------- /chat-ui/public/locales/it/sidebar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New folder": "Nuova cartella", 3 | "New chat": "Nuova conversazione", 4 | "No conversations.": "Nessuna conversazione.", 5 | "Search conversations...": "Cerca conversazioni...", 6 | "OpenAI API Key": "Chiave API OpenAI", 7 | "Import data": "Importa dati", 8 | "Are you sure?": "Sei sicuro?", 9 | "Clear conversations": "Elimina conversazioni", 10 | "Export data": "Esporta dati" 11 | } 12 | -------------------------------------------------------------------------------- /chat-ui/public/locales/ja/chat.json: -------------------------------------------------------------------------------- 1 | { 2 | "OpenAI API Key Required": "OpenAIのAPIキーが必要です", 3 | "Please set your OpenAI API key in the bottom left of the sidebar.": "左下のサイドバーでOpenAIのAPIキーを設定してください", 4 | "Stop Generating": "回答をストップ", 5 | "Prompt limit is {{maxLength}} characters": "プロンプトの文字数は{{maxLength}}文字までです", 6 | "System Prompt": "システムのプロンプト", 7 | "You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.": "あなたはOpenAIによってトレーニングされた大規模言語モデルのChatGPTです。ユーザーの指示には注意深く従ってください。マークダウンを使用して応答してください。", 8 | "Enter a prompt": "プロンプトを入力してください", 9 | "Regenerate response": "もう一度回答する", 10 | "Sorry, there was an error.": "すみません、エラーが発生しました。", 11 | "Model": "モデル", 12 | "Conversation": "会話", 13 | "OR": "または", 14 | "Loading...": "読み込み中...", 15 | "Type a message...": "メッセージを入力...", 16 | "Error fetching models.": "モデルの取得中にエラーが発生しました。", 17 | "AI": "AI", 18 | "You": "あなた", 19 | "Cancel": "キャンセル", 20 | "Save & Submit": "Save & Submit", 21 | "Make sure your OpenAI API key is set in the bottom left of the sidebar.": "OpenAIのAPIキーがサイドバーの左下に設定されていることを確認してください。", 22 | "If you completed this step, OpenAI may be experiencing issues.": "このステップを完了した場合、OpenAIに問題が発生している可能性があります。", 23 | "click if using a .env.local file": "もし.env.localファイルを使用している場合はこちらをクリックしてください", 24 | "Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.": "メッセージの文字数は{{maxLength}}文字までです。あなたは{{valueLength}}文字を入力しました。", 25 | "Please enter a message": "メッセージを入力してください", 26 | "Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.": "Chatbot UIは、ChatGPTと同様のインターフェイスと機能を実現するための、チャットボットキットです。", 27 | "Are you sure you want to clear all messages?": "すべてのメッセージを削除してもよろしいですか?", 28 | "Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.": "0.8のような高い値は出力をよりランダムにし、0.2のような低い値はより焦点を絞り、決定論的にします。" 29 | } 30 | -------------------------------------------------------------------------------- /chat-ui/public/locales/ja/common.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /chat-ui/public/locales/ja/markdown.json: -------------------------------------------------------------------------------- 1 | { 2 | "Copy code": "コードをコピー", 3 | "Copied!": "コピーしました!", 4 | "Enter file name": "ファイル名を入力" 5 | } 6 | -------------------------------------------------------------------------------- /chat-ui/public/locales/ja/promptbar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New prompt": "新しいプロンプト", 3 | "New folder": "新しいフォルダ", 4 | "No prompts.": "プロンプトはありません", 5 | "Search prompts...": "プロンプトの検索...", 6 | "Name": "名前", 7 | "Description": "説明", 8 | "A description for your prompt.": "プロンプトの説明", 9 | "Prompt": "プロンプト", 10 | "Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}": "プロンプトの内容。変数を表すには {{}} を使ってください。 例: {{name}} is a {{adjective}} {{noun}}", 11 | "Save": "保存" 12 | } 13 | -------------------------------------------------------------------------------- /chat-ui/public/locales/ja/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Settings": "設定", 3 | "Theme": "テーマ", 4 | "Save": "保存", 5 | "Dark mode": "ダークモード", 6 | "Light mode": "ライトモード" 7 | } 8 | -------------------------------------------------------------------------------- /chat-ui/public/locales/ja/sidebar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New folder": "新規フォルダ", 3 | "New chat": "新規チャット", 4 | "No conversations.": "会話履歴はありません。", 5 | "Search conversations...": "会話を検索...", 6 | "OpenAI API Key": "OpenAI APIキー", 7 | "Import data": "会話履歴をインポート", 8 | "Are you sure?": "よろしいですか?", 9 | "Clear conversations": " 会話をクリア", 10 | "Export data": "会話履歴をエクスポート", 11 | "Dark mode": "ダークモード", 12 | "Light mode": "ライトモード", 13 | "Settings": "設定" 14 | } 15 | -------------------------------------------------------------------------------- /chat-ui/public/locales/ko/chat.json: -------------------------------------------------------------------------------- 1 | { 2 | "OpenAI API Key Required": "OpenAI API 키가 필요합니다", 3 | "Please set your OpenAI API key in the bottom left of the sidebar.": "사이드바 왼쪽 하단에 OpenAI API 키를 설정하세요.", 4 | "Stop Generating": "생성 중지", 5 | "Prompt limit is {{maxLength}} characters": "프롬프트 제한은 {{maxLength}}자입니다", 6 | "System Prompt": "시스템 프롬트", 7 | "You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.": "당신은 OpenAI에서 훈련된 대규모 언어 모델 ChatGPT입니다. 사용자의 지시를 주의해서 따르세요. 마크다운을 사용하여 응답하세요.", 8 | "Enter a prompt": "프롬프트를 입력하세요", 9 | "Regenerate response": "응답 재생성", 10 | "Sorry, there was an error.": "죄송합니다, 오류가 발생했습니다.", 11 | "Model": "모델", 12 | "Conversation": "대화", 13 | "OR": "또는", 14 | "Loading...": "로드 중...", 15 | "Type a message...": "메시지를 입력하세요...", 16 | "Error fetching models.": "모델을 가져오는 중 오류가 발생했습니다.", 17 | "AI": "인공지능", 18 | "You": "당신", 19 | "Cancel": "Cancel", 20 | "Save & Submit": "Save & Submit", 21 | "Make sure your OpenAI API key is set in the bottom left of the sidebar.": "OpenAI API 키가 사이드바 왼쪽 하단에 설정되어 있는지 확인하세요.", 22 | "If you completed this step, OpenAI may be experiencing issues.": "이 단계를 완료한 경우 OpenAI에 문제가 있을 수도 있습니다.", 23 | "click if using a .env.local file": "click if using a .env.local file", 24 | "Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.": "메시지 제한은 {{maxLength}}자입니다. {{valueLength}}자를 입력했습니다.", 25 | "Please enter a message": "메시지를 입력하세요", 26 | "Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.": "Chatbot UI는 ChatGPT의 인터페이스와 기능을 모방하는 것을 목표로 둔 OpenAI의 채팅 모델들을 위한 고급 챗봇 키트입니다.", 27 | "Are you sure you want to clear all messages?": "모든 메시지를 지우시겠습니까?", 28 | "Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.": "0.8과 같은 높은 값은 출력을 더 무작위로 만들고, 0.2와 같은 낮은 값은 더 집중적이고 결정론적으로 만들어줍니다." 29 | } 30 | -------------------------------------------------------------------------------- /chat-ui/public/locales/ko/common.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /chat-ui/public/locales/ko/markdown.json: -------------------------------------------------------------------------------- 1 | { 2 | "Copy code": "코드 복사", 3 | "Copied!": "복사 완료!", 4 | "Enter file name": "파일 이름을 입력하세요" 5 | } 6 | -------------------------------------------------------------------------------- /chat-ui/public/locales/ko/promptbar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New prompt": "New prompt", 3 | "New folder": "New folder", 4 | "No prompts.": "No prompts.", 5 | "Search prompts...": "Search prompts...", 6 | "Name": "Name", 7 | "Description": "Description", 8 | "A description for your prompt.": "A description for your prompt.", 9 | "Prompt": "Prompt", 10 | "Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}": "Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}", 11 | "Save": "Save" 12 | } 13 | -------------------------------------------------------------------------------- /chat-ui/public/locales/ko/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Dark mode": "다크 모드", 3 | "Light mode": "라이트 모드" 4 | } 5 | -------------------------------------------------------------------------------- /chat-ui/public/locales/ko/sidebar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New folder": "새 폴더", 3 | "New chat": "새 채팅", 4 | "No conversations.": "대화가 없습니다.", 5 | "Search conversations...": "대화 검색...", 6 | "OpenAI API Key": "OpenAI API 키", 7 | "Import data": "대화 가져오기", 8 | "Are you sure?": "확실합니까?", 9 | "Clear conversations": "대화 지우기", 10 | "Export data": "대화 내보내기" 11 | } 12 | -------------------------------------------------------------------------------- /chat-ui/public/locales/pl/chat.json: -------------------------------------------------------------------------------- 1 | { 2 | "OpenAI API Key Required": "Klucz do OpenAI API jest wymagany", 3 | "Please set your OpenAI API key in the bottom left of the sidebar.": "Proszę wprowadzić swój klucz do OpenAI API na pasku bocznym w lewym dolnym rogu", 4 | "Stop Generating": "Zatrzymaj generowanie", 5 | "Prompt limit is {{maxLength}} characters": "Limit prompta wynosi {{maxLength}} znaków", 6 | "System Prompt": "Prompt systemowy", 7 | "You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.": "Jesteś ChatGPT, duży model językowy wytrenowany przez OpenAI. Postępuj zgodnie z instrukcjami użytkownika. Odpowiedz za pomocą formatu markdown.", 8 | "Enter a prompt": "Wprowadź prompt", 9 | "Regenerate response": "Wygeneruj odpowiedź", 10 | "Sorry, there was an error.": "Przepraszam, wystąpił błąd.", 11 | "Model": "Model", 12 | "Conversation": "Rozmowa", 13 | "OR": "LUB", 14 | "Loading...": "Ładowanie...", 15 | "Type a message...": "Napisz wiadomość...", 16 | "Error fetching models.": "Błąd podczas pobierania modelu", 17 | "AI": "SI", 18 | "You": "Ty", 19 | "Cancel": "Anuluj", 20 | "Save & Submit": "Zapisz i wyślij", 21 | "Make sure your OpenAI API key is set in the bottom left of the sidebar.": "Upewnij się, że wprowadziłeś swój klucz do OpenAI API na pasku bocznym w lewym dolnym rogu", 22 | "If you completed this step, OpenAI may be experiencing issues.": "Jeśli wykonałeś ten krok to oznacza, że mogą występować problemy po stronie OpenAI.", 23 | "click if using a .env.local file": "kliknij jeśli używasz pliku .env.local", 24 | "Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.": "Limit wiadomości wynosi {{maxLength}} znaków. Wprowadziłeś {{valueLength}} znaków.", 25 | "Please enter a message": "Proszę wpisać swoją wiadomość", 26 | "Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.": "Chatbot UI to zaawansowane narzędzie chatbotów dla modeli czatów od OpenAI, którego celem jest naśladowanie interfejsu i funkcjonalności ChatGPT.", 27 | "Are you sure you want to clear all messages?": "Czy na pewno chcesz usunąć wszystkie wiadomości?" 28 | } 29 | -------------------------------------------------------------------------------- /chat-ui/public/locales/pl/common.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /chat-ui/public/locales/pl/markdown.json: -------------------------------------------------------------------------------- 1 | { 2 | "Copy code": "Skopiuj kod", 3 | "Copied!": "Skopiowany", 4 | "Enter file name": "Wprowadź nazwę pliku" 5 | } 6 | -------------------------------------------------------------------------------- /chat-ui/public/locales/pl/promptbar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New prompt": "Nowy prompt", 3 | "New folder": "Nowy folder", 4 | "No prompts.": "Brak promptów.", 5 | "Search prompts...": "Szukaj promptów...", 6 | "Name": "Nazwa", 7 | "Description": "Opis", 8 | "A description for your prompt.": "Opis Twojego prompta.", 9 | "Prompt": "Prompt", 10 | "Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}": "Zawartość prompta. Użyj {{}} żeby oznaczyć zmienną. Np.: {{nazwa}} jest {{przymiotnik}} {{rzeczownik}}", 11 | "Save": "Zapisz" 12 | } 13 | -------------------------------------------------------------------------------- /chat-ui/public/locales/pl/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Dark mode": "Tryb ciemny", 3 | "Light mode": "Tryb jasny" 4 | } 5 | -------------------------------------------------------------------------------- /chat-ui/public/locales/pl/sidebar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New folder": "Nowy folder", 3 | "New chat": "Nowy chat", 4 | "No conversations.": "Brak rozmów.", 5 | "Search conversations...": "Szukaj rozmów...", 6 | "OpenAI API Key": "Klucz do OpenAI API", 7 | "Import data": "Import rozmów", 8 | "Are you sure?": "Czy jesteś pewien?", 9 | "Clear conversations": "Usuń rozmowy", 10 | "Export data": "Eksport rozmów" 11 | } 12 | -------------------------------------------------------------------------------- /chat-ui/public/locales/pt/common.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /chat-ui/public/locales/pt/markdown.json: -------------------------------------------------------------------------------- 1 | { 2 | "Copy code": "Copiar código", 3 | "Copied!": "Copiado!", 4 | "Enter file name": "Insira o nome do arquivo" 5 | } 6 | -------------------------------------------------------------------------------- /chat-ui/public/locales/pt/promptbar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New prompt": "New prompt", 3 | "New folder": "New folder", 4 | "No prompts.": "No prompts.", 5 | "Search prompts...": "Search prompts...", 6 | "Name": "Name", 7 | "Description": "Description", 8 | "A description for your prompt.": "A description for your prompt.", 9 | "Prompt": "Prompt", 10 | "Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}": "Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}", 11 | "Save": "Save" 12 | } 13 | -------------------------------------------------------------------------------- /chat-ui/public/locales/pt/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Dark mode": "Modo escuro", 3 | "Light mode": "Modo claro" 4 | } 5 | -------------------------------------------------------------------------------- /chat-ui/public/locales/pt/sidebar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New folder": "Nova pasta", 3 | "New chat": "Novo chat", 4 | "No conversations.": "Não há conversas.", 5 | "Search conversations...": "Buscar conversas...", 6 | "OpenAI API Key": "API Key da OpenAI", 7 | "Import data": "Importar conversas", 8 | "Are you sure?": "Tem certeza?", 9 | "Clear conversations": "Apagar conversas", 10 | "Export data": "Exportar conversas" 11 | } 12 | -------------------------------------------------------------------------------- /chat-ui/public/locales/ro/common.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /chat-ui/public/locales/ro/markdown.json: -------------------------------------------------------------------------------- 1 | { 2 | "Copy code": "Copiați codul", 3 | "Copied!": "Copiat!", 4 | "Enter file name": "Introduceți numele fișierului" 5 | } 6 | -------------------------------------------------------------------------------- /chat-ui/public/locales/ro/promptbar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New prompt": "Noua solicitare", 3 | "New folder": "Dosar nou", 4 | "No prompts.": "Fără solicitări.", 5 | "Search prompts...": "Cereri de căutare...", 6 | "Name": "Nume", 7 | "Description": "Descriere", 8 | "A description for your prompt.": "Descrierea solicitării prompt.", 9 | "Prompt": "Îndemnuri", 10 | "Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}": "Conținut prompt. Utilizați {{}} pentru a indica o variabilă. De exemplu: {{nume}} este un {{adjectiv}} {{substantiv}}", 11 | "Save": "Salvați" 12 | } 13 | -------------------------------------------------------------------------------- /chat-ui/public/locales/ro/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Dark mode": "Modul întunecat", 3 | "Light mode": "Modul de golire" 4 | } 5 | -------------------------------------------------------------------------------- /chat-ui/public/locales/ro/sidebar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New folder": "Folder nou", 3 | "New chat": "Conversație nouă", 4 | "No conversations.": "Nicio conversație.", 5 | "Search conversations...": "Căutați conversații...", 6 | "OpenAI API Key": "Cheia API OpenAI", 7 | "Import data": "Importați conversații", 8 | "Are you sure?": "Esti sigur?", 9 | "Clear conversations": "Ștergeți conversațiile", 10 | "Export data": "Exportați conversații" 11 | } 12 | -------------------------------------------------------------------------------- /chat-ui/public/locales/ru/common.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /chat-ui/public/locales/ru/markdown.json: -------------------------------------------------------------------------------- 1 | { 2 | "Copy code": "Скопировать", 3 | "Copied!": "Скопировано!", 4 | "Enter file name": "Введите имя файла для загрузки" 5 | } 6 | -------------------------------------------------------------------------------- /chat-ui/public/locales/ru/promptbar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New prompt": "New prompt", 3 | "New folder": "New folder", 4 | "No prompts.": "No prompts.", 5 | "Search prompts...": "Search prompts...", 6 | "Name": "Name", 7 | "Description": "Description", 8 | "A description for your prompt.": "A description for your prompt.", 9 | "Prompt": "Prompt", 10 | "Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}": "Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}", 11 | "Save": "Save" 12 | } 13 | -------------------------------------------------------------------------------- /chat-ui/public/locales/ru/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Dark mode": "Темный режим", 3 | "Light mode": "Светлый режим" 4 | } 5 | -------------------------------------------------------------------------------- /chat-ui/public/locales/ru/sidebar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New folder": "Новая папка", 3 | "New chat": "Новый чат", 4 | "No conversations.": "Нет чатов.", 5 | "Search conversations...": "Поиск чатов...", 6 | "OpenAI API Key": "API-ключ OpenAI", 7 | "Import data": "Импортировать чаты", 8 | "Are you sure?": "Вы уверены?", 9 | "Clear conversations": "Удалить чаты", 10 | "Export data": "Экспортировать чаты" 11 | } 12 | -------------------------------------------------------------------------------- /chat-ui/public/locales/si/common.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /chat-ui/public/locales/si/markdown.json: -------------------------------------------------------------------------------- 1 | { 2 | "Copy code": "කේතය පිටපත් කරන්න", 3 | "Copied!": "පිටපත් කළා!", 4 | "Enter file name": "ගොනු නාමය ඇතුළත් කරන්න" 5 | } 6 | -------------------------------------------------------------------------------- /chat-ui/public/locales/si/promptbar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New prompt": "New prompt", 3 | "New folder": "New folder", 4 | "No prompts.": "No prompts.", 5 | "Search prompts...": "Search prompts...", 6 | "Name": "Name", 7 | "Description": "Description", 8 | "A description for your prompt.": "A description for your prompt.", 9 | "Prompt": "Prompt", 10 | "Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}": "Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}", 11 | "Save": "Save" 12 | } 13 | -------------------------------------------------------------------------------- /chat-ui/public/locales/si/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Dark mode": "අඳුරු මාදිලිය", 3 | "Light mode": "ආලෝක මාදිලිය" 4 | } 5 | -------------------------------------------------------------------------------- /chat-ui/public/locales/si/sidebar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New folder": "නව ෆෝල්ඩරය", 3 | "New chat": "නව සංවාදයක්", 4 | "No conversations.": "සංවාද නැත.", 5 | "Search conversations...": "සංවාද සොයන්න...", 6 | "OpenAI API Key": "OpenAI API යතුර", 7 | "Import data": "සංවාද ආයාත කරන්න", 8 | "Are you sure?": "ඔබට විශ්වාස ද?", 9 | "Clear conversations": "සංවාද මකන්න", 10 | "Export data": "සංවාද නිර්යාත කරන්න" 11 | } 12 | -------------------------------------------------------------------------------- /chat-ui/public/locales/sv/common.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /chat-ui/public/locales/sv/markdown.json: -------------------------------------------------------------------------------- 1 | { 2 | "Copy code": "Kopiera kod", 3 | "Copied!": "Kopierad!", 4 | "Enter file name": "Ange filnamn" 5 | } 6 | -------------------------------------------------------------------------------- /chat-ui/public/locales/sv/promptbar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New prompt": "Ny prompt", 3 | "New folder": "Ny mapp", 4 | "No prompts.": "Inga prompts.", 5 | "Search prompts...": "Sök prompts...", 6 | "Name": "Namn", 7 | "Description": "Beskrivning", 8 | "A description for your prompt.": "En beskrivning för din prompt.", 9 | "Prompt": "Prompt", 10 | "Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}": "Prompt-innehåll. Använd {{}} för att beteckna en variabel. Ex: {{namn}} är ett {{adjektiv}} {{substantiv}}", 11 | "Save": "Spara" 12 | } 13 | -------------------------------------------------------------------------------- /chat-ui/public/locales/sv/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Dark mode": "Mörkt läge", 3 | "Light mode": "Ljust läge" 4 | } 5 | -------------------------------------------------------------------------------- /chat-ui/public/locales/sv/sidebar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New folder": "Ny mapp", 3 | "New chat": "Ny chatt", 4 | "No conversations.": "Inga konversationer.", 5 | "Search conversations...": "Sök konversationer...", 6 | "OpenAI API Key": "OpenAI API-nyckel", 7 | "Import data": "Importera konversationer", 8 | "Are you sure?": "Är du säker?", 9 | "Clear conversations": "Radera konversationer", 10 | "Export data": "Exportera konversationer" 11 | } 12 | -------------------------------------------------------------------------------- /chat-ui/public/locales/te/common.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /chat-ui/public/locales/te/markdown.json: -------------------------------------------------------------------------------- 1 | { 2 | "Copy code": "కోడ్‌ను కాపీ చేయండి", 3 | "Copied!": "కాపీ చేయబడింది!", 4 | "Enter file name": "ఫైల్ పేరు నమోదు చేయండి" 5 | } 6 | -------------------------------------------------------------------------------- /chat-ui/public/locales/te/promptbar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New prompt": "New prompt", 3 | "New folder": "New folder", 4 | "No prompts.": "No prompts.", 5 | "Search prompts...": "Search prompts...", 6 | "Name": "Name", 7 | "Description": "Description", 8 | "A description for your prompt.": "A description for your prompt.", 9 | "Prompt": "Prompt", 10 | "Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}": "Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}", 11 | "Save": "Save" 12 | } 13 | -------------------------------------------------------------------------------- /chat-ui/public/locales/te/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Dark mode": "డార్క్ మోడ్", 3 | "Light mode": "లైట్ మోడ్" 4 | } 5 | -------------------------------------------------------------------------------- /chat-ui/public/locales/te/sidebar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New folder": "కొత్త ఫోల్డర్", 3 | "New chat": "కొత్త చాట్", 4 | "No conversations.": "సంభాషణలు లేవు.", 5 | "Search conversations...": "సంభాషణలు వెతకండి...", 6 | "OpenAI API Key": "ఒపెన్ ఎయి ఐ API కీ ", 7 | "Import data": "సంభాషణలు దిగుమతి చేయండి", 8 | "Are you sure?": "మీరు ఖచ్చితంగా ఉన్నారా?", 9 | "Clear conversations": "సంభాషణలు తొలగించు", 10 | "Export data": "సంభాషణలు ఎగుమతి చేయండి" 11 | } 12 | -------------------------------------------------------------------------------- /chat-ui/public/locales/tr/chat.json: -------------------------------------------------------------------------------- 1 | { 2 | "OpenAI API Key Required": "OpenAI API Anahtarı Gerekli", 3 | "Please set your OpenAI API key in the bottom left of the sidebar.": "Lütfen OpenAI API anahtarınızı yan çubuğun sol altınan'dan ayarlayın.", 4 | "Stop Generating": "Durdur", 5 | "Prompt limit is {{maxLength}} characters": "Prompt sınırı {{maxLength}} karakterdir", 6 | "System Prompt": "Sistem Prompt", 7 | "You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.": "Sen ChatGPT'sin, OpenAI tarafından eğitilmiş büyük bir dil modelisin. Kullanıcının talimatlarını dikkatlice takip et. Yanıtını markdown kullanarak ver.", 8 | "Enter a prompt": "Bir prompt girin", 9 | "Regenerate response": "Yanıtı Yeniden Oluştur", 10 | "Sorry, there was an error.": "Üzgünüm, bir hata oluştu.", 11 | "Model": "Model", 12 | "Conversation": "Sohbet", 13 | "OR": "VEYA", 14 | "Loading...": "Yükleniyor...", 15 | "Type a message...": "Bir mesaj yazın...", 16 | "Error fetching models.": "Modeller getirilirken hata oluştu.", 17 | "AI": "Yapay Zeka", 18 | "You": "Sen", 19 | "Cancel": "İptal", 20 | "Save & Submit": "Kaydet ve Gönder", 21 | "Make sure your OpenAI API key is set in the bottom left of the sidebar.": "OpenAI API anahtarınızın yan çubuğun sol altında ayarlandığından emin ol.", 22 | "If you completed this step, OpenAI may be experiencing issues.": "Bu adımı tamamladıysanız, OpenAI sorun yaşıyor olabilir.", 23 | "click if using a .env.local file": "Eğer .env.local dosyası kullanıyorsanız tıklayın", 24 | "Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.": "Mesaj sınırı {{maxLength}} karakterdir. {{valueLength}} karakter girdiniz.", 25 | "Please enter a message": "Lütfen bir mesaj girin", 26 | "Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.": "Chatbot UI, ChatGPT'nin arayüz ve işlevselliğini taklit etmeyi amaçlayan OpenAI'in sohbet modelleri için gelişmiş bir sohbetbot kitidir.", 27 | "Are you sure you want to clear all messages?": "Tüm mesajları temizlemek istediğinize emin misiniz?" 28 | } 29 | -------------------------------------------------------------------------------- /chat-ui/public/locales/tr/common.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /chat-ui/public/locales/tr/markdown.json: -------------------------------------------------------------------------------- 1 | { 2 | "Copy code": "Kodu kopyala", 3 | "Copied!": "Kopyalandi!", 4 | "Enter file name": "Dosya ismi gir" 5 | } 6 | -------------------------------------------------------------------------------- /chat-ui/public/locales/tr/promptbar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New prompt": "Yeni prompt", 3 | "New folder": "Yeni klasör", 4 | "No prompts.": "Prompt yok.", 5 | "Search prompts...": "Prompt'ları ara...", 6 | "Name": "İsim", 7 | "Description": "Açıklama", 8 | "A description for your prompt.": "Prompt'unuz için bir açıklama.", 9 | "Prompt": "Prompt", 10 | "Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}": "Prompt içeriği. Değişken belirtmek için {{}} kullanın. Örn: {{ad}} bir {{sıfat}} {{isim}}", 11 | "Save": "Kaydet" 12 | } 13 | -------------------------------------------------------------------------------- /chat-ui/public/locales/tr/sidebar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New folder": "Yeni klasör", 3 | "New chat": "Yeni sohbet", 4 | "No conversations.": "Hiçbir konuşma yok.", 5 | "Search conversations...": "Sohbetleri ara...", 6 | "OpenAI API Key": "OpenAI API Anahtarı", 7 | "Import data": "Veri içe aktar", 8 | "Are you sure?": "Emin misiniz?", 9 | "Clear conversations": "Konuşmaları temizle", 10 | "Export data": "Veri dışa aktar", 11 | "Dark mode": "Karanlık mod", 12 | "Light mode": "Aydınlık mod", 13 | "Plugin Keys": "Plugin Anahtarları" 14 | } 15 | -------------------------------------------------------------------------------- /chat-ui/public/locales/vi/common.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /chat-ui/public/locales/vi/markdown.json: -------------------------------------------------------------------------------- 1 | { 2 | "Copy code": "Sao chép mã", 3 | "Copied!": "Đã sao chép!", 4 | "Enter file name": "Nhập tên file" 5 | } 6 | -------------------------------------------------------------------------------- /chat-ui/public/locales/vi/promptbar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New prompt": "Prompt mới", 3 | "New folder": "Thư mục mới", 4 | "No prompts.": "Không có Prompt nào.", 5 | "Search prompts...": "Tìm kiếm các Prompt...", 6 | "Name": "Tên", 7 | "Description": "Mô tả", 8 | "A description for your prompt.": "Một mô tả cho Prompt của bạn.", 9 | "Prompt": "Prompt", 10 | "Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}": "Nội dung Prompt. Sử dụng {{}} để biểu thị một biến. Ví dụ: {{name}} là một {{adjective}} {{noun}}", 11 | "Save": "Lưu" 12 | } 13 | -------------------------------------------------------------------------------- /chat-ui/public/locales/vi/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Dark mode": "Chế độ tối", 3 | "Light mode": "Chế độ sáng" 4 | } 5 | -------------------------------------------------------------------------------- /chat-ui/public/locales/vi/sidebar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New folder": "Thư mục mới", 3 | "New chat": "Tạo hội thoại mới", 4 | "No conversations.": "Không có hội thoại nào.", 5 | "Search conversations...": "Tìm kiếm các cuộc hội thoại...", 6 | "OpenAI API Key": "OpenAI API Key", 7 | "Import data": "Nhập dữ liệu hội thoại", 8 | "Are you sure?": "Bạn chắc chắn chứ?", 9 | "Clear conversations": "Xoá các đoạn hội thoại", 10 | "Export data": "Xuất dữ liệu hội thoại" 11 | } 12 | -------------------------------------------------------------------------------- /chat-ui/public/locales/zh/chat.json: -------------------------------------------------------------------------------- 1 | { 2 | "OpenAI API Key Required": "需要 OpenAI API 密钥", 3 | "Please set your OpenAI API key in the bottom left of the sidebar.": "请在侧边栏左下角设置您的 OpenAI API 密钥。", 4 | "If you don't have an OpenAI API key, you can get one here: ": "如果你没有 OpenAI API 密钥,你可以在此获取:", 5 | "Stop Generating": "停止生成", 6 | "Prompt limit is {{maxLength}} characters": "提示字数限制为 {{maxLength}} 个字符", 7 | "New Conversation": "新的聊天", 8 | "System Prompt": "系统提示", 9 | "You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.": "你是 ChatGPT,一个由 OpenAI 训练的大型语言模型。请仔细遵循用户的指示。使用 Markdown 格式进行回应。", 10 | "Enter a prompt": "输入一个提示", 11 | "Regenerate response": "重新生成回应", 12 | "Sorry, there was an error.": "抱歉,出现了错误。", 13 | "Model": "模型", 14 | "Conversation": "对话", 15 | "OR": "或", 16 | "Loading...": "加载中...", 17 | "Type a message or type \"/\" to select a prompt...": "输入一条消息或键入 \"/\" 以选择提示...", 18 | "Error fetching models.": "获取模型时出错。", 19 | "AI": "AI", 20 | "You": "你", 21 | "Cancel": "取消", 22 | "Save & Submit": "保存并提交", 23 | "Make sure your OpenAI API key is set in the bottom left of the sidebar.": "请确保您的 OpenAI API 密钥已在侧边栏左下角设置。", 24 | "If you completed this step, OpenAI may be experiencing issues.": "如果您已完成此步骤,OpenAI 可能遇到了问题。", 25 | "click if using a .env.local file": "click if using a .env.local file", 26 | "Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.": "消息字数限制为 {{maxLength}} 个字符。您已输入 {{valueLength}} 个字符。", 27 | "Please enter a message": "请输入一条消息", 28 | "Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.": "Chatbot UI 是一个高级聊天机器人工具包,旨在模仿 OpenAI 聊天模型的 ChatGPT 界面和功能。", 29 | "Are you sure you want to clear all messages?": "你确定要清除所有的消息吗?", 30 | "Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.": "较高的数值(例如0.8)会使输出更随机,而较低的数值(例如0.2)会使输出更加聚焦和确定性更强。", 31 | "View Account Usage": "查阅账户用量", 32 | "Temperature": "生成温度", 33 | "Precise": "保守", 34 | "Neutral": "中立", 35 | "Creative": "随性" 36 | } 37 | -------------------------------------------------------------------------------- /chat-ui/public/locales/zh/common.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /chat-ui/public/locales/zh/markdown.json: -------------------------------------------------------------------------------- 1 | { 2 | "Copy code": "复制代码", 3 | "Copied!": "已复制!", 4 | "Enter file name": "输入文件名" 5 | } 6 | -------------------------------------------------------------------------------- /chat-ui/public/locales/zh/promptbar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New prompt": "新建提示", 3 | "New folder": "新建文件夹", 4 | "No prompts.": "无提示词", 5 | "Search prompts...": "搜索提示...", 6 | "Name": "名称", 7 | "A name for your prompt.": "提示词名称", 8 | "Description": "描述", 9 | "A description for your prompt.": "提示词描述", 10 | "Prompt": "提示词", 11 | "Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}": "提示内容。使用 {{}} 表示一个变量。例如:{{name}} 是一个 {{adjective}} {{noun}}", 12 | "Save": "保存" 13 | } 14 | -------------------------------------------------------------------------------- /chat-ui/public/locales/zh/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Settings": "设置", 3 | "Theme": "主题", 4 | "Dark mode": "深色模式", 5 | "Light mode": "浅色模式", 6 | "Save": "保存" 7 | } 8 | -------------------------------------------------------------------------------- /chat-ui/public/locales/zh/sidebar.json: -------------------------------------------------------------------------------- 1 | { 2 | "New folder": "新建文件夹", 3 | "New chat": "新建聊天", 4 | "New Conversation": "新的聊天", 5 | "No conversations.": "无对话", 6 | "Search conversations...": "搜索对话...", 7 | "OpenAI API Key": "OpenAI API 密钥", 8 | "Import data": "导入对话", 9 | "Are you sure?": "确定吗?", 10 | "Clear conversations": "清空对话", 11 | "Settings": "设置", 12 | "Export data": "导出对话", 13 | "Plugin Keys": "插件密钥" 14 | } 15 | -------------------------------------------------------------------------------- /chat-ui/public/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabhed/validator-endpoint/4572ba711392b82320f4e7f76ee09aa50803908f/chat-ui/public/screenshot.png -------------------------------------------------------------------------------- /chat-ui/public/screenshots/screenshot-0402023.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabhed/validator-endpoint/4572ba711392b82320f4e7f76ee09aa50803908f/chat-ui/public/screenshots/screenshot-0402023.jpg -------------------------------------------------------------------------------- /chat-ui/styles/globals.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | 5 | ::-webkit-scrollbar-track { 6 | background-color: transparent; 7 | } 8 | 9 | ::-webkit-scrollbar-thumb { 10 | background-color: #ccc; 11 | border-radius: 10px; 12 | } 13 | 14 | ::-webkit-scrollbar-thumb:hover { 15 | background-color: #aaa; 16 | } 17 | 18 | ::-webkit-scrollbar-track:hover { 19 | background-color: #f2f2f2; 20 | } 21 | 22 | ::-webkit-scrollbar-corner { 23 | background-color: transparent; 24 | } 25 | 26 | ::-webkit-scrollbar { 27 | width: 6px; 28 | height: 6px; 29 | } 30 | 31 | html { 32 | background: #202123; 33 | } 34 | 35 | @media (max-width: 720px) { 36 | pre { 37 | width: calc(100vw - 110px); 38 | } 39 | } 40 | 41 | pre:has(div.codeblock) { 42 | padding: 0; 43 | } 44 | -------------------------------------------------------------------------------- /chat-ui/tailwind.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('tailwindcss').Config} */ 2 | module.exports = { 3 | content: [ 4 | './app/**/*.{js,ts,jsx,tsx}', 5 | './pages/**/*.{js,ts,jsx,tsx}', 6 | './components/**/*.{js,ts,jsx,tsx}', 7 | ], 8 | darkMode: 'class', 9 | theme: { 10 | extend: {}, 11 | }, 12 | variants: { 13 | extend: { 14 | visibility: ['group-hover'], 15 | }, 16 | }, 17 | plugins: [require('@tailwindcss/typography')], 18 | }; 19 | -------------------------------------------------------------------------------- /chat-ui/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": ["dom", "dom.iterable", "esnext"], 5 | "allowJs": true, 6 | "skipLibCheck": true, 7 | "strict": true, 8 | "forceConsistentCasingInFileNames": true, 9 | "noEmit": true, 10 | "esModuleInterop": true, 11 | "module": "esnext", 12 | "moduleResolution": "node", 13 | "resolveJsonModule": true, 14 | "isolatedModules": true, 15 | "jsx": "preserve", 16 | "incremental": true, 17 | "types": ["vitest/globals"], 18 | "paths": { 19 | "@/*": ["./*"] 20 | } 21 | }, 22 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], 23 | "exclude": ["node_modules"] 24 | } 25 | -------------------------------------------------------------------------------- /chat-ui/types/chat.ts: -------------------------------------------------------------------------------- 1 | export interface Message { 2 | role: Role; 3 | content: string; 4 | } 5 | 6 | export type Role = 'assistant' | 'user'; 7 | 8 | export interface ChatBody { 9 | messages: Message[]; 10 | key: string; 11 | prompt: string; 12 | uid: number | undefined; 13 | api: string; 14 | plugins: string[]; 15 | } 16 | 17 | export interface Conversation { 18 | id: string; 19 | name: string; 20 | messages: Message[]; 21 | prompt: string; 22 | folderId: string | null; 23 | } 24 | -------------------------------------------------------------------------------- /chat-ui/types/data.ts: -------------------------------------------------------------------------------- 1 | export interface KeyValuePair { 2 | key: string; 3 | value: any; 4 | } 5 | -------------------------------------------------------------------------------- /chat-ui/types/env.ts: -------------------------------------------------------------------------------- 1 | export interface ProcessEnv { 2 | OPENAI_API_KEY: string; 3 | OPENAI_API_HOST?: string; 4 | OPENAI_API_TYPE?: 'openai' | 'azure'; 5 | OPENAI_API_VERSION?: string; 6 | OPENAI_ORGANIZATION?: string; 7 | } 8 | -------------------------------------------------------------------------------- /chat-ui/types/error.ts: -------------------------------------------------------------------------------- 1 | export interface ErrorMessage { 2 | code: String | null; 3 | title: String; 4 | messageLines: String[]; 5 | } 6 | -------------------------------------------------------------------------------- /chat-ui/types/export.ts: -------------------------------------------------------------------------------- 1 | import { Conversation, Message } from './chat'; 2 | import { FolderInterface } from './folder'; 3 | import { OpenAIModel } from './openai'; 4 | import { Prompt } from './prompt'; 5 | 6 | export type SupportedExportFormats = 7 | | ExportFormatV1 8 | | ExportFormatV2 9 | | ExportFormatV3 10 | | ExportFormatV4; 11 | export type LatestExportFormat = ExportFormatV4; 12 | 13 | //////////////////////////////////////////////////////////////////////////////////////////// 14 | interface ConversationV1 { 15 | id: number; 16 | name: string; 17 | messages: Message[]; 18 | } 19 | 20 | export type ExportFormatV1 = ConversationV1[]; 21 | 22 | //////////////////////////////////////////////////////////////////////////////////////////// 23 | interface ChatFolder { 24 | id: number; 25 | name: string; 26 | } 27 | 28 | export interface ExportFormatV2 { 29 | history: Conversation[] | null; 30 | folders: ChatFolder[] | null; 31 | } 32 | 33 | //////////////////////////////////////////////////////////////////////////////////////////// 34 | export interface ExportFormatV3 { 35 | version: 3; 36 | history: Conversation[]; 37 | folders: FolderInterface[]; 38 | } 39 | 40 | export interface ExportFormatV4 { 41 | version: 4; 42 | history: Conversation[]; 43 | folders: FolderInterface[]; 44 | prompts: Prompt[]; 45 | } 46 | -------------------------------------------------------------------------------- /chat-ui/types/folder.ts: -------------------------------------------------------------------------------- 1 | export interface FolderInterface { 2 | id: string; 3 | name: string; 4 | type: FolderType; 5 | } 6 | 7 | export type FolderType = 'chat' | 'prompt'; 8 | -------------------------------------------------------------------------------- /chat-ui/types/google.ts: -------------------------------------------------------------------------------- 1 | import { ChatBody, Message } from './chat'; 2 | 3 | export interface GoogleBody extends ChatBody { 4 | googleAPIKey: string; 5 | googleCSEId: string; 6 | } 7 | 8 | export interface GoogleResponse { 9 | message: Message; 10 | } 11 | 12 | export interface GoogleSource { 13 | title: string; 14 | link: string; 15 | displayLink: string; 16 | snippet: string; 17 | image: string; 18 | text: string; 19 | } 20 | -------------------------------------------------------------------------------- /chat-ui/types/index.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /chat-ui/types/openai.ts: -------------------------------------------------------------------------------- 1 | import { OPENAI_API_TYPE } from '../utils/app/const'; 2 | 3 | export interface OpenAIModel { 4 | id: string; 5 | name: string; 6 | maxLength: number; // maximum length of a message 7 | tokenLimit: number; 8 | } 9 | 10 | export enum OpenAIModelID { 11 | GPT_3_5 = 'gpt-3.5-turbo', 12 | GPT_3_5_AZ = 'gpt-35-turbo', 13 | GPT_4 = 'gpt-4', 14 | GPT_4_32K = 'gpt-4-32k', 15 | } 16 | 17 | // in case the `DEFAULT_MODEL` environment variable is not set or set to an unsupported model 18 | export const fallbackModelID = OpenAIModelID.GPT_3_5; 19 | 20 | export const OpenAIModels: Record = { 21 | [OpenAIModelID.GPT_3_5]: { 22 | id: OpenAIModelID.GPT_3_5, 23 | name: 'GPT-3.5', 24 | maxLength: 12000, 25 | tokenLimit: 4000, 26 | }, 27 | [OpenAIModelID.GPT_3_5_AZ]: { 28 | id: OpenAIModelID.GPT_3_5_AZ, 29 | name: 'GPT-3.5', 30 | maxLength: 12000, 31 | tokenLimit: 4000, 32 | }, 33 | [OpenAIModelID.GPT_4]: { 34 | id: OpenAIModelID.GPT_4, 35 | name: 'GPT-4', 36 | maxLength: 24000, 37 | tokenLimit: 8000, 38 | }, 39 | [OpenAIModelID.GPT_4_32K]: { 40 | id: OpenAIModelID.GPT_4_32K, 41 | name: 'GPT-4-32K', 42 | maxLength: 96000, 43 | tokenLimit: 32000, 44 | }, 45 | }; 46 | -------------------------------------------------------------------------------- /chat-ui/types/plugin.ts: -------------------------------------------------------------------------------- 1 | import { KeyValuePair } from './data'; 2 | 3 | export interface Plugin { 4 | id: PluginID; 5 | name: PluginName; 6 | requiredKeys: KeyValuePair[]; 7 | } 8 | 9 | export interface PluginKey { 10 | pluginId: PluginID; 11 | requiredKeys: KeyValuePair[]; 12 | } 13 | 14 | export enum PluginID { 15 | GOOGLE_SEARCH = 'google-search', 16 | } 17 | 18 | export enum PluginName { 19 | GOOGLE_SEARCH = 'Google Search', 20 | } 21 | 22 | export const Plugins: Record = { 23 | [PluginID.GOOGLE_SEARCH]: { 24 | id: PluginID.GOOGLE_SEARCH, 25 | name: PluginName.GOOGLE_SEARCH, 26 | requiredKeys: [ 27 | { 28 | key: 'GOOGLE_API_KEY', 29 | value: '', 30 | }, 31 | { 32 | key: 'GOOGLE_CSE_ID', 33 | value: '', 34 | }, 35 | ], 36 | }, 37 | }; 38 | 39 | export const PluginList = Object.values(Plugins); 40 | -------------------------------------------------------------------------------- /chat-ui/types/prompt.ts: -------------------------------------------------------------------------------- 1 | export interface Prompt { 2 | id: string; 3 | name: string; 4 | description: string; 5 | content: string; 6 | folderId: string | null; 7 | } 8 | -------------------------------------------------------------------------------- /chat-ui/types/settings.ts: -------------------------------------------------------------------------------- 1 | export interface Settings { 2 | theme: 'light' | 'dark'; 3 | } 4 | -------------------------------------------------------------------------------- /chat-ui/types/storage.ts: -------------------------------------------------------------------------------- 1 | import { Conversation } from './chat'; 2 | import { FolderInterface } from './folder'; 3 | import { PluginKey } from './plugin'; 4 | import { Prompt } from './prompt'; 5 | 6 | // keep track of local storage schema 7 | export interface LocalStorage { 8 | apiKey: string; 9 | conversationHistory: Conversation[]; 10 | selectedConversation: Conversation; 11 | theme: 'light' | 'dark'; 12 | // added folders (3/23/23) 13 | folders: FolderInterface[]; 14 | // added prompts (3/26/23) 15 | prompts: Prompt[]; 16 | // added showChatbar and showPromptbar (3/26/23) 17 | showChatbar: boolean; 18 | showPromptbar: boolean; 19 | // added plugin keys (4/3/23) 20 | pluginKeys: PluginKey[]; 21 | } 22 | -------------------------------------------------------------------------------- /chat-ui/utils/app/api.ts: -------------------------------------------------------------------------------- 1 | import { Plugin, PluginID } from '@/types/plugin'; 2 | 3 | export const getEndpoint = (plugin: Plugin | null) => { 4 | if (!plugin) { 5 | return 'api/chat'; 6 | } 7 | 8 | if (plugin.id === PluginID.GOOGLE_SEARCH) { 9 | return 'api/google'; 10 | } 11 | 12 | return 'api/chat'; 13 | }; 14 | -------------------------------------------------------------------------------- /chat-ui/utils/app/clean.ts: -------------------------------------------------------------------------------- 1 | import { Conversation } from '@/types/chat'; 2 | import { OpenAIModelID, OpenAIModels } from '@/types/openai'; 3 | 4 | import { DEFAULT_SYSTEM_PROMPT, DEFAULT_TEMPERATURE } from './const'; 5 | 6 | export const cleanSelectedConversation = (conversation: Conversation) => { 7 | // added model for each conversation (3/20/23) 8 | // added system prompt for each conversation (3/21/23) 9 | // added folders (3/23/23) 10 | // added prompts (3/26/23) 11 | // added messages (4/16/23) 12 | 13 | let updatedConversation = conversation; 14 | 15 | // check for system prompt on each conversation 16 | if (!updatedConversation.prompt) { 17 | updatedConversation = { 18 | ...updatedConversation, 19 | prompt: updatedConversation.prompt || DEFAULT_SYSTEM_PROMPT, 20 | }; 21 | } 22 | 23 | if (!updatedConversation.folderId) { 24 | updatedConversation = { 25 | ...updatedConversation, 26 | folderId: updatedConversation.folderId || null, 27 | }; 28 | } 29 | 30 | if (!updatedConversation.messages) { 31 | updatedConversation = { 32 | ...updatedConversation, 33 | messages: updatedConversation.messages || [], 34 | }; 35 | } 36 | 37 | return updatedConversation; 38 | }; 39 | 40 | export const cleanConversationHistory = (history: any[]): Conversation[] => { 41 | // added model for each conversation (3/20/23) 42 | // added system prompt for each conversation (3/21/23) 43 | // added folders (3/23/23) 44 | // added prompts (3/26/23) 45 | // added messages (4/16/23) 46 | 47 | if (!Array.isArray(history)) { 48 | console.warn('history is not an array. Returning an empty array.'); 49 | return []; 50 | } 51 | 52 | return history.reduce((acc: any[], conversation) => { 53 | try { 54 | if (!conversation.prompt) { 55 | conversation.prompt = DEFAULT_SYSTEM_PROMPT; 56 | } 57 | 58 | if (!conversation.folderId) { 59 | conversation.folderId = null; 60 | } 61 | 62 | if (!conversation.messages) { 63 | conversation.messages = []; 64 | } 65 | 66 | acc.push(conversation); 67 | return acc; 68 | } catch (error) { 69 | console.warn( 70 | `error while cleaning conversations' history. Removing culprit`, 71 | error, 72 | ); 73 | } 74 | return acc; 75 | }, []); 76 | }; 77 | -------------------------------------------------------------------------------- /chat-ui/utils/app/codeblock.ts: -------------------------------------------------------------------------------- 1 | interface languageMap { 2 | [key: string]: string | undefined; 3 | } 4 | 5 | export const programmingLanguages: languageMap = { 6 | javascript: '.js', 7 | python: '.py', 8 | java: '.java', 9 | c: '.c', 10 | cpp: '.cpp', 11 | 'c++': '.cpp', 12 | 'c#': '.cs', 13 | ruby: '.rb', 14 | php: '.php', 15 | swift: '.swift', 16 | 'objective-c': '.m', 17 | kotlin: '.kt', 18 | typescript: '.ts', 19 | go: '.go', 20 | perl: '.pl', 21 | rust: '.rs', 22 | scala: '.scala', 23 | haskell: '.hs', 24 | lua: '.lua', 25 | shell: '.sh', 26 | sql: '.sql', 27 | html: '.html', 28 | css: '.css', 29 | // add more file extensions here, make sure the key is same as language prop in CodeBlock.tsx component 30 | }; 31 | 32 | export const generateRandomString = (length: number, lowercase = false) => { 33 | const chars = 'ABCDEFGHJKLMNPQRSTUVWXY3456789'; // excluding similar looking characters like Z, 2, I, 1, O, 0 34 | let result = ''; 35 | for (let i = 0; i < length; i++) { 36 | result += chars.charAt(Math.floor(Math.random() * chars.length)); 37 | } 38 | return lowercase ? result.toLowerCase() : result; 39 | }; 40 | -------------------------------------------------------------------------------- /chat-ui/utils/app/const.ts: -------------------------------------------------------------------------------- 1 | export const title = 'Bittensor Chat'; 2 | 3 | export const DEFAULT_SYSTEM_PROMPT = 4 | process.env.NEXT_PUBLIC_DEFAULT_SYSTEM_PROMPT || 5 | "*Start new session** You are an AI assistant. Follow the user's instructions carefully. Respond using markdown."; 6 | 7 | export const NEXT_PUBLIC_VALIDATOR_ENDPOINT_BASE_URL = 8 | process.env.NEXT_PUBLIC_VALIDATOR_ENDPOINT_BASE_URL || 9 | 'https://validator-api.fabhed.dev'; 10 | export const OPENAI_API_HOST = 11 | process.env.OPENAI_API_HOST || 'https://api.openai.com'; 12 | 13 | export const DEFAULT_TEMPERATURE = parseFloat( 14 | process.env.NEXT_PUBLIC_DEFAULT_TEMPERATURE || '1', 15 | ); 16 | 17 | export const OPENAI_API_TYPE = process.env.OPENAI_API_TYPE || 'openai'; 18 | 19 | export const OPENAI_API_VERSION = 20 | process.env.OPENAI_API_VERSION || '2023-03-15-preview'; 21 | 22 | export const OPENAI_ORGANIZATION = process.env.OPENAI_ORGANIZATION || ''; 23 | 24 | export const AZURE_DEPLOYMENT_ID = process.env.AZURE_DEPLOYMENT_ID || ''; 25 | 26 | export const AUTH0_DOMAIN = process.env.NEXT_PUBLIC_AUTH0_DOMAIN || ''; 27 | export const AUTH0_CLIENT_ID = process.env.NEXT_PUBLIC_AUTH0_CLIENT_ID || ''; 28 | -------------------------------------------------------------------------------- /chat-ui/utils/app/conversation.ts: -------------------------------------------------------------------------------- 1 | import { Conversation } from '@/types/chat'; 2 | 3 | export const updateConversation = ( 4 | updatedConversation: Conversation, 5 | allConversations: Conversation[], 6 | ) => { 7 | const updatedConversations = allConversations.map((c) => { 8 | if (c.id === updatedConversation.id) { 9 | return updatedConversation; 10 | } 11 | 12 | return c; 13 | }); 14 | 15 | saveConversation(updatedConversation); 16 | saveConversations(updatedConversations); 17 | 18 | return { 19 | single: updatedConversation, 20 | all: updatedConversations, 21 | }; 22 | }; 23 | 24 | export const saveConversation = (conversation: Conversation) => { 25 | localStorage.setItem('selectedConversation', JSON.stringify(conversation)); 26 | }; 27 | 28 | export const saveConversations = (conversations: Conversation[]) => { 29 | localStorage.setItem('conversationHistory', JSON.stringify(conversations)); 30 | }; 31 | -------------------------------------------------------------------------------- /chat-ui/utils/app/folders.ts: -------------------------------------------------------------------------------- 1 | import { FolderInterface } from '@/types/folder'; 2 | 3 | export const saveFolders = (folders: FolderInterface[]) => { 4 | localStorage.setItem('folders', JSON.stringify(folders)); 5 | }; 6 | -------------------------------------------------------------------------------- /chat-ui/utils/app/prompts.ts: -------------------------------------------------------------------------------- 1 | import { Prompt } from '@/types/prompt'; 2 | 3 | export const updatePrompt = (updatedPrompt: Prompt, allPrompts: Prompt[]) => { 4 | const updatedPrompts = allPrompts.map((c) => { 5 | if (c.id === updatedPrompt.id) { 6 | return updatedPrompt; 7 | } 8 | 9 | return c; 10 | }); 11 | 12 | savePrompts(updatedPrompts); 13 | 14 | return { 15 | single: updatedPrompt, 16 | all: updatedPrompts, 17 | }; 18 | }; 19 | 20 | export const savePrompts = (prompts: Prompt[]) => { 21 | localStorage.setItem('prompts', JSON.stringify(prompts)); 22 | }; 23 | -------------------------------------------------------------------------------- /chat-ui/utils/app/settings.ts: -------------------------------------------------------------------------------- 1 | import { Settings } from '@/types/settings'; 2 | 3 | const STORAGE_KEY = 'settings'; 4 | 5 | export const getSettings = (): Settings => { 6 | let settings: Settings = { 7 | theme: 'dark', 8 | }; 9 | const settingsJson = localStorage.getItem(STORAGE_KEY); 10 | if (settingsJson) { 11 | try { 12 | let savedSettings = JSON.parse(settingsJson) as Settings; 13 | settings = Object.assign(settings, savedSettings); 14 | } catch (e) { 15 | console.error(e); 16 | } 17 | } 18 | return settings; 19 | }; 20 | 21 | export const saveSettings = (settings: Settings) => { 22 | localStorage.setItem(STORAGE_KEY, JSON.stringify(settings)); 23 | }; 24 | -------------------------------------------------------------------------------- /chat-ui/utils/data/throttle.ts: -------------------------------------------------------------------------------- 1 | export function throttle any>( 2 | func: T, 3 | limit: number, 4 | ): T { 5 | let lastFunc: ReturnType; 6 | let lastRan: number; 7 | 8 | return ((...args) => { 9 | if (!lastRan) { 10 | func(...args); 11 | lastRan = Date.now(); 12 | } else { 13 | clearTimeout(lastFunc); 14 | lastFunc = setTimeout(() => { 15 | if (Date.now() - lastRan >= limit) { 16 | func(...args); 17 | lastRan = Date.now(); 18 | } 19 | }, limit - (Date.now() - lastRan)); 20 | } 21 | }) as T; 22 | } 23 | -------------------------------------------------------------------------------- /chat-ui/utils/server/google.ts: -------------------------------------------------------------------------------- 1 | export const cleanSourceText = (text: string) => { 2 | return text 3 | .trim() 4 | .replace(/(\n){4,}/g, '\n\n\n') 5 | .replace(/\n\n/g, ' ') 6 | .replace(/ {3,}/g, ' ') 7 | .replace(/\t/g, '') 8 | .replace(/\n+(\s*\n)*/g, '\n'); 9 | }; 10 | -------------------------------------------------------------------------------- /chat-ui/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import path from 'path'; 2 | import { defineConfig } from 'vite'; 3 | 4 | export default defineConfig({ 5 | resolve: { 6 | alias: { 7 | '@': path.resolve(__dirname, './'), 8 | }, 9 | }, 10 | }); 11 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # Documentation 2 | 3 | ## Btvep 4 | 5 | In this documentation you will find examples on how to use the backend part of the valdiator-endpoint repository. The backend is called `btvep` ( 6 | **B**it**t**ensor **V**alidator **E**nd**p**oint) and contains an API server, Database (SQLite) and a CLI. It's the core of the repository which the `chat-ui` and `admin-ui` connects to. 7 | 8 | If you are new, the first thing you should setup is the backend, see the [Getting started guide](../btvep/README.md#getting-started) 9 | 10 | - [cli.md](./cli.md) - `btvep` CLI reference 11 | - [requests.md](./requests.md) - A guide for making requests. Examples with python and curl. 12 | - [docker.md](./docker.md) - A guide for using docker to host `btvep`. 13 | -------------------------------------------------------------------------------- /docs/auth0/application-allowed-settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabhed/validator-endpoint/4572ba711392b82320f4e7f76ee09aa50803908f/docs/auth0/application-allowed-settings.png -------------------------------------------------------------------------------- /docs/auth0/auth0-api-audience.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabhed/validator-endpoint/4572ba711392b82320f4e7f76ee09aa50803908f/docs/auth0/auth0-api-audience.png -------------------------------------------------------------------------------- /docs/auth0/auth0-domain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabhed/validator-endpoint/4572ba711392b82320f4e7f76ee09aa50803908f/docs/auth0/auth0-domain.png -------------------------------------------------------------------------------- /docs/auth0/create-application.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabhed/validator-endpoint/4572ba711392b82320f4e7f76ee09aa50803908f/docs/auth0/create-application.png -------------------------------------------------------------------------------- /docs/auth0/new-api-form.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabhed/validator-endpoint/4572ba711392b82320f4e7f76ee09aa50803908f/docs/auth0/new-api-form.png -------------------------------------------------------------------------------- /docs/auth0/sidebar-navigation-applications-apis.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabhed/validator-endpoint/4572ba711392b82320f4e7f76ee09aa50803908f/docs/auth0/sidebar-navigation-applications-apis.png -------------------------------------------------------------------------------- /docs/docker.md: -------------------------------------------------------------------------------- 1 | # Validator Endpoint with Docker 2 | 3 | This guide will walk you through the process of setting up and running the Validator Endpoint using Docker. This is preferrable if you don't want to bother installing the correct python version or redis, as all of this is pre-configured in our Dockerfile. It will however require you to start a shell within the docker container to be able to use the `btvep` cli. 4 | 5 | ## Install Docker 6 | 7 | To install Docker, you can follow the official Docker documentation: 8 | 9 | - [Install Docker Engine](https://docs.docker.com/engine/install/) 10 | 11 | ## Setting Up Docker Compose and Configuration 12 | 13 | ```bash 14 | # Copy the template file to a .gitignored docker-compose.yml 15 | cp docker-compose.template.yml docker-compose.yml 16 | ``` 17 | 18 | Replace the `HOTKEY_MNEMONIC` environemnt variable in docker-compose.yml with your actual mnemonic. 19 | 20 | ## Starting the Container 21 | 22 | You can start the Validator Endpoint container using Docker Compose with the following command: 23 | 24 | ```bash 25 | # Starts the containers in the background 26 | docker-compose up -d 27 | ``` 28 | 29 | By default the `btvep_api` container is accessable on port 8000 your host machine. This can be changed in the docker-compose.yml file as well. 30 | 31 | ## Running Commands 32 | 33 | Since the `btvep` cli is installed in the container, it won't be accessable from your host machine. To run commands inside the running Docker container, simply use the `docker exec` command: 34 | 35 | ```bash 36 | # Start a shell with access to btvep 37 | docker exec -it btvep_api /bin/bash 38 | 39 | # Run any btvep commands 40 | btvep --help # available commands 41 | btvep key create # create an API key 42 | ``` 43 | 44 | This spawns a bash shell in the docker environment where you have access to the `btvep` command 45 | 46 | That's it! You now have your Validator Endpoint running in a Docker container. Happy validating! 47 | 48 | ## Try it out 49 | 50 | Make a request with the key you just created (Replace $API_KEY) 51 | 52 | ```bash 53 | curl http://localhost:8000/chat \ 54 | -H "Content-Type: application/json" \ 55 | -H "Authorization: Bearer $API_KEY" \ 56 | -H "Endpoint-Version: 2023-05-19" \ 57 | -d '{ 58 | "messages": [{"role": "user", "content": "What is 1+1?"}] 59 | }' 60 | ``` 61 | -------------------------------------------------------------------------------- /temp.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabhed/validator-endpoint/4572ba711392b82320f4e7f76ee09aa50803908f/temp.txt --------------------------------------------------------------------------------