eduard76 commited on
Commit
bef742f
·
verified ·
1 Parent(s): 48c0cf5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -0
app.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ import gradio as gr
3
+
4
+ # Load your HF model (must be on Hub)
5
+ pipe = pipeline("text-generation", model="eduard76/Llama3-8b-good-new", trust_remote_code=True)
6
+
7
+ def chat_fn(message, history):
8
+ full_input = "\n".join([f"User: {turn[0]}\nAI: {turn[1]}" for turn in history] + [f"User: {message}\nAI:"])
9
+ result = pipe(full_input, max_new_tokens=256, do_sample=True, temperature=0.7)
10
+ response = result[0]['generated_text'].split("AI:")[-1].strip()
11
+ return response
12
+
13
+ gr.ChatInterface(chat_fn, title="🤖 Chat with Eduard76's LLM").launch()