Skip to content

Commit

Permalink
HF space
Browse files Browse the repository at this point in the history
  • Loading branch information
AstraBert committed Apr 6, 2024
1 parent c189e4b commit 7630a4e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 42 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ _Go and give it a try [here](https://hf.co/chat/assistant/660d9a4f590a7924eed02a
<img src="https://img.shields.io/badge/Release-v0.1.0-blue" alt="Static Badge">
<img src="https://img.shields.io/badge/Docker_image_size-6.44GB-red" alt="Static Badge">
<div>
<a href="https://astrabert.github.io/everything-rag/"><img src="./data/example_chat.png" alt="Example chat" align="center"></a>
<a href="https://huggingface.co/spaces/as-cle-bert/everything-rag"><img src="./data/example_chat.png" alt="Example chat" align="center"></a>
<p><i>Example chat with everything-rag, mediated by google/flan-t5-base</i></p>
</div>
</div>
Expand All @@ -26,6 +26,20 @@ _Go and give it a try [here](https://hf.co/chat/assistant/660d9a4f590a7924eed02a
5. [Contributing](#contributing)
6. [References](#reference)

## TL;DR

* Q: This README is soooooo long, I want to get my hands dirty!!!
>A: You can do it in the [dedicated HuggingFace space](https://huggingface.co/spaces/as-cle-bert/everything-rag), based on google/flan-t5-base.
<div>
<iframe
src="https://as-cle-bert-everything-rag.hf.space"
frameborder="0"
width="850"
height="450"
></iframe>
</div>

## Introduction

Introducing **everything-rag**, your fully customizable and local chatbot assistant! 🤖
Expand Down
38 changes: 2 additions & 36 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,37 +1,3 @@
# Use an official Python runtime as a parent image
FROM python:3.10-slim-buster

# Set the working directory in the container to /app
WORKDIR /app

# Add the current directory contents into the container at /app
ADD . /app

# Update and install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
libpq-dev \
libffi-dev \
libssl-dev \
musl-dev \
libxml2-dev \
libxslt1-dev \
zlib1g-dev \
&& rm -rf /var/lib/apt/lists/*

# Install Python dependencies
RUN python3 -m pip cache purge
RUN python3 -m pip install --no-cache-dir -r requirements.txt

# Set version
ARG version="v0.1.0"

# Echo version
RUN echo "Started everything-rag ${version}"

# Expose the port that the application will run on
EXPOSE 7860

# Set the entrypoint with a default command and allow the user to override it
ENTRYPOINT ["python3", "chat.py"]
FROM ghcr.io/astrabert/everything-rag:latest

ENTRYPOINT [ "python3", "chat.py" ]
Binary file modified docker/__pycache__/utils.cpython-310.pyc
Binary file not shown.
7 changes: 4 additions & 3 deletions docker/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def bot(history):
yield history
else:
try:
response = just_chatting(model=model, tokenizer=tokenizer, query=history[-1][0], vectordb=vectordb, chat_history=[convert_none_to_str(his) for his in history])["answer"]
response = just_chatting(task=tsk, model=model, tokenizer=tokenizer, query=history[-1][0], vectordb=vectordb, chat_history=[convert_none_to_str(his) for his in history])["answer"]
history[-1][1] = ""
for character in response:
history[-1][1] += character
Expand Down Expand Up @@ -70,9 +70,10 @@ def bot(history):
bot_msg.then(lambda: gr.MultimodalTextbox(interactive=True), None, [chat_input])

chatbot.like(print_like_dislike, None, None)
gr.ClearButton(chatbot)
clear = gr.ClearButton(chatbot)

demo.queue()
if __name__ == "__main__":
demo.launch(server_name="0.0.0.0", share=False)
demo.launch(share=False)


3 changes: 1 addition & 2 deletions docker/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def just_chatting(
model=model,
tokenizer=tokenizer,
max_new_tokens = 2048,
repetition_penalty = float(10),
repetition_penalty = float(1.2),
)

local_llm = HuggingFacePipeline(pipeline=pipe)
Expand All @@ -159,7 +159,6 @@ def just_chatting(
mod,
)

tokenizer.pad_token = tokenizer.eos_token

model = TASK_TO_MODEL[tsk].from_pretrained(
mod,
Expand Down

0 comments on commit 7630a4e

Please sign in to comment.