Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -14,10 +14,10 @@ def respond(message, history: list[dict[str, str]]):
|
|
| 14 |
response = ""
|
| 15 |
for msg in client.chat_completion(
|
| 16 |
messages,
|
| 17 |
-
max_tokens=512,
|
| 18 |
stream=True,
|
| 19 |
-
temperature=0.7,
|
| 20 |
-
top_p=0.95
|
| 21 |
):
|
| 22 |
if msg.choices and msg.choices[0].delta.content:
|
| 23 |
response += msg.choices[0].delta.content
|
|
@@ -30,49 +30,10 @@ custom_css = """
|
|
| 30 |
background: linear-gradient(to bottom right, #7E498B, #f5f5f5);
|
| 31 |
font-family: 'Segoe UI', sans-serif;
|
| 32 |
}
|
| 33 |
-
|
| 34 |
-
.gradio-chatbox {
|
| 35 |
-
background-color: #ffffff;
|
| 36 |
-
border-radius: 16px;
|
| 37 |
-
padding: 12px;
|
| 38 |
-
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
| 39 |
-
}
|
| 40 |
-
|
| 41 |
-
.gradio-chatbox .message.user {
|
| 42 |
-
background-color: #7E498B;
|
| 43 |
-
color: #fff;
|
| 44 |
-
border-radius: 12px 12px 0 12px;
|
| 45 |
-
padding: 10px 14px;
|
| 46 |
-
margin: 6px 0;
|
| 47 |
-
max-width: 80%;
|
| 48 |
-
}
|
| 49 |
-
|
| 50 |
-
.gradio-chatbox .message.bot {
|
| 51 |
-
background-color: #f0f0f5;
|
| 52 |
-
color: #333;
|
| 53 |
-
border-radius: 12px 12px 12px 0;
|
| 54 |
-
padding: 10px 14px;
|
| 55 |
-
margin: 6px 0;
|
| 56 |
-
max-width: 80%;
|
| 57 |
-
}
|
| 58 |
-
|
| 59 |
-
input[type="text"] {
|
| 60 |
-
border-radius: 8px;
|
| 61 |
-
border: 1px solid #ccc;
|
| 62 |
-
padding: 8px 12px;
|
| 63 |
-
}
|
| 64 |
-
|
| 65 |
-
button {
|
| 66 |
-
background-color: #7E498B !important;
|
| 67 |
-
color: white !important;
|
| 68 |
-
border-radius: 8px !important;
|
| 69 |
-
font-weight: bold !important;
|
| 70 |
-
}
|
| 71 |
"""
|
| 72 |
|
| 73 |
with gr.Blocks(theme=gr.themes.Soft(), css=custom_css) as demo:
|
| 74 |
-
|
| 75 |
-
chatbot.render()
|
| 76 |
|
| 77 |
if __name__ == "__main__":
|
| 78 |
demo.launch(share=True)
|
|
|
|
| 14 |
response = ""
|
| 15 |
for msg in client.chat_completion(
|
| 16 |
messages,
|
| 17 |
+
max_tokens=512,
|
| 18 |
stream=True,
|
| 19 |
+
temperature=0.7,
|
| 20 |
+
top_p=0.95
|
| 21 |
):
|
| 22 |
if msg.choices and msg.choices[0].delta.content:
|
| 23 |
response += msg.choices[0].delta.content
|
|
|
|
| 30 |
background: linear-gradient(to bottom right, #7E498B, #f5f5f5);
|
| 31 |
font-family: 'Segoe UI', sans-serif;
|
| 32 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
"""
|
| 34 |
|
| 35 |
with gr.Blocks(theme=gr.themes.Soft(), css=custom_css) as demo:
|
| 36 |
+
gr.ChatInterface(respond, type="messages") # 👈 bas yehi kaafi hai, render() ki zaroorat nahi
|
|
|
|
| 37 |
|
| 38 |
if __name__ == "__main__":
|
| 39 |
demo.launch(share=True)
|