FUTFUT / app.py
mintaeng's picture
Update app.py
8db4f2f verified
raw
history blame
2.09 kB
import gradio as gr
from load_model_type_a import load_Auto
from load_push import all_files
from retriever import *
from retrieve_docs import *
from make_chain_model import make_chain_llm
from make_answer import *
def respond(
message,
history: list[tuple[str, str]],
system_message,
max_tokens,
temperature,
top_p,
):
messages = [{"role": "system", "content": system_message}]
for val in history:
if val[0]:
messages.append({"role": "user", "content": val[0]})
if val[1]:
messages.append({"role": "assistant", "content": val[1]})
messages.append({"role": "user", "content": message})
response = ""
for message in client.chat_completion(
messages,
max_tokens=max_tokens,
stream=True,
temperature=temperature,
top_p=top_p,
):
token = message.choices[0].delta.content
response += token
yield response
"""
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
"""
TITLE = "FUT FUT Chatbot"
DESCRIPTION = """
'ํ•ด์š”'์ฒด๋ฅผ ์‚ฌ์šฉํ•˜๋ฉฐ ์นœ์ ˆํ•˜๊ฒŒ ๋‹ตํ•˜๋Š” ํ’‹ํ’‹์ด ์ฑ—๋ด‡.
A rag pipeline with a chatbot feature
Resources used to build this project :
* embedding model : https://huggingface.co/BM-K/KoSimCSE-roberta-multitask
* dataset : https://huggingface.co/datasets/Dongwookss/q_a_korean_futsal
* vector DB : PINECONE
* chatbot : https://huggingface.co/Dongwookss/small_fut_final
"""
Examples = [['์‹œํฅ ํ’‹์‚ด ๊ตฌ์žฅ ์ถ”์ฒœํ•ด์ค˜'],['ํ’‹์‚ด ๊ฒฝ๊ธฐ ๊ทœ์น™ ์„ค๋ช…ํ•ด์ค˜'], ['ํ’‹์‚ด ๊ฒฝ๊ธฐ ์‹œ๊ฐ„ ์•Œ๋ ค์ค˜']]
demo = gr.ChatInterface(
fn=talk,
chatbot=gr.Chatbot(
show_label=True,
show_share_button=True,
show_copy_button=True,
likeable=True,
layout="bubble",
bubble_full_width=False,
),
theme="Soft",
examples=[["what's anarchy ? "]],
title=TITLE,
description=DESCRIPTION,
examples=Examples
)
demo.launch(debug=True)
# if __name__ == "__main__":
# demo.launch()