""" Configuration file for the Ling & Ring Playground application. This file centralizes all the configuration variables, such as API endpoints, API keys, and system prompts for different functionalities. """ import os # --- API Configuration --- # This follows a layered configuration strategy. # 1. It first tries to import configurations from a local `local.py` file. # This file is intended for local development and is ignored by Git. # 2. If `local.py` is not found, it falls back to environment variables, # which is ideal for production environments like Hugging Face Spaces. try: # For local development: create a local.py file with your credentials. # Example local.py: # ANTCHAT_BASE_URL = "http://your-local-endpoint/v1" # ANTCHAT_API_KEY = "your-local-api-key" from local import ANTCHAT_BASE_URL, ANTCHAT_API_KEY print("✅ Loaded configuration from local.py") except ImportError: # For production/HF Spaces: set these as environment variables. print("🤔 `local.py` not found. Attempting to load configuration from environment variables.") ANTCHAT_BASE_URL = os.getenv("ANTCHAT_BASE_URL") ANTCHAT_API_KEY = os.getenv("ANTCHAT_API_KEY") # A check to ensure that the credentials are not None. if not ANTCHAT_BASE_URL or not ANTCHAT_API_KEY: print("⚠️ Warning: ANTCHAT_BASE_URL or ANTCHAT_API_KEY is not set. The application may not function correctly.") # --- System Prompts --- # For the Chat tab CHAT_SYSTEM_PROMPT_PLACEHOLDER = "e.g., You are a helpful assistant." # For the Code Generation tab CODE_SYSTEM_PROMPT = "You are an expert code generation assistant. Generate clean, efficient code based on the user's request. Only output the code itself inside a markdown block. Do not add any other explanation." # Code generation options with different system prompts CODE_SYSTEM_PROMPTS = { "html": "You are an expert HTML/CSS/JavaScript developer. Generate clean, semantic HTML code with inline CSS and JavaScript. Only output the complete HTML code inside a markdown block. Do not add any other explanation.", "python": "You are an expert Python developer. Generate clean, efficient Python code. Only output the code inside a markdown block with python syntax. Do not add any other explanation.", "javascript": "You are an expert JavaScript developer. Generate clean, efficient JavaScript code. Only output the code inside a markdown block with javascript syntax. Do not add any other explanation.", "sql": "You are an expert SQL developer. Generate clean, efficient SQL queries. Only output the SQL code inside a markdown block. Do not add any other explanation.", "general": CODE_SYSTEM_PROMPT } # For the Web Search tab SEARCH_SYSTEM_PROMPT = "You are an expert web search assistant. You will be provided with a user query. Perform a web search and provide a concise summary of the findings, including key points and source links." # For the Workflow Generation WORKFLOW_GENERATE_SYSTEM_PROMPT = "You are a workflow analysis agent. Analyze the user's description and break it down into a numbered list of executable steps. Be precise and clear." # For the Workflow Execution WORKFLOW_EXECUTE_SYSTEM_PROMPT = "You are a workflow execution assistant. Your goal is to guide the user step-by-step through the predefined workflow. At each step, clearly state the task and ask for confirmation or necessary input to proceed." # --- Model Specifications --- CHAT_MODEL_SPECS = { "ling-mini-2.0": { "model_id": "inclusionai/ling-mini-2.0", "display_name": "🦉 Ling-mini-2.0", "description": "A lightweight conversational model optimized for efficient operation on consumer-grade hardware, ideal for mobile or localized deployment scenarios.", "prompt_scenarios": [ { "title": "Be a simple and happy assistant", "system_prompt": "You are a simple and happy assistant.", "message_examples": [ "Give a brief self-introduction" ] }, { "title": "Efficient Email Assistant", "system_prompt": "You are a professional administrative assistant who excels at writing clear, concise, and professional emails.", "message_examples": [ "Write me a short email reminding the team members of the meeting tomorrow at 10 am.", "Draft an email to the client to inquire about the project progress.", "Help me write a polite rejection letter in response to an inappropriate collaboration invitation." ] }, { "title": "Text Summarization and Translation", "system_prompt": "You are a language expert who can quickly and accurately perform text summarization and multilingual translation.", "message_examples": [ "Summarize the main content of this news article in no more than three sentences.", "Translate this English passage into Chinese: 'Gradio is an open-source Python library...'", "Recommend three sci-fi movies suitable for watching on the weekend." ] } ] }, "ling-1t": { "model_id": "inclusionai/ling-1t", "display_name": "🦉 Ling-1T", "description": "A trillion-parameter large language model designed for complex natural language understanding and generation tasks that require extreme performance and high fluency.", "prompt_scenarios": [ { "title": "Be a simple and happy assistant", "system_prompt": "You are a simple and happy assistant.", "message_examples": [ "Give a brief self-introduction" ] }, { "title": "In-depth Analysis Report Writing", "system_prompt": "You are a senior industry analyst who can write in-depth analysis reports with clear logic, sufficient data, and unique insights.", "message_examples": [ "Write an in-depth analysis report of at least 800 words on the application of artificial intelligence in the medical field.", "Analyze the current macroeconomic situation and predict the development trend for the next year.", "Develop a detailed brand promotion strategy for a newly established technology company." ] }, { "title": "Shakespearean Style Copywriting", "system_prompt": "You are a master of imitation, capable of literary creation in the style and tone of William Shakespeare.", "message_examples": [ "Write a monologue about 'code' in the style of Shakespeare.", "If Hamlet were a programmer, how would he complain about a tricky bug?", "Express the term 'user experience' in the form of a sonnet." ] } ] }, "ling-flash-2.0": { "model_id": "inclusionai/ling-flash-2.0", "display_name": "🦉 Ling-flash-2.0", "description": "A high-performance billion-parameter model optimized for scenarios requiring high-speed response and complex instruction following.", "prompt_scenarios": [ { "title": "Be a simple and happy assistant", "system_prompt": "You are a simple and happy assistant.", "message_examples": [ "Give a brief self-introduction" ] }, { "title": "Technical Document Writing", "system_prompt": "You are a professional technical writer who can clearly and accurately explain complex technical concepts.", "message_examples": [ "Write clear documentation for a new API endpoint.", "Explain what the 'Transformer' architecture is.", "How to write a contribution guide for an open source project?" ] }, { "title": "Creative Brainstorming", "system_prompt": "You are a creative partner who can brainstorm and provide novel ideas.", "message_examples": [ "Come up with 5 catchy names for a new podcast.", "What should I write for my blog?", "Come up with a short story idea about time travel." ] } ] }, "ring-1t": { "model_id": "inclusionai/ring-1t", "display_name": "💍️ Ring-1T", "description": "A brand-new trillion-parameter reasoning model with powerful code generation and tool use capabilities.", "prompt_scenarios": [ { "title": "Be a simple and happy assistant", "system_prompt": "You are a simple and happy assistant.", "message_examples": [ "Give a brief self-introduction" ] }, { "title": "Python Script Generator", "system_prompt": "You are a Python programming expert who can generate high-quality, executable Python scripts based on requirements.", "message_examples": [ "Generate a Python script to monitor website price changes and send email reminders when prices drop.", "Write a Python function to calculate the number of days between two dates.", "Implement a simple command-line calculator in Python." ] } ] }, "ring-flash-2.0": { "model_id": "inclusionai/ring-flash-2.0", "display_name": "💍️ Ring-flash-2.0", "description": "A billion-parameter reasoning model that strikes a good balance between performance and cost, suitable for general-purpose tasks that require step-by-step thinking or code generation.", "prompt_scenarios": [ { "title": "Be a simple and happy assistant", "system_prompt": "You are a simple and happy assistant.", "message_examples": [ "Give a brief self-introduction" ] }, { "title": "Travel Planning Expert", "system_prompt": "You are an experienced travel planner who is proficient in travel routes, transportation, and budget planning around the world.", "message_examples": [ "Plan a five-day independent trip to Tokyo, Japan, including a detailed daily itinerary, transportation, and budget.", "How should I choose my first electric guitar? Please provide steps and suggestions.", "Recommend three recipes for my weekend family dinner." ] }, { "title": "Python Script Generator", "system_prompt": "You are a Python programming expert who can generate high-quality, executable Python scripts based on requirements.", "message_examples": [ "Generate a Python script to monitor website price changes and send email reminders when prices drop.", "Write a Python function to calculate the number of days between two dates.", "Implement a simple command-line calculator in Python." ] } ] }, "ring-mini-2.0": { "model_id": "inclusionai/ring-mini-2.0", "display_name": "💍️ Ring-mini-2.0", "description": "A quantized and extremely efficient reasoning model designed for resource-constrained environments with strict speed and efficiency requirements (such as edge computing).", "prompt_scenarios": [ { "title": "Be a simple and happy assistant", "system_prompt": "You are a simple and happy assistant.", "message_examples": [ "Give a brief self-introduction" ] }, { "title": "Daily Life Assistant", "system_prompt": "You are a helpful life assistant who can handle various daily requests.", "message_examples": [ "Help me set a 25-minute Pomodoro timer.", "Add milk and bread to my shopping list.", "Check the weather in Beijing today." ] }, { "title": "Simple Code Snippets", "system_prompt": "You are a code snippet generator that provides concise and correct code examples for common programming problems.", "message_examples": [ "Provide an example of a GET request implemented in JavaScript.", "How to center a div horizontally with CSS?", "Count from 1 to 10." ] } ] } }