Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,8 +5,6 @@ from huggingface_hub import InferenceClient
|
|
| 5 |
def respond(
|
| 6 |
message,
|
| 7 |
history: list[dict[str, str]],
|
| 8 |
-
system_message,
|
| 9 |
-
max_tokens,
|
| 10 |
temperature,
|
| 11 |
top_p,
|
| 12 |
hf_token: gr.OAuthToken,
|
|
@@ -14,7 +12,18 @@ def respond(
|
|
| 14 |
"""
|
| 15 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
| 16 |
"""
|
| 17 |
-
client = InferenceClient(token=hf_token.token, model="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
messages = [{"role": "system", "content": system_message}]
|
| 20 |
|
|
@@ -26,7 +35,6 @@ def respond(
|
|
| 26 |
|
| 27 |
for message in client.chat_completion(
|
| 28 |
messages,
|
| 29 |
-
max_tokens=max_tokens,
|
| 30 |
stream=True,
|
| 31 |
temperature=temperature,
|
| 32 |
top_p=top_p,
|
|
@@ -47,8 +55,6 @@ chatbot = gr.ChatInterface(
|
|
| 47 |
respond,
|
| 48 |
type="messages",
|
| 49 |
additional_inputs=[
|
| 50 |
-
gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
| 51 |
-
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
| 52 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
| 53 |
gr.Slider(
|
| 54 |
minimum=0.1,
|
|
|
|
| 5 |
def respond(
|
| 6 |
message,
|
| 7 |
history: list[dict[str, str]],
|
|
|
|
|
|
|
| 8 |
temperature,
|
| 9 |
top_p,
|
| 10 |
hf_token: gr.OAuthToken,
|
|
|
|
| 12 |
"""
|
| 13 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
| 14 |
"""
|
| 15 |
+
client = InferenceClient(token=hf_token.token, model="meta-llama/Llama-3.2-1B-Instruct")
|
| 16 |
+
|
| 17 |
+
system_message = (
|
| 18 |
+
"You are a 'Perspective Engine'. Analyze the user's input from three distinct emotional and logical angles. "
|
| 19 |
+
"Output your response in this exact Markdown format:\n\n"
|
| 20 |
+
"### 🟢 The Optimist\n"
|
| 21 |
+
"(Write an enthusiastic, positive analysis here)\n\n"
|
| 22 |
+
"### 🔴 The Pessimist\n"
|
| 23 |
+
"(Write a critical, risk-focused analysis here)\n\n"
|
| 24 |
+
"### 🔵 The Realist\n"
|
| 25 |
+
"(Write a balanced, factual conclusion here)"
|
| 26 |
+
)
|
| 27 |
|
| 28 |
messages = [{"role": "system", "content": system_message}]
|
| 29 |
|
|
|
|
| 35 |
|
| 36 |
for message in client.chat_completion(
|
| 37 |
messages,
|
|
|
|
| 38 |
stream=True,
|
| 39 |
temperature=temperature,
|
| 40 |
top_p=top_p,
|
|
|
|
| 55 |
respond,
|
| 56 |
type="messages",
|
| 57 |
additional_inputs=[
|
|
|
|
|
|
|
| 58 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
| 59 |
gr.Slider(
|
| 60 |
minimum=0.1,
|