Spaces:
Sleeping
Sleeping
devin_lee commited on
Commit ·
333a04d
1
Parent(s): 15672e8
update app.py
Browse files
app.py
CHANGED
|
@@ -5,14 +5,21 @@ from outlines.models import openai
|
|
| 5 |
from outlines.generate import choice
|
| 6 |
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
)
|
| 15 |
-
|
|
|
|
|
|
|
| 16 |
|
| 17 |
def create_prompt_message(message: str) -> str:
|
| 18 |
return f"""
|
|
@@ -56,11 +63,15 @@ def inference(message:str)->str:
|
|
| 56 |
with gr.Blocks() as demo:
|
| 57 |
gr.Markdown("LLM訂位意圖分類器🍴🥂")
|
| 58 |
gr.Markdown("判斷輸入訊息是否與訂位有關")
|
|
|
|
|
|
|
|
|
|
| 59 |
with gr.Row():
|
| 60 |
inputs=gr.Textbox(placeholder="請輸入顧客訊息...", label="輸入訊息")
|
| 61 |
outputs=gr.Textbox(label="分類結果")
|
| 62 |
with gr.Row():
|
| 63 |
inference_btn = gr.Button("開始分類")
|
|
|
|
| 64 |
inference_btn.click(
|
| 65 |
fn=inference,
|
| 66 |
inputs=inputs,
|
|
|
|
| 5 |
from outlines.generate import choice
|
| 6 |
|
| 7 |
|
| 8 |
+
model_names = {
|
| 9 |
+
"Gemma-2B": "google/gemma-2b-it",
|
| 10 |
+
"Qwen2.5-7B": "Qwen/Qwen2.5-7B-Instruct-Turbo"
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
def load_classifier(model_key):
|
| 14 |
+
model_id = model_names[model_key]
|
| 15 |
+
model = openai(
|
| 16 |
+
model_id,
|
| 17 |
+
api_key=os.getenv("TOGETHER_AI_KEY"),
|
| 18 |
+
base_url="https://api.together.xyz/v1"
|
| 19 |
)
|
| 20 |
+
return choice(model, ["Reservation", "Others"])
|
| 21 |
+
|
| 22 |
+
classifier = load_classifier("Gemma 2B")
|
| 23 |
|
| 24 |
def create_prompt_message(message: str) -> str:
|
| 25 |
return f"""
|
|
|
|
| 63 |
with gr.Blocks() as demo:
|
| 64 |
gr.Markdown("LLM訂位意圖分類器🍴🥂")
|
| 65 |
gr.Markdown("判斷輸入訊息是否與訂位有關")
|
| 66 |
+
|
| 67 |
+
with gr.Row():
|
| 68 |
+
model_list = gr.Dropdown(choices=list(model_names.keys()), label="選擇模型", value="Gemma 2B")
|
| 69 |
with gr.Row():
|
| 70 |
inputs=gr.Textbox(placeholder="請輸入顧客訊息...", label="輸入訊息")
|
| 71 |
outputs=gr.Textbox(label="分類結果")
|
| 72 |
with gr.Row():
|
| 73 |
inference_btn = gr.Button("開始分類")
|
| 74 |
+
|
| 75 |
inference_btn.click(
|
| 76 |
fn=inference,
|
| 77 |
inputs=inputs,
|