File size: 13,245 Bytes
a9fb7e9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3731531
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cb6eafc
a9fb7e9
cb6eafc
 
a9fb7e9
3731531
 
 
 
 
 
 
a9fb7e9
cb6eafc
 
a9fb7e9
cb6eafc
 
 
a9fb7e9
 
 
cb6eafc
 
a9fb7e9
cb6eafc
 
 
a9fb7e9
 
 
 
cb6eafc
a9fb7e9
cb6eafc
 
a9fb7e9
3731531
 
 
 
 
 
 
a9fb7e9
cb6eafc
 
a9fb7e9
cb6eafc
 
 
a9fb7e9
 
 
cb6eafc
 
a9fb7e9
cb6eafc
 
 
a9fb7e9
 
 
 
cb6eafc
 
 
 
a9fb7e9
3731531
 
 
 
 
 
 
a9fb7e9
cb6eafc
 
a9fb7e9
cb6eafc
 
 
 
 
 
 
 
 
 
 
 
3731531
 
 
 
 
 
 
cb6eafc
 
 
 
 
 
 
a9fb7e9
 
 
cb6eafc
 
a9fb7e9
cb6eafc
 
 
a9fb7e9
 
 
 
cb6eafc
a9fb7e9
cb6eafc
 
a9fb7e9
3731531
 
 
 
 
 
 
a9fb7e9
cb6eafc
 
a9fb7e9
cb6eafc
 
 
a9fb7e9
 
 
cb6eafc
 
a9fb7e9
cb6eafc
 
 
a9fb7e9
 
 
 
 
 
 
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
"""
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."
                ]
            }
        ]
    }
}