Coder Social home page Coder Social logo

huggingface / chat-ui Goto Github PK

View Code? Open in Web Editor NEW
6.8K 82.0 964.0 4.68 MB

Open source codebase powering the HuggingChat app

Home Page: https://huggingface.co/chat

License: Apache License 2.0

JavaScript 0.38% HTML 0.28% Svelte 33.43% TypeScript 65.19% Dockerfile 0.41% CSS 0.10% Shell 0.11% Smarty 0.09%
chatgpt huggingface sveltekit hacktoberfest llm svelte svelte-kit tailwindcss typescript

chat-ui's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chat-ui's Issues

Look into CORS

Given that the cookie is "Same-Site": "None", we should double check everything is ok security-wise, harden if not.

Reduce number of http calls

  • When opening a new conversation: create conversation, then call to send first message, then set conversation title
  • When sending a message on a shared conversation: duplicate conversation, then call to send first message
  • When retrying a message on a shared conversation: duplicate conversation, then retry

Each of those is two or three calls, they should only be one.

In the backend of message sending, we can maybe send a first token with the conversation id, and sometimes a last token with the conversation title?

It will also help with #19

Public repository todo

Prepare the repository to be made public:

  • scan the repo for secrets? (I used gitleaks and seems ok)
  • add "contribute" section to README
  • add banner/logo to README
  • add a license
  • add a description in the Github "About" section

Sanitize HTML messages

Either before or after the call to marked.

We probably need to load something like jsdom on the backend (but not the frontend) for dompurify to work.

Inspiration from hub code:

let purify: createDOMPurify.DOMPurifyI;

async function loadDOMPurify() {
	if (purify) {
		return;
	}
	if (typeof window === "undefined") {
		/// To avoid needing the dependency on the frontend, we load it dynamically on the backend
		// eslint-disable-next-line @typescript-eslint/no-shadow
		const { JSDOM } = await import("jsdom");
		purify = createDOMPurify(new JSDOM().window as unknown as Window);
	} else {
		purify = createDOMPurify(window);
	}

Improve accessibility

  • keyboard navigation on modals (ESC key to close) + click on background
  • keyboard navigation on conversation list, currently you can't access edit/delete buttons with keyboard
  • keyboard navigation on chat, currently you can't access retry (and soon thumb up/down) buttons with keyboard
  • minor but maybe make buttons consistent (some don't have hover/active state)

Support multiple models

Once #156 is merged:

  • Add a property "currentModel" in Settings (to remember a user's preferred model), and enable changing this setting (in the settings modal or the chat interface)
  • Pass it along instead of models[0] to the backend calls

The rest should be UI/UX/Frontend

Cleanup text output

Sometimes the model returns weird things like on the following screenshots:
image (1)

Code not parsed properly:
Screenshot 2023-04-21 at 16 28 32

Save messages in DB

Convos are created but their messages aren't saved.

We should save the messages in DB

First draft we can save directly from frontend

Delete confirmation

  • Add a confirmation before deleting chats
  • Eventually add a confirmation on retry button if not the last one (as a retry deletes all following messages)

Improve share feature

Some ideas:

  1. Same as on https://play.vercel.ai/r/QI768eA we could have a image instead of the current "Share this conversation" once the conv has been shared which copies to clipboard directly on click
  2. Maybe have a custom modal instead of window.alert for better look?
  3. You can't copy the link on Safari desktop with the share API

cc @gary149

Flash on dark theme

There's a short flash from white to dark (when on dark mode) when refreshing the page. I think it was not the case before ๐Ÿ‘€

<br> tags not being parsed properly

Since we sanitize the markdown before parsing it. We are disallowing every HTML tag within markdown apart from code blocks. We might want to selectively authorise some tags, or use a sanitizer...

Navigating between conversations should not cancel the text generation

I know it's something we built on purpose but thinking about it more and playing with it I don't think we should stop the generation when user is switching between conversations:
Imagine you want to check another conversation while waiting for the assistant to finish answering on a long request, you loose the answer.

Build last step of DOCKERFILE

Those last commands:

RUN --mount=type=secret,id=DOTENV_LOCAL,mode=0444,required=true cat /run/secrets/DOTENV_LOCAL > .env.local
   
RUN npm run build

ENV PORT 7860

CMD pm2 start build/index.js -i $CPU_CORES --no-daemon

Should be run in a .sh script called by the last CMD of the Dockerfile. Because the cache layers aren't invalidated when secrets change.

It would also allow people to download the docker image (would probably need to delete & recreate the space though, as for now we allow to download either all or none of the docker images)

cc @XciD @christophe-rannou

Backend API

  • Create MongoDB database/collections
  • Create endpoint /api/conversations
    • POST: create a new conversation
    • GET retrieve a list of conversations
  • Create endpoint /api/conversation
    • POST(conversation_id): send a new message in a conversation
  • Create endpoint /api/conversation/:id
    • GET retrieve an existing conversation

Improve browser support

Currently we don't have any target in our tsconfig. The problem is that by default TS will load some recent ecmascript version which are not compatible with fairly recent browsers such as Safari 14.

For example we are using methods such as Array.prototype.at() which is ECMAScript 2022 or replaceAll().
So we need to either set something like "lib": ["ES2018", "DOM"] so TS doesn't compile if we use those, or just polyfill them ( not sure doing "target": "ES5" would work?).

ref: https://huggingface.slack.com/archives/C055NNJF98Q/p1682531350797939

Release todo

To release

  • Mobile height (with Safari navigation bar it's overflowing)
  • Add social meta
  • Make "share" more visible
  • Code blocks screen overflow
  • Scrollbar adjustments for code blocks and navigation
  • Add disclaimer
  • Persistent conversations
  • Toggle for dark mode
  • Models selector
  • use .prose class for assistant messages #16
  • Share session with others
  • Errors handling
  • Auto-scroll #10
  • Retry with the same message?
  • Handle max-tokens
  • Stop generating #86
  • Privacy modal
  • Icons
  • #12

Others

  • Data export?
  • Auto-name conversations
  • Expose and being able to configure model params
  • Search conversations
  • Like/dislikes responses
  • Arrow up/down to browse user input history

Fix proxified headers

Currently it's:

		headers: {
			...request.headers,
			'Content-Type': 'application/json',
			Authorization: `Basic ${HF_TOKEN}`
		},

I think ...request.headers is not valid unfortunately.

By fixing we can

  • remove 'Content-Type': 'application/json'
  • Maybe even remove the guard against the route in hooks.server.ts (maybe...)

Add pre-prompt

cc @OlivierDehaene

Below are a series of dialogues between various people and an AI assistant. The AI tries to be helpful, polite, honest, sophisticated, emotionally aware, and humble-but-knowledgeable. The assistant is happy to help with almost anything, and will do its best to understand exactly what is needed. It also tries to avoid giving false or misleading information, and it caveats when it isn't entirely sure about the right answer. That said, the assistant is practical and really does its best, and doesn't let caution get too much in the way of being useful.
-----
<current prompt>
-----

Is this something we want to do ASAP @julien-c @gary149 ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.