Spaces:
Sleeping
Sleeping
File size: 7,657 Bytes
d4e1ed9 68d4a44 d4e1ed9 ff62d4f d4e1ed9 ff62d4f d4e1ed9 ff62d4f d4e1ed9 d18bd01 5f0033b ff62d4f d4e1ed9 ff62d4f e09ca8b d4e1ed9 d881a0d dc0fedf d881a0d dc0fedf d881a0d dc0fedf d881a0d dc0fedf d881a0d dc0fedf d881a0d dc0fedf d881a0d dc0fedf d881a0d dc0fedf d881a0d dc0fedf d881a0d dc0fedf d881a0d dc0fedf d881a0d dc0fedf d881a0d dc0fedf d4e1ed9 dc0fedf d881a0d e56e479 d881a0d e56e479 d881a0d dc0fedf d881a0d dc0fedf d4e1ed9 a10cd56 d18bd01 4a08cd6 30f47d5 a10cd56 1ec4295 4a08cd6 d4e1ed9 30f47d5 d4e1ed9 1ec4295 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
import gradio as gr
from huggingface_hub import InferenceClient
"""
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
"""
client = InferenceClient("Trinoid/Data_Management")
def respond(
message,
history: list[tuple[str, str]],
system_message,
max_tokens,
temperature,
top_p,
):
messages = [{"role": "system", "content": system_message}]
for val in history:
if val[0]:
messages.append({"role": "user", "content": val[0]})
if val[1]:
messages.append({"role": "assistant", "content": val[1]})
messages.append({"role": "user", "content": message})
response = ""
thinking_process = []
# Use chat completion instead of text generation
for message in client.chat_completion(
messages,
max_tokens=max_tokens,
stream=True,
temperature=temperature,
top_p=top_p,
):
token = message.choices[0].delta.content
if token:
response += token
yield response
# Custom CSS for Plant Wisdom.AI styling
custom_css = """
.gradio-container {
font-family: 'Source Sans Pro', 'Helvetica Neue', Arial, sans-serif;
max-width: 1000px;
margin: 0 auto;
background-color: #ffffff;
}
.contain {
background-color: #ffffff;
border-radius: 12px;
box-shadow: 0 4px 6px rgba(0,0,0,0.05);
padding: 20px;
}
.message {
padding: 16px 20px;
border-radius: 12px;
margin: 12px 0;
font-size: 16px;
line-height: 1.5;
}
.message.user {
background-color: #f5f7fa;
margin-left: 15%;
border: 1px solid #e8eef7;
}
.message.assistant {
background-color: #f0f7f0;
margin-right: 15%;
border: 1px solid #e0ede0;
color: #2c3338;
}
.submit-btn {
background-color: #2e7d32 !important;
color: white !important;
border-radius: 8px !important;
padding: 12px 24px !important;
font-weight: 600 !important;
font-size: 16px !important;
transition: all 0.3s ease !important;
border: none !important;
}
.submit-btn:hover {
background-color: #1b5e20 !important;
transform: translateY(-1px) !important;
box-shadow: 0 4px 8px rgba(0,0,0,0.1) !important;
}
.submit-btn:active {
transform: translateY(0) !important;
}
.slider-container {
background-color: #f8faf8;
padding: 20px;
border-radius: 12px;
margin: 12px 0;
border: 1px solid #e0ede0;
}
.textbox {
border: 2px solid #e0ede0 !important;
border-radius: 8px !important;
padding: 12px !important;
font-size: 16px !important;
transition: all 0.3s ease !important;
background-color: #ffffff !important;
}
.textbox:focus {
border-color: #2e7d32 !important;
outline: none !important;
box-shadow: 0 0 0 3px rgba(46,125,50,0.1) !important;
}
.title {
color: #2c3338 !important;
font-size: 32px !important;
font-weight: 700 !important;
margin-bottom: 16px !important;
}
.description {
color: #505a62 !important;
font-size: 18px !important;
line-height: 1.6 !important;
margin-bottom: 24px !important;
}
.additional-inputs {
background-color: #f8faf8;
border: 1px solid #e0ede0;
border-radius: 12px;
padding: 20px;
margin-top: 24px;
}
.chatbot {
height: 600px !important;
border: 1px solid #e0ede0;
border-radius: 12px;
background-color: #ffffff;
}
"""
"""
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
"""
demo = gr.ChatInterface(
respond,
title="AI Data Management Expert",
description="Hello! I am your Data Management Expert, specialized in Microsoft 365. I'm here to help you with guidance on Data Management procedures. How can I assist you today?",
theme=gr.themes.Base(
primary_hue=gr.themes.Color(
c50="#f3f7f3",
c100="#e0ede0",
c200="#b5d4b5",
c300="#8abb8a",
c400="#5fa25f",
c500="#2e7d32",
c600="#1b5e20",
c700="#154a19",
c800="#0e3511",
c900="#082108",
c950="#041104"
),
secondary_hue=gr.themes.Color(
c50="#f3f7f3",
c100="#e0ede0",
c200="#b5d4b5",
c300="#8abb8a",
c400="#5fa25f",
c500="#2e7d32",
c600="#1b5e20",
c700="#154a19",
c800="#0e3511",
c900="#082108",
c950="#041104"
),
neutral_hue="slate",
spacing_size="lg",
radius_size="lg",
font=["Source Sans Pro", "Helvetica Neue", "Arial", "sans-serif"],
),
css=custom_css,
additional_inputs=[
gr.Textbox(
value="""You are a specialized AI assistant made by Plant Wisdom.AI with deep knowledge of Microsoft 365 services—including SharePoint Online, OneDrive, Teams, Exchange, and the Microsoft Purview (Compliance) ecosystem—as well as general records management and data governance best practices.
Your primary objectives are:
Provide accurate, detailed, and practical answers about:
Microsoft 365's features, capabilities, and architecture.
Document and records management (e.g., retention labels, policies, disposition reviews).
Compliance and information governance (e.g., data loss prevention, eDiscovery, retention schedules).
SharePoint Online configuration, site management, and usage best practices.
Integration points across Microsoft 365 (Teams, Outlook, Power Platform, etc.).
Address user questions in a clear, direct manner without simply directing them to official documentation. Instead, share concise explanations and relevant examples.
When applicable, highlight best practices, common pitfalls, and recommended solutions based on real-world usage.
If you are not certain about an answer or lack enough context, say so clearly rather than guess.
Tone and Style:
Strive for clarity and helpfulness; avoid excessive jargon.
Avoid generic references like "refer to the documentation." Instead, explain or paraphrase relevant information whenever possible.
Cite Microsoft's recommended or well-known practices when beneficial, but do so in your own words.
Keep responses concise yet sufficiently detailed.
Additional Guidelines:
Where necessary, provide step-by-step instructions for configurations or troubleshooting.
Distinguish between official Microsoft 365 functionalities and custom solutions or third-party tools.
If the user's request includes advanced or niche scenarios, do your best to provide an overview, while acknowledging any areas that may require deeper research.
Maintain professionalism in all responses; be polite, solution-focused, and proactive.
Follow any privacy or ethical guidelines, and do not disclose personally identifiable information about real people.
IMPORTANT: If a question has been asked before in the conversation, acknowledge this and either refer back to the previous answer or provide additional context. Do not simply repeat the same answer verbatim.""",
label="System message"
),
gr.Slider(minimum=1, maximum=2048, value=1200, step=1, label="Max new tokens"),
gr.Slider(minimum=0.1, maximum=2.0, value=0.4, step=0.1, label="Temperature"),
gr.Slider(
minimum=0.1,
maximum=1.0,
value=0.7,
step=0.05,
label="Top-p (nucleus sampling)",
),
],
)
if __name__ == "__main__":
demo.launch(server_name="0.0.0.0")
|