Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[feature] Embed assistants #1489

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

[feature] Embed assistants #1489

wants to merge 3 commits into from

Conversation

mishig25
Copy link
Collaborator

@mishig25 mishig25 commented Sep 25, 2024

Description

Users can now create tools and connect their tools to their assistants (read here), making for use cases such as: create an assistant that queries your websites and chats about your website.

This PR adds an ability where users can embed their assistants on their websites.

Step1: under assistants settings, there will be script tag that can be put on a website's html head section.

Screenshot 2024-09-28 at 10 50 52

Step2: HF Chat button will appear on the bottom right section of your website.

Screenshot 2024-09-28 at 10 51 11

Step3: When you click on HF Chat button, a chat window modal with minimal hf/hf-chat chrome will appear

Screenshot 2024-09-28 at 10 51 30

Testing locally

  1. follow the latest readme on how to run chat-ui locally
  2. read this comment

Reviewing

when reviewing make sure to click Hide whitespace to see the actual diff
image

Screen recording

Screen.Recording.2024-09-28.at.11.00.44.mov

it may look bit confusing in the video because I'm embedding hf-chat inside hf-chat locally for testing purposes. but you can imagine the hf-chat modal being embedded on any arbitrary website

@mishig25 mishig25 force-pushed the embed_assistant branch 2 times, most recently from 3194ba5 to 54f1570 Compare September 27, 2024 11:57

document.addEventListener('DOMContentLoaded', function() {
const button = document.createElement('button');
button.className = 'fixed bottom-5 right-5 z-50 px-1.5 py-1 bg-blue-500 text-white rounded cursor-pointer hover:bg-blue-600 transition-colors flex items-center focus:outline-none';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is it going to work with tailwindcss?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will convert it back to regular css once we agree on the design

@mishig25 mishig25 force-pushed the embed_assistant branch 7 times, most recently from ed116a5 to 8749982 Compare September 28, 2024 03:25
@mishig25 mishig25 changed the title embed assistants [feature] Embed assistants Sep 28, 2024
@mishig25 mishig25 marked this pull request as ready for review September 28, 2024 03:37
Comment on lines +206 to +213
<!-- TODO: remove -->
{#if !$page.data.embeddedAssistantId}
<script
src="http://localhost:5173/chat/api/assistant/{$page.data.assistants.at(-1)
._id}/embed-snippet"
defer
></script>
{/if}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to make testing the embedded assistants easier, I'm embedding hf assistant inside the chat-ui. These lines would be removed before merging to main.

you can change {$page.data.assistants.at(-1)._id} this part that grabs the last assistant id to any specific local assistant id if you want

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants