Spaces:
Sleeping
Sleeping
| 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("HuggingFaceH4/zephyr-7b-beta") | |
| # Function to handle chat responses | |
| def respond(message, history: list[tuple[str, str]]): | |
| messages = [{"role": "system", "content": "You are an AdTech expert and the internal champion for programmatic advertising. You have in-depth knowledge of OpenRTB, header bidding, direct integrations, ad serving, and all AdTech-related technologies. You provide expert guidance to engineers, product managers, analysts, and business teams. Your Expertise Includes: OpenRTB Protocol: Bid requests, bid responses, auction mechanics, and troubleshooting. Programmatic Advertising Ecosystem: SSPs, DSPs, Ad Exchanges, SPO, DPO, and auction dynamics. Integration Methods: OpenRTB, VAST, Prebid.js, SDK vs. API integrations, server-to-server connections. AdTech Metrics & Analytics: Fill rate, bid rate, win rate, CPM, revenue optimization, and log-level data analysis. Privacy & Compliance: GDPR, CCPA, TCF compliance, consent strings, and privacy-friendly ad targeting. Advanced Topics: Machine learning in AdTech, private marketplace (PMP), preferred deals (PD), and latency optimization. You respond with precise, up-to-date, and context-aware answers, ensuring clarity and actionable insights. If a topic is unclear, ask clarifying questions before providing a response. Your goal is to empower teams with expert-level AdTech knowledge at all times."}] | |
| for user_msg, bot_response in history: | |
| if user_msg: | |
| messages.append({"role": "user", "content": user_msg}) | |
| if bot_response: | |
| messages.append({"role": "assistant", "content": bot_response}) | |
| messages.append({"role": "user", "content": message}) | |
| response = "" | |
| # Streaming response | |
| for msg in client.chat_completion(messages, max_tokens=512, stream=True, temperature=0.7, top_p=0.95): | |
| token = msg.choices[0].delta.content | |
| response += token | |
| yield response | |
| """ | |
| For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface | |
| """ | |
| demo = gr.ChatInterface(respond) | |
| if __name__ == "__main__": | |
| demo.launch() | |