Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,21 +9,18 @@ def respond(
|
|
| 9 |
max_tokens,
|
| 10 |
temperature,
|
| 11 |
top_p,
|
| 12 |
-
hf_token: gr.OAuthToken,
|
| 13 |
):
|
| 14 |
"""
|
| 15 |
-
|
|
|
|
| 16 |
"""
|
| 17 |
-
client = InferenceClient(
|
| 18 |
|
| 19 |
messages = [{"role": "system", "content": system_message}]
|
| 20 |
-
|
| 21 |
messages.extend(history)
|
| 22 |
-
|
| 23 |
messages.append({"role": "user", "content": message})
|
| 24 |
|
| 25 |
response = ""
|
| 26 |
-
|
| 27 |
for message in client.chat_completion(
|
| 28 |
messages,
|
| 29 |
max_tokens=max_tokens,
|
|
@@ -40,9 +37,7 @@ def respond(
|
|
| 40 |
yield response
|
| 41 |
|
| 42 |
|
| 43 |
-
|
| 44 |
-
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
| 45 |
-
"""
|
| 46 |
chatbot = gr.ChatInterface(
|
| 47 |
respond,
|
| 48 |
type="messages",
|
|
@@ -60,11 +55,10 @@ chatbot = gr.ChatInterface(
|
|
| 60 |
],
|
| 61 |
)
|
| 62 |
|
|
|
|
| 63 |
with gr.Blocks() as demo:
|
| 64 |
-
|
| 65 |
-
gr.LoginButton()
|
| 66 |
chatbot.render()
|
| 67 |
|
| 68 |
-
|
| 69 |
if __name__ == "__main__":
|
| 70 |
-
demo.launch()
|
|
|
|
| 9 |
max_tokens,
|
| 10 |
temperature,
|
| 11 |
top_p,
|
|
|
|
| 12 |
):
|
| 13 |
"""
|
| 14 |
+
Public version of the chatbot — no OAuth required.
|
| 15 |
+
Uses Hugging Face's Inference API (requires the model to be public).
|
| 16 |
"""
|
| 17 |
+
client = InferenceClient(model="openai/gpt-oss-20b")
|
| 18 |
|
| 19 |
messages = [{"role": "system", "content": system_message}]
|
|
|
|
| 20 |
messages.extend(history)
|
|
|
|
| 21 |
messages.append({"role": "user", "content": message})
|
| 22 |
|
| 23 |
response = ""
|
|
|
|
| 24 |
for message in client.chat_completion(
|
| 25 |
messages,
|
| 26 |
max_tokens=max_tokens,
|
|
|
|
| 37 |
yield response
|
| 38 |
|
| 39 |
|
| 40 |
+
# Chatbot UI
|
|
|
|
|
|
|
| 41 |
chatbot = gr.ChatInterface(
|
| 42 |
respond,
|
| 43 |
type="messages",
|
|
|
|
| 55 |
],
|
| 56 |
)
|
| 57 |
|
| 58 |
+
# Public app (no login, no auth)
|
| 59 |
with gr.Blocks() as demo:
|
| 60 |
+
gr.Markdown("## 🤖 JoeyMerhej Public Chatbot\nNo login required — start chatting below!")
|
|
|
|
| 61 |
chatbot.render()
|
| 62 |
|
|
|
|
| 63 |
if __name__ == "__main__":
|
| 64 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|