Spaces:
Running
Running
refine
Browse files
app.py
CHANGED
|
@@ -3,276 +3,149 @@ from datetime import date
|
|
| 3 |
import gradio as gr
|
| 4 |
import openai
|
| 5 |
|
|
|
|
| 6 |
MODEL_CONFIGS = {
|
| 7 |
-
"
|
| 8 |
"model_id": "tiiuae/Falcon-H1-34B-Instruct",
|
| 9 |
"api_key_env": "XXL_API_KEY",
|
| 10 |
"base_url_env": "XXL_URL",
|
| 11 |
},
|
| 12 |
-
"
|
| 13 |
"model_id": "tiiuae/Falcon-H1-7B-Instruct",
|
| 14 |
"api_key_env": "L_API_KEY",
|
| 15 |
"base_url_env": "L_URL",
|
| 16 |
},
|
| 17 |
-
"
|
| 18 |
"model_id": "tiiuae/Falcon-H1-3B-Instruct",
|
| 19 |
"api_key_env": "M_API_KEY",
|
| 20 |
"base_url_env": "M_URL",
|
| 21 |
},
|
| 22 |
-
"
|
| 23 |
"model_id": "tiiuae/Falcon-H1-1.5B-Deep-Instruct",
|
| 24 |
"api_key_env": "S_API_KEY",
|
| 25 |
"base_url_env": "S_URL",
|
| 26 |
},
|
| 27 |
-
"
|
| 28 |
"model_id": "tiiuae/Falcon-H1-1.5B-Instruct",
|
| 29 |
"api_key_env": "XS_API_KEY",
|
| 30 |
"base_url_env": "XS_URL",
|
| 31 |
},
|
| 32 |
-
"
|
| 33 |
"model_id": "tiiuae/Falcon-H1-0.5B-Instruct",
|
| 34 |
"api_key_env": "XXS_API_KEY",
|
| 35 |
"base_url_env": "XXS_URL",
|
| 36 |
},
|
| 37 |
}
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
# Enhanced Titles
|
| 42 |
-
TITLE_HTML = "<h1 style='text-align: center; color: #6d28d9; margin-top: 1rem; margin-bottom: 0.5rem;'>✨ Private Multi-Backend Playground ✨</h1>" # A slightly deeper purple for prominent title
|
| 43 |
-
SUB_TITLE_HTML = "<p style='text-align: center; color: #52525b; margin-bottom: 1.5rem;'>Keys & endpoints stay server-side; the browser never sees them.</p>"
|
| 44 |
-
|
| 45 |
-
# Enhanced CSS for a light purple theme
|
| 46 |
CSS = """
|
| 47 |
-
body,
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
--button-primary-background-fill: var(--primary-400) !important;
|
| 61 |
-
--button-primary-background-fill-hover: var(--primary-500) !important;
|
| 62 |
-
--button-primary-text-color: white !important;
|
| 63 |
-
|
| 64 |
-
--body-background-fill: linear-gradient(to bottom right, #f5f3ff, #ede9fe); /* Subtle gradient background */
|
| 65 |
-
}
|
| 66 |
-
|
| 67 |
-
.duplicate-button {
|
| 68 |
-
margin: auto !important;
|
| 69 |
-
color: #fff !important;
|
| 70 |
-
background: #333 !important; /* Dark grey instead of pure black for a softer look */
|
| 71 |
-
border-radius: 100vh !important;
|
| 72 |
-
border: none !important;
|
| 73 |
-
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
| 74 |
-
}
|
| 75 |
-
.duplicate-button:hover {
|
| 76 |
-
background: #444 !important;
|
| 77 |
-
}
|
| 78 |
-
|
| 79 |
-
/* Accordion styling for parameters */
|
| 80 |
-
.gradio-accordion {
|
| 81 |
-
border-radius: 8px !important;
|
| 82 |
-
border: 1px solid var(--primary-200) !important;
|
| 83 |
-
box-shadow: 0 1px 3px rgba(0,0,0,0.05);
|
| 84 |
-
}
|
| 85 |
-
.gradio-accordion > .accordion-header {
|
| 86 |
-
background-color: var(--primary-100) !important;
|
| 87 |
-
color: var(--primary-700) !important;
|
| 88 |
-
border-bottom: 1px solid var(--primary-200) !important;
|
| 89 |
-
font-weight: 600;
|
| 90 |
-
}
|
| 91 |
-
.gradio-accordion > .accordion-header:hover {
|
| 92 |
-
background-color: var(--primary-200) !important;
|
| 93 |
-
}
|
| 94 |
-
.gradio-accordion > div > .gradio-html.component.min { /* Accordion arrow icon */
|
| 95 |
-
color: var(--primary-700) !important;
|
| 96 |
-
}
|
| 97 |
-
|
| 98 |
-
/* Chat interface specific styling */
|
| 99 |
-
.gradio-chatinterface-input-box { /* The container for textbox and buttons */
|
| 100 |
-
background-color: #ffffff !important;
|
| 101 |
-
border-top: 1px solid var(--primary-200) !important;
|
| 102 |
-
padding: 10px !important;
|
| 103 |
-
}
|
| 104 |
-
.gradio-chatbot { /* The main chat display area */
|
| 105 |
-
background-color: #ffffff !important;
|
| 106 |
-
border-radius: 8px;
|
| 107 |
-
box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
|
| 108 |
-
}
|
| 109 |
-
|
| 110 |
-
/* Chat bubble styling */
|
| 111 |
-
.message-bubble-user {
|
| 112 |
-
background: var(--primary-400) !important;
|
| 113 |
-
color: white !important;
|
| 114 |
-
border-radius: 18px 18px 5px 18px !important;
|
| 115 |
-
padding: 10px 15px !important;
|
| 116 |
-
box-shadow: 0 1px 2px rgba(0,0,0,0.1);
|
| 117 |
-
}
|
| 118 |
-
.message-bubble-bot {
|
| 119 |
-
background: var(--neutral-100) !important; /* Using a neutral color from the 'soft' theme */
|
| 120 |
-
color: var(--neutral-800) !important;
|
| 121 |
-
border: 1px solid var(--neutral-200) !important;
|
| 122 |
-
border-radius: 18px 18px 18px 5px !important;
|
| 123 |
-
padding: 10px 15px !important;
|
| 124 |
-
box-shadow: 0 1px 2px rgba(0,0,0,0.05);
|
| 125 |
-
}
|
| 126 |
-
|
| 127 |
-
/* Styling for sliders and dropdowns within the accordion */
|
| 128 |
-
.gradio-accordion .gradio-slider label span,
|
| 129 |
-
.gradio-accordion .gradio-dropdown label span {
|
| 130 |
-
color: var(--primary-700) !important;
|
| 131 |
-
font-size: 0.95em;
|
| 132 |
-
font-weight: 500;
|
| 133 |
-
}
|
| 134 |
-
.gradio-accordion .gradio-slider input[type=range]::-webkit-slider-thumb {
|
| 135 |
-
background: var(--primary-500) !important;
|
| 136 |
-
border: 2px solid white !important; /* Add a border to the thumb */
|
| 137 |
-
box-shadow: 0 1px 2px rgba(0,0,0,0.15);
|
| 138 |
-
}
|
| 139 |
-
.gradio-accordion .gradio-slider input[type=range]::-moz-range-thumb {
|
| 140 |
-
background: var(--primary-500) !important;
|
| 141 |
-
border: 2px solid white !important;
|
| 142 |
-
box-shadow: 0 1px 2px rgba(0,0,0,0.15);
|
| 143 |
-
}
|
| 144 |
-
.gradio-accordion .gradio-dropdown .multiselect__tags {
|
| 145 |
-
border: 1px solid var(--primary-300) !important;
|
| 146 |
-
background: white !important;
|
| 147 |
-
}
|
| 148 |
-
.gradio-accordion .gradio-dropdown .multiselect__option--selected {
|
| 149 |
-
background: var(--primary-500) !important;
|
| 150 |
-
color: white !important;
|
| 151 |
-
}
|
| 152 |
-
.gradio-accordion .gradio-dropdown .multiselect__option--highlight {
|
| 153 |
-
background: var(--primary-200) !important;
|
| 154 |
-
color: var(--primary-700) !important;
|
| 155 |
-
}
|
| 156 |
-
.gradio-accordion .gradio-dropdown .multiselect__input::placeholder {
|
| 157 |
-
color: var(--neutral-400);
|
| 158 |
-
}
|
| 159 |
-
|
| 160 |
-
/* Making sure the Parameters section title is clear */
|
| 161 |
-
.gradio-accordion > .accordion-header > .label-wrap > span {
|
| 162 |
-
font-size: 1.1em !important;
|
| 163 |
-
}
|
| 164 |
"""
|
| 165 |
|
|
|
|
| 166 |
def stream_chat(
|
| 167 |
-
message
|
| 168 |
-
|
| 169 |
-
model_label: str,
|
| 170 |
-
temperature: float = 0.7,
|
| 171 |
-
max_new_tokens: int = 1024,
|
| 172 |
-
top_p: float = 1.0,
|
| 173 |
-
# top_k: int = 20, # top_k was defined but not used in client.chat.completions.create
|
| 174 |
-
penalty: float = 1.2,
|
| 175 |
):
|
| 176 |
-
cfg = MODEL_CONFIGS[
|
| 177 |
api_key = os.getenv(cfg["api_key_env"])
|
| 178 |
-
base_url = os.getenv(cfg.get("base_url_env", ""), None)
|
| 179 |
-
|
| 180 |
if not api_key:
|
| 181 |
-
yield f"❌
|
| 182 |
return
|
| 183 |
-
|
| 184 |
-
yield f"❌ Endpoint URL Error: Environment variable {cfg['base_url_env']} not set."
|
| 185 |
-
return
|
| 186 |
-
|
| 187 |
client = openai.OpenAI(api_key=api_key, base_url=base_url)
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
|
|
|
| 192 |
|
| 193 |
try:
|
| 194 |
stream = client.chat.completions.create(
|
| 195 |
-
model=cfg["model_id"],
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
top_p=top_p,
|
| 199 |
-
max_tokens=max_new_tokens,
|
| 200 |
-
presence_penalty=penalty,
|
| 201 |
-
# top_k was not a standard OpenAI API parameter for chat completions,
|
| 202 |
-
# it's often used in other models or sampling strategies.
|
| 203 |
-
# If your backend supports it, you might need to pass it differently.
|
| 204 |
stream=True,
|
| 205 |
)
|
| 206 |
partial = ""
|
| 207 |
for chunk in stream:
|
| 208 |
-
|
|
|
|
| 209 |
partial += delta.content
|
| 210 |
yield partial
|
| 211 |
-
except openai.APIConnectionError as e:
|
| 212 |
-
yield f"❌ API Connection Error: {e}"
|
| 213 |
-
except openai.RateLimitError as e:
|
| 214 |
-
yield f"❌ Rate Limit Exceeded: {e}"
|
| 215 |
-
except openai.APIStatusError as e:
|
| 216 |
-
yield f"❌ API Status Error: {e.status_code} - {e.response.text}"
|
| 217 |
except Exception as e:
|
| 218 |
-
yield f"❌
|
| 219 |
-
|
| 220 |
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
avatar_images=(None, "https://img.icons8.com/fluency/96/chatbot.png") # Example bot avatar
|
| 225 |
-
)
|
| 226 |
|
| 227 |
with gr.Blocks(css=CSS, theme="soft") as demo:
|
| 228 |
-
|
| 229 |
-
gr.
|
| 230 |
-
gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
additional_inputs=[
|
| 238 |
-
gr.Dropdown(
|
| 239 |
choices=list(MODEL_CONFIGS.keys()),
|
| 240 |
-
value=
|
| 241 |
-
|
| 242 |
-
)
|
| 243 |
-
|
| 244 |
-
gr.
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
],
|
| 253 |
-
cache_examples=False,
|
| 254 |
-
retry_btn="🔄 Retry",
|
| 255 |
-
undo_btn="↩️ Undo",
|
| 256 |
-
clear_btn="🗑️ Clear",
|
| 257 |
-
submit_btn="💬 Send",
|
| 258 |
-
autofocus=True,
|
| 259 |
)
|
| 260 |
|
| 261 |
if __name__ == "__main__":
|
| 262 |
-
|
| 263 |
-
# Example (do not commit real keys to code):
|
| 264 |
-
# os.environ["XXL_API_KEY"] = "your_xxl_api_key_here"
|
| 265 |
-
# os.environ["XXL_URL"] = "your_xxl_url_here"
|
| 266 |
-
# ... and so on for other models if you intend to test them.
|
| 267 |
-
|
| 268 |
-
# Check if at least one model has its API key set for a better startup experience
|
| 269 |
-
is_any_model_configured = any(
|
| 270 |
-
os.getenv(MODEL_CONFIGS[model_key]["api_key_env"]) for model_key in MODEL_CONFIGS
|
| 271 |
-
)
|
| 272 |
-
if not is_any_model_configured and MODEL_CONFIGS:
|
| 273 |
-
first_model_key_env = MODEL_CONFIGS[list(MODEL_CONFIGS.keys())[0]]["api_key_env"]
|
| 274 |
-
print(f"Warning: No model API keys seem to be set. Set environment variables like '{first_model_key_env}'.")
|
| 275 |
-
elif not MODEL_CONFIGS:
|
| 276 |
-
print("Warning: MODEL_CONFIGS is empty. No models to select.")
|
| 277 |
-
|
| 278 |
-
demo.launch()
|
|
|
|
| 3 |
import gradio as gr
|
| 4 |
import openai
|
| 5 |
|
| 6 |
+
# ----------------------- Model registry -----------------------
|
| 7 |
MODEL_CONFIGS = {
|
| 8 |
+
"34B": { # keys are what you show in the dropdown
|
| 9 |
"model_id": "tiiuae/Falcon-H1-34B-Instruct",
|
| 10 |
"api_key_env": "XXL_API_KEY",
|
| 11 |
"base_url_env": "XXL_URL",
|
| 12 |
},
|
| 13 |
+
"7B": {
|
| 14 |
"model_id": "tiiuae/Falcon-H1-7B-Instruct",
|
| 15 |
"api_key_env": "L_API_KEY",
|
| 16 |
"base_url_env": "L_URL",
|
| 17 |
},
|
| 18 |
+
"3B": {
|
| 19 |
"model_id": "tiiuae/Falcon-H1-3B-Instruct",
|
| 20 |
"api_key_env": "M_API_KEY",
|
| 21 |
"base_url_env": "M_URL",
|
| 22 |
},
|
| 23 |
+
"1.5B-Deep": {
|
| 24 |
"model_id": "tiiuae/Falcon-H1-1.5B-Deep-Instruct",
|
| 25 |
"api_key_env": "S_API_KEY",
|
| 26 |
"base_url_env": "S_URL",
|
| 27 |
},
|
| 28 |
+
"1.5B": {
|
| 29 |
"model_id": "tiiuae/Falcon-H1-1.5B-Instruct",
|
| 30 |
"api_key_env": "XS_API_KEY",
|
| 31 |
"base_url_env": "XS_URL",
|
| 32 |
},
|
| 33 |
+
"0.5B": {
|
| 34 |
"model_id": "tiiuae/Falcon-H1-0.5B-Instruct",
|
| 35 |
"api_key_env": "XXS_API_KEY",
|
| 36 |
"base_url_env": "XXS_URL",
|
| 37 |
},
|
| 38 |
}
|
| 39 |
|
| 40 |
+
# ----------------------- CSS -----------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
CSS = """
|
| 42 |
+
body{font-family:'Inter',sans-serif;}
|
| 43 |
+
h1{font-size:32px;font-weight:700;margin:12px 0;text-align:center;color:#12233d}
|
| 44 |
+
.subtitle{text-align:center;color:#4b5563;font-size:14px;margin-top:-6px}
|
| 45 |
+
.section-label{display:inline-block;background:#e2e8f9;color:#5b6bce;
|
| 46 |
+
font-size:12px;font-weight:600;padding:2px 8px;border-radius:6px}
|
| 47 |
+
.card{border:1px solid #e5e7eb;border-radius:8px;padding:8px;margin-bottom:12px}
|
| 48 |
+
#refresh-btn{width:100%;height:42px;font-weight:600;
|
| 49 |
+
background:#ffffff;border:1px solid #e5e7eb;border-radius:8px}
|
| 50 |
+
#refresh-btn:hover{background:#f9fafb}
|
| 51 |
+
.gr-chatbot-message{background:#ffffff;border:1px solid #e5e7eb;
|
| 52 |
+
border-radius:6px;padding:8px;font-size:14px}
|
| 53 |
+
.gr-user-message{background:#edf2ff;border:1px solid #dbe4ff;}
|
| 54 |
+
.gradio-button.primary{background:#6262f2 !important;color:#fff !important}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
"""
|
| 56 |
|
| 57 |
+
# ----------------------- Chat backend -----------------------
|
| 58 |
def stream_chat(
|
| 59 |
+
message, history, model_key, temperature=0.7, max_new_tokens=1024,
|
| 60 |
+
top_p=1.0, presence_penalty=1.2,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
):
|
| 62 |
+
cfg = MODEL_CONFIGS[model_key]
|
| 63 |
api_key = os.getenv(cfg["api_key_env"])
|
|
|
|
|
|
|
| 64 |
if not api_key:
|
| 65 |
+
yield f"❌ `{cfg['api_key_env']}` env-var missing."
|
| 66 |
return
|
| 67 |
+
base_url = os.getenv(cfg["base_url_env"]) or None
|
|
|
|
|
|
|
|
|
|
| 68 |
client = openai.OpenAI(api_key=api_key, base_url=base_url)
|
| 69 |
+
|
| 70 |
+
messages = [
|
| 71 |
+
m for (u, a) in history
|
| 72 |
+
for m in ({"role":"user","content":u},{"role":"assistant","content":a})
|
| 73 |
+
] + [{"role":"user","content":message}]
|
| 74 |
|
| 75 |
try:
|
| 76 |
stream = client.chat.completions.create(
|
| 77 |
+
model=cfg["model_id"], messages=messages,
|
| 78 |
+
temperature=temperature, top_p=top_p,
|
| 79 |
+
max_tokens=max_new_tokens, presence_penalty=presence_penalty,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
stream=True,
|
| 81 |
)
|
| 82 |
partial = ""
|
| 83 |
for chunk in stream:
|
| 84 |
+
delta = chunk.choices[0].delta
|
| 85 |
+
if delta and delta.content:
|
| 86 |
partial += delta.content
|
| 87 |
yield partial
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
except Exception as e:
|
| 89 |
+
yield f"❌ Error: {e}"
|
|
|
|
| 90 |
|
| 91 |
+
# ----------------------- UI -----------------------
|
| 92 |
+
today = date.today()
|
| 93 |
+
default_model = list(MODEL_CONFIGS.keys())[0]
|
|
|
|
|
|
|
| 94 |
|
| 95 |
with gr.Blocks(css=CSS, theme="soft") as demo:
|
| 96 |
+
# Header
|
| 97 |
+
gr.Markdown("# Falcon-H1 Playground")
|
| 98 |
+
gr.HTML(
|
| 99 |
+
f"""<p class="subtitle">
|
| 100 |
+
Falcon-H1 is a new model by TII in Abu Dhabi. It is open source and
|
| 101 |
+
available on Hugging Face for research or application purposes.<br>
|
| 102 |
+
This playground connects to backend vLLM servers running different
|
| 103 |
+
Falcon-H1 checkpoints.
|
| 104 |
+
</p>"""
|
| 105 |
+
)
|
| 106 |
|
| 107 |
+
# Model row
|
| 108 |
+
with gr.Row(equal_height=False):
|
| 109 |
+
with gr.Column(scale=3):
|
| 110 |
+
gr.HTML('<span class="section-label">Select Falcon-H1 Model</span>')
|
| 111 |
+
model_dd = gr.Dropdown(
|
|
|
|
|
|
|
| 112 |
choices=list(MODEL_CONFIGS.keys()),
|
| 113 |
+
value=default_model,
|
| 114 |
+
show_label=False,
|
| 115 |
+
)
|
| 116 |
+
with gr.Column(scale=2):
|
| 117 |
+
refresh_btn = gr.Button("↻ Refresh Models", elem_id="refresh-btn")
|
| 118 |
+
|
| 119 |
+
# Status
|
| 120 |
+
gr.HTML('<span class="section-label">Status</span>')
|
| 121 |
+
status_box = gr.Textbox(value="Status: Done.", interactive=False, show_label=False)
|
| 122 |
+
|
| 123 |
+
# Chat
|
| 124 |
+
gr.HTML('<span class="section-label">Falcon-H1 Chat</span>')
|
| 125 |
+
chatbot = gr.Chatbot(height=520)
|
| 126 |
+
|
| 127 |
+
# Parameters accordion
|
| 128 |
+
with gr.Accordion("⚙️ Parameters", open=False):
|
| 129 |
+
temperature = gr.Slider(0,1,0.7,label="Temperature",step=0.05)
|
| 130 |
+
max_tokens = gr.Slider(64,4096*8,1024,label="Max new tokens",step=64)
|
| 131 |
+
top_p = gr.Slider(0,1,1,label="Top-p",step=0.05)
|
| 132 |
+
presence_pen = gr.Slider(0,2,1.2,label="Presence penalty",step=0.1)
|
| 133 |
+
|
| 134 |
+
# Examples bar (optional)
|
| 135 |
+
examples = [
|
| 136 |
+
"Hello there, can you suggest few places to visit in UAE?",
|
| 137 |
+
"What UAE is known for?",
|
| 138 |
+
"Write a short poem about the desert.",
|
| 139 |
+
"Translate 'Welcome to Abu Dhabi' into Arabic.",
|
| 140 |
+
]
|
| 141 |
+
gr.Examples(examples, chatbot)
|
| 142 |
+
|
| 143 |
+
# Chat interface wiring
|
| 144 |
+
gr.ChatInterface(
|
| 145 |
+
fn=stream_chat, chatbot=chatbot, additional_inputs=[
|
| 146 |
+
model_dd, temperature, max_tokens, top_p, presence_pen
|
| 147 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
)
|
| 149 |
|
| 150 |
if __name__ == "__main__":
|
| 151 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|