The Anevol Question Bank API provides a simple yet powerful interface for answering various types of questions, intelligent question generation, and essay grading. You can submit question content and options through the API to get answers, generate various exam questions, or submit essay content for professional grading suggestions.
All API requests require authentication. Please ensure you include your API Keys in the request.
You can provide API Keys in two ways:
X-API-Key: YOUR_API_KEY?token=YOUR_API_KEYPlease keep your API Keys secure and do not expose them in client-side code.
GET http://localhost:8888/api/search
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| title | string | Yes | Question Content |
| options | string | No | Question options, each option on a separate line |
| type | string | No | Question Type, optional values: single(single choice)、multiple(multiple choice)、judgement(judgment)、fill(fill-in)、short_answer(short answer)、calculation(calculation)、essay(essay)、coding(programming) |
| token | string | Yes* | API Keys (if not provided in request headers) |
| Parameter Name | Type | Description |
|---|---|---|
| code | integer | Return code, 1 for success, 0 for failure |
| question | string | Original Question Content |
| answer | string | Question Answer |
| msg | string | Error message (returned only on failure) |
The AI Question Generation API can intelligently generate exam questions based on specified subjects, difficulty levels, and question types. Supports uploading teaching materials, and AI will generate related questions based on the material content.
GET/POST http://localhost:8888/api/generate
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| subject | string | Yes | Subject content, such as: Mathematics, Chinese, Physics, Chemistry, etc. |
| type | string | No | Question Type, default single. Optional values: single(single choice)、multiple(multiple choice)、judgement(judgment)、fill(fill-in)、short_answer(short answer)、calculation(calculation)、essay(essay)、coding(programming) |
| difficulty | string | No | Difficulty level, default medium. Optional values: easy(easy)、medium(medium)、hard(hard) |
| count | integer | No | Number of questions, default 1, maximum 10 questions |
| keywords | string | No | Keywords that the questions should contain |
| material | file | No | Teaching material files, supports .txt, .md, .pdf, .doc, .docx formats (POST requests only) |
| material_content | string | No | Teaching material text content (JSON format requests) |
| token | string | Yes* | API Keys (if not provided in request headers) |
.txt - Plain text files.md - Markdown files.pdf - PDF documents.doc/.docx - Word documents| Parameter Name | Type | Description |
|---|---|---|
| code | integer | Return code, 1 for success, 0 for failure |
| subject | string | Subject content |
| difficulty | string | Difficulty level |
| type | string | Question Type |
| count | integer | Number of generated questions |
| questions | string | Generated Question Content |
| model | string | AI model information used |
| msg | string | Error message (returned only on failure) |
The Similar Question Generation API can generate a specified number of similar questions based on the original question provided by the user. This feature is very useful for teaching, practice, and question bank expansion.
GET/POST http://localhost:8888/api/similar
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| question | string | Yes | Original Question Content |
| options | string | No | Original question options, each option on a separate line |
| type | string | No | Question Type, default single. Optional values: single(single choice)、multiple(multiple choice)、judgement(judgment)、fill(fill-in)、short_answer(short answer)、calculation(calculation)、essay(essay)、coding(programming) |
| count | integer | No | Number of similar questions to generate, default 3, maximum 10 |
| similarity_level | string | No | Similarity level, default medium. Optional values: low(slight change)、medium(medium change)、high(significant change) |
| variation_type | string | No | Change type, default comprehensive. Optional values: numerical(numerical change)、contextual(contextual change)、expression(expression change)、structure(structural change)、comprehensive(comprehensive change) |
| token | string | Yes* | API Keys (if not provided in request headers) |
| Parameter Name | Type | Description |
|---|---|---|
| code | integer | Return code, 1 for success, 0 for failure |
| original_question | string | Original Question Content (returned on success) |
| question_type | string | Question Type (returned on success) |
| similarity_level | string | Similarity level (returned on success) |
| variation_type | string | Change type (returned on success) |
| count | integer | Number of generated questions (returned on success) |
| similar_questions | string | Generated similar Question Content (returned on success) |
| model | string | AI model information used (returned on success) |
| using_backup | boolean | Whether backup model was used (optional, returned only when backup model is used) |
| msg | string | Error message (returned only on failure) |
| error | string | Error type identifier (returned only on failure) |
{
"code": 1,
"original_question": "Which of the following is a prime number?",
"question_type": "single",
"similarity_level": "medium",
"variation_type": "numerical",
"count": 3,
"similar_questions": "Question 1: Which of the following numbers is a prime number?\nA. 8\nB. 11\nC. 12\nD. 15\nCorrect answer: B\n\nQuestion 2: Which of the following is a prime number?\nA. 14\nB. 16\nC. 17\nD. 18\nCorrect answer: C\n\nQuestion 3: Which of the following options is a prime number?\nA. 21\nB. 22\nC. 23\nD. 24\nCorrect answer: C",
"model": "spark:X1"
}
{
"code": 0,
"msg": "Please provide original Question Content"
}
The AI Question Explanation API can provide detailed knowledge point explanations, problem-solving approaches, and answer analysis for questions. This feature is very valuable for teaching, self-study, and deep understanding of questions.
GET/POST http://localhost:8888/api/explain
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| question | string | Yes | Question Content |
| options | string | No | Question options, each option on a separate line |
| type | string | No | Question Type. Optional values: single(single choice)、multiple(multiple choice)、judgement(judgment)、fill(fill-in)、short_answer(short answer)、calculation(calculation)、essay(essay)、coding(programming) |
| answer | string | No | Correct answer (if provided, will be analyzed in detail in the explanation) |
| explain_level | string | No | Explanation level, default adaptive. Optional values: brief(brief explanation)、detailed(detailed explanation)、comprehensive(comprehensive explanation)、adaptive(intelligent adaptation) |
| subject | string | No | Subject Name (such as: Mathematics, Physics, Chemistry, etc., helps provide more professional explanations) |
| student_level | string | No | Student level, default intermediate. Optional values: beginner(beginner)、intermediate(intermediate)、advanced(advanced) |
| learning_style | string | No | Learning style, default balanced. Optional values: visual(visual)、auditory(auditory)、kinesthetic(kinesthetic)、logical(logical)、social(social)、balanced(balanced) |
| include_examples | boolean | No | Whether to include related example questions, default true |
| include_practice | boolean | No | Whether to include practice suggestions, default true |
| focus_areas | string | No | Key areas or knowledge points to focus on (such as: number theory basics, mechanics basics, etc.) |
| token | string | Yes* | API Keys (if not provided in request headers) |
| Level | Description | Use Cases |
|---|---|---|
brief |
Brief explanation, including core points, problem-solving approaches, answer explanation | Quick review, pre-exam sprint |
detailed |
Detailed explanation, including knowledge point organization, question analysis, problem-solving process, answer description, precautions | Daily learning, homework tutoring |
comprehensive |
Comprehensive explanation, including question analysis, knowledge system, problem-solving strategy, detailed answer, answer verification, error analysis, knowledge expansion, learning suggestions | Deep learning, teaching preparation |
adaptive |
Intelligent adaptive explanation, automatically adjust explanation depth based on student level and Question Type | Personalized learning, intelligent teaching |
| Style | Description | Characteristics |
|---|---|---|
visual |
Visual learning | Use charts, flowcharts, analogies and visual descriptions |
auditory |
Auditory learning | Conversational explanation, focusing on speech rhythm and cadence |
kinesthetic |
Kinesthetic learning | Provide operational steps and hands-on practice suggestions |
logical |
Logical learning | Logical reasoning and systematic analysis, focusing on cause and effect relationships |
social |
Social learning | Collaborative learning approach, providing discussion topics and group activities |
balanced |
Balanced learning | Comprehensive use of multiple explanation methods |
| Parameter Name | Type | Description |
|---|---|---|
| code | integer | Return code, 1 for success, 0 for failure |
| question | string | Question Content (returned on success) |
| question_type | string | Question Type (returned on success) |
| explain_level | string | Explanation level (returned on success) |
| original_level | string | Original requested explanation level (returned on success) |
| student_level | string | Student level (returned on success) |
| learning_style | string | Learning style (returned on success) |
| subject | string | Subject name (returned on success) |
| answer | string | Question Answer (returned on success) |
| explanation | string | Detailed explanation content (returned on success) |
| model | string | AI model information used (returned on success) |
| features | object | Feature information (returned on success), including adaptive_level, include_examples, include_practice, focus_areas, etc. |
| using_backup | boolean | Whether backup model was used (optional, returned only when backup model is used) |
| msg | string | Error message (returned only on failure) |
| error | string | Error type identifier (returned only on failure) |
{
"code": 1,
"question": "Which of the following is a prime number?",
"question_type": "single",
"explain_level": "detailed",
"original_level": "adaptive",
"student_level": "intermediate",
"learning_style": "visual",
"subject": "Mathematics",
"answer": "C",
"explanation": "【Knowledge Point Review】\nA prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. In other words, a prime number can only be divided by 1 and itself.\n\n【Question Analysis】\nThis question tests the concept and judgment method of prime numbers. We need to analyze each option one by one to determine which number meets the definition of a prime number.\n\n【Solution Process】\nLet's analyze each option:\nA. 4 = 2 × 2, besides 1 and 4, it can also be divided by 2, so it's not a prime number\nB. 6 = 2 × 3, besides 1 and 6, it can also be divided by 2 and 3, so it's not a prime number\nC. 7: Besides 1 and 7, there are no other factors, so it is a prime number\nD. 9 = 3 × 3, besides 1 and 9, it can also be divided by 3, so it's not a prime number\n\n【Answer Description】\nThe correct answer is C. 7 is a prime number because it can only be divided by 1 and 7, satisfying the definition of a prime number.\n\n【Related Examples】\nOther prime number examples: 2, 3, 5, 11, 13, 17, 19, 23, 29, 31, etc.\n\n【Practice Suggestions】\n1. Draw a prime number distribution chart\n2. Practice prime number judgment methods\n3. Learn prime factorization techniques\n\n【Personalized Suggestions】\nAs an intermediate level student, I suggest you:\n1. Use more charts to understand abstract concepts\n2. Try to connect knowledge points with real life\n3. Regularly review and consolidate basic knowledge",
"model": "deepseek:deepseek-chat",
"features": {
"adaptive_level": true,
"include_examples": true,
"include_practice": true,
"focus_areas": "Number Theory Basics"
}
}
{
"code": 0,
"msg": "Please provide Question Content"
}
The AI Intelligent Translation API provides high-quality multilingual translation services, supporting multiple translation modes and professional domain translation. Suitable for academic translation, technical document translation, business communication and other scenarios.
GET/POST http://localhost:8888/api/translate
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| text | string | Yes | Text content to be translated |
| source_lang | string | No | Source language code, default auto (automatic detection) |
| target_lang | string | No | Target language code, default zh (Chinese) |
| translate_mode | string | No | Translation mode, default standard. Optional values: fast(fast)、standard(standard)、accurate(accurate) |
| domain | string | No | Professional domain, default general. Optional values: academic、technical、business、medical、legal、literature、news |
| preserve_format | boolean | No | Whether to preserve format, default false |
| token | string | Yes* | API Keys (if not provided in request headers) |
| Language Code | Language Name | Language Code | Language Name |
|---|---|---|---|
auto |
Auto detection | zh |
Chinese |
zh-cn |
Simplified Chinese | zh-tw |
Traditional Chinese |
en |
English | ja |
Japanese |
ko |
Korean | fr |
French |
de |
German | es |
Spanish |
it |
Italian | ru |
Russian |
ar |
Arabic | pt |
Portuguese |
th |
Thai | vi |
Vietnamese |
| Mode | Description | Use Cases | Token Usage |
|---|---|---|---|
fast |
Fast translation, focusing on speed while maintaining basic accuracy | Batch translation, real-time communication | Less |
standard |
Standard translation, balancing quality and speed | Daily translation, document processing | Moderate |
accurate |
Accurate translation, focusing on quality and accuracy | Professional documents, important content | More |
| Domain Code | Domain Name | Characteristics |
|---|---|---|
general |
General translation | Suitable for daily conversation and general text |
academic |
Academic translation | Focus on accuracy of academic terminology and professional terms |
technical |
Technical translation | Focus on technical terminology accuracy, maintaining professionalism |
business |
Business translation | Use business terminology, maintain formal professional tone |
medical |
Medical translation | Ensure accuracy of medical terminology and terminology |
legal |
Legal translation | Focus on legal terminology accuracy, rigorous word usage |
literature |
Literature translation | Maintain the literary and artistic nature of literary works |
news |
News translation | News reporting language style, objective and accurate |
| Parameter Name | Type | Description |
|---|---|---|
| code | integer | Return code, 1 for success, 0 for failure |
| original_text | string | Original text (returned on success) |
| translated_text | string | Translation result (returned on success) |
| source_lang | string | Source language code (returned on success) |
| target_lang | string | Target language code (returned on success) |
| detected_target_lang | string | Detected result language (returned on success) |
| translate_mode | string | Translation mode (returned on success) |
| domain | string | Professional domain (returned on success) |
| preserve_format | boolean | Whether format was preserved (returned on success) |
| text_length | integer | Original text length (returned on success) |
| model | string | AI model information used (returned on success) |
| using_backup | boolean | Whether backup model was used (optional) |
| msg | string | Error message (returned only on failure) |
| error | string | Error type identifier (returned only on failure) |
{
"code": 1,
"original_text": "Hello, world!",
"translated_text": "Hello, world!",
"source_lang": "auto",
"target_lang": "zh",
"detected_target_lang": "zh",
"translate_mode": "standard",
"domain": "general",
"preserve_format": false,
"text_length": 13,
"model": "deepseek:deepseek-chat"
}
{
"code": 0,
"msg": "Please provide text content to be translated"
}
curl -X GET "http://localhost:8888/api/search?token=YOUR_API_KEY&title=What is the capital of China?&options=Beijing%0AShanghai%0AGuangzhou%0AShenzhen&type=single"
curl -X POST "http://localhost:8888/api/search" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"title": "What is the capital of China?",
"options": "Beijing\nShanghai\nGuangzhou\nShenzhen",
"type": "single"
}'
{
"code": 1,
"question": "What is the capital of China?",
"answer": "A"
}
{
"code": 0,
"msg": "Invalid API Keys or insufficient usage count"
}
curl -X GET "http://localhost:8888/api/generate?token=YOUR_API_KEY&subject=Mathematics&type=single&difficulty=medium&count=1"
curl -X POST "http://localhost:8888/api/generate" \
-H "X-API-Key: YOUR_API_KEY" \
-F "subject=Mathematics" \
-F "type=single" \
-F "difficulty=medium" \
-F "count=2" \
-F "keywords=function" \
-F "material=@math_chapter1.pdf"
curl -X POST "http://localhost:8888/api/generate" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"subject": "Mathematics",
"type": "single",
"difficulty": "medium",
"count": 1,
"keywords": "function",
"material_content": "Functions are important concepts in mathematics..."
}'
{
"code": 1,
"subject": "Mathematics",
"difficulty": "medium",
"type": "single",
"count": 1,
"questions": "Question: Which of the following numbers is a prime number?\nA. 4\nB. 6\nC. 7\nD. 9\nCorrect answer: C",
"model": "spark:x1"
}
curl -X GET "http://localhost:8888/api/generate?token=YOUR_API_KEY&subject=Physics&type=calculation&difficulty=hard&count=3"
{
"code": 0,
"msg": "Unsupported file format, please upload .txt, .md, .pdf, .doc, .docx format files"
}
The AI Essay Grading interface provides professional Chinese and English essay grading services. The system automatically identifies language type and provides detailed grading suggestions, including overall evaluation, strength analysis, problem identification, revision suggestions, and scoring levels.
GET/POST http://localhost:8888/api/grade
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| content | String | Yes | Essay content (at least 10 characters, supports automatic Chinese and English recognition) |
| topic | String | No | Essay topic (Chinese or English) |
| requirements | String | No | Writing requirements |
| criteria | String | No | Grading criteria, optional values: comprehensive (comprehensive scoring), content (content quality), structure (structure organization), language (language expression), grammar (grammar checking), creativity (creative thinking), default is comprehensive |
| essay_file | File | No | Essay file upload (supports .txt, .md, .doc, .docx formats) |
| token | string | Yes* | API Keys (if not provided in request headers) |
| Parameter Name | Type | Description |
|---|---|---|
| code | integer | Return code, 1 for success, 0 for failure |
| essay_topic | string | Essay topic (returned on success) |
| language | string | Detected essay language type, chinese or english (returned on success) |
| criteria | string | Chinese description of grading criteria (returned on success) |
| grading_result | string | Detailed grading results, including overall evaluation, strength analysis, problem identification, revision suggestions, scoring level and score (returned on success) |
| model | string | AI model information used (returned on success) |
| word_count | integer | Essay word count statistics (returned on success) |
| using_backup | boolean | Whether backup model was used (optional, returned only when backup model is used) |
| msg | string | Error message (returned only on failure) |
| error | string | Error type identifier (returned only on failure) |
{
"code": 1,
"essay_topic": "My Hometown",
"language": "chinese",
"criteria": "Comprehensive Scoring",
"grading_result": "【Overall Evaluation】\nThis is an essay describing hometown...\n\n【Strength Analysis】\n1. Vivid descriptions, fluent language\n2. Clear structure, well-organized\n\n【Problem Identification】\n1. Some word choices are not accurate enough\n2. Some sentence structures could be more varied\n\n【Revision Suggestions】\n1. Suggest using more adjectives to enrich descriptions\n2. Can add some rhetorical devices\n\n【Scoring Level】\nB+ (Good level, overall article quality is high)\n\n【Score】\n82 points",
"model": "deepseek:deepseek-chat",
"word_count": 456
}
{
"code": 0,
"msg": "Essay content cannot be empty and should contain at least 10 characters"
}
curl -X GET "http://localhost:8888/api/grade?token=YOUR_API_KEY&content=My hometown is a beautiful small county&topic=My Hometown&criteria=comprehensive"
curl -X POST "http://localhost:8888/api/grade" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": "My hometown is a beautiful small county town with mountains and water, picturesque scenery. In spring, flowers bloom all over the mountains and fields; in summer, green trees provide shade; in autumn, fruits are abundant; in winter, snowflakes dance. I love my hometown, where I have beautiful childhood memories.",
"topic": "My Hometown",
"requirements": "Requirements: vivid language, specific descriptions, express true feelings, at least 400 words",
"criteria": "comprehensive"
}'
curl -X POST "http://localhost:8888/api/grade" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": "Environmental protection is one of the most important issues facing humanity today. With rapid industrialization and urbanization, our planet is experiencing unprecedented environmental challenges. Air pollution, water contamination, and climate change are threatening the future of our world. However, I believe that through collective efforts and individual actions, we can make a significant difference in protecting our environment.",
"topic": "Environmental Protection",
"requirements": "Write an argumentative essay about environmental protection, minimum 200 words",
"criteria": "comprehensive"
}'
curl -X POST "http://localhost:8888/api/grade" \
-H "X-API-Key: YOUR_API_KEY" \
-F "topic=My Hometown" \
-F "requirements=Requirements: vivid language, specific descriptions" \
-F "criteria=comprehensive" \
-F "essay_file=@essay.txt"
{
"code": 1,
"essay_topic": "My Hometown",
"language": "chinese",
"criteria": "Comprehensive Scoring",
"grading_result": "【Overall Evaluation】\nThis is an essay describing hometown, where the author shows the beauty of hometown through the perspective of seasonal changes. The thinking is relatively clear and the language is relatively fluent, but the content needs to be further enriched.\n\n【Strength Analysis】\n1. The structure is reasonably arranged, describing in the order of spring, summer, autumn, and winter, with clear organization\n2. The word choice is relatively vivid, with appropriate use of phrases like \"flowers blooming all over the mountains\" and \"green trees providing shade\"\n3. Expresses sincere feelings for hometown, with authentic emotions\n\n【Problem Identification】\n1. The description is too simple, lacking specific detailed descriptions\n2. The word count is significantly insufficient, with a large gap from the required 400 words\n3. Language expression could be more rich and varied\n\n【Revision Suggestions】\n1. Suggest adding specific landscape descriptions, such as specific flowers, trees, fruits, etc.\n2. Can add some specific childhood memory fragments\n3. Appropriately use rhetorical devices such as metaphors and personification to make the language more vivid\n4. Expand the content to meet the required word count\n\n【Scoring Level】\nC+ (Basic level, both content and language need improvement)\n\n【Score】\n68 points",
"model": "deepseek:deepseek-chat",
"word_count": 89
}
{
"code": 1,
"essay_topic": "Environmental Protection",
"language": "english",
"criteria": "Comprehensive Assessment",
"grading_result": "【Overall Evaluation】\nThis is an argumentative essay about environmental protection, where the author can choose a topic with practical significance and express a clear viewpoint. The article structure is basically reasonable and the language expression is relatively fluent, but there is room for improvement in argumentation depth and vocabulary usage.\n\n【Strength Analysis】\n1. Clear theme, choosing an environmentally friendly topic with social significance\n2. The introduction can well introduce the topic, mentioning environmental challenges brought by industrialization and urbanization\n3. Grammar is basically correct, with relatively diverse sentence structures\n4. Expresses positive views, believing that the current situation can be changed through collective and individual efforts\n\n【Problem Identification】\n1. The argumentation is not sufficient enough, lacking specific examples and data support\n2. Paragraph development is not complete enough, needs more detailed expansion\n3. Vocabulary usage is relatively simple, can use more advanced vocabulary\n4. Article length is insufficient, needs further content expansion\n\n【Revision Suggestions】\n1. Add specific environmental problem examples, such as specific pollution data or cases\n2. Provide more solutions, such as government policies, technological innovation, personal behavior, etc.\n3. Use richer vocabulary and complex sentence structures to improve language level\n4. Add a conclusion paragraph to better summarize the full text viewpoint\n\n【Scoring Level】\nB- (Above average level, has some foundation but needs further improvement)\n\n【Score】\n75 points",
"model": "deepseek:deepseek-chat",
"word_count": 267
}
{
"code": 0,
"msg": "Unsupported file format, please upload files in .txt, .md, .doc, .docx formats"
}
curl -X GET "http://localhost:8888/api/similar?token=YOUR_API_KEY&question=Which%20of%20the%20following%20is%20a%20prime%20number%3F&options=A.%204%0AB.%206%0AC.%207%0AD.%209&type=single&count=3&similarity_level=medium&variation_type=numerical"
curl -X POST "http://localhost:8888/api/similar" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"question": "Which of the following is a prime number?",
"options": "A. 4\nB. 6\nC. 7\nD. 9",
"type": "single",
"count": 3,
"similarity_level": "medium",
"variation_type": "numerical"
}'
curl -X POST "http://localhost:8888/api/similar" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"question": "Earth is the largest planet in the solar system",
"type": "judgement",
"count": 4,
"similarity_level": "high",
"variation_type": "contextual"
}'
curl -X POST "http://localhost:8888/api/similar" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"question": "Calculate the value of 15 × 8",
"type": "calculation",
"count": 2,
"similarity_level": "low",
"variation_type": "numerical"
}'
curl -X POST "http://localhost:8888/api/similar" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"question": "The People's Republic of China was founded in _____",
"type": "fill",
"count": 3,
"similarity_level": "medium",
"variation_type": "expression"
}'
curl -X POST "http://localhost:8888/api/similar" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"question": "Write a Python function to calculate the greatest common divisor of two numbers",
"type": "coding",
"count": 2,
"similarity_level": "medium",
"variation_type": "structure"
}'
{
"code": 1,
"original_question": "Which of the following is a prime number?",
"question_type": "single",
"similarity_level": "medium",
"variation_type": "numerical",
"count": 3,
"similar_questions": "Question 1: Which of the following numbers is a prime number?\nA. 8\nB. 11\nC. 12\nD. 15\nCorrect answer: B\n\nQuestion 2: Which of the following is a prime number?\nA. 14\nB. 16\nC. 17\nD. 18\nCorrect answer: C\n\nQuestion 3: Which of the following options is a prime number?\nA. 21\nB. 22\nC. 23\nD. 24\nCorrect answer: C",
"model": "spark:X1"
}
{
"code": 1,
"original_question": "Earth is the largest planet in the solar system",
"question_type": "judgement",
"similarity_level": "high",
"variation_type": "contextual",
"count": 4,
"similar_questions": "Question 1: Jupiter is the largest planet in the solar system\nCorrect answer: True\n\nQuestion 2: Mars is the largest celestial body in the solar system\nCorrect answer: False\n\nQuestion 3: The Sun is the largest star in the solar system\nCorrect answer: True\n\nQuestion 4: The Moon is the largest satellite in the Earth system\nCorrect answer: True",
"model": "deepseek:deepseek-chat"
}
{
"code": 1,
"original_question": "Calculate the value of 15 × 8",
"question_type": "calculation",
"similarity_level": "low",
"variation_type": "numerical",
"count": 2,
"similar_questions": "Question 1: Calculate the value of 16 × 8\nSolution process: 16 × 8 = 128\nFinal answer: 128\n\nQuestion 2: Calculate the value of 15 × 9\nSolution process: 15 × 9 = 135\nFinal answer: 135",
"model": "spark:X1"
}
{
"code": 0,
"msg": "Please provide original Question Content"
}
curl -X GET "http://localhost:8888/api/explain?token=YOUR_API_KEY&question=Which%20of%20the%20following%20is%20a%20prime%20number%3F&options=A.%204%0AB.%206%0AC.%207%0AD.%209&type=single&answer=C&explain_level=adaptive&subject=Mathematics&student_level=intermediate&learning_style=visual"
curl -X POST "http://localhost:8888/api/explain" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"question": "Which of the following is a prime number?",
"options": "A. 4\nB. 6\nC. 7\nD. 9",
"type": "single",
"answer": "C",
"explain_level": "adaptive",
"subject": "Mathematics",
"student_level": "intermediate",
"learning_style": "visual",
"include_examples": true,
"include_practice": true,
"focus_areas": "Number Theory Basics"
}'
curl -X POST "http://localhost:8888/api/explain" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"question": "Calculate the value of 2 + 3 × 4",
"type": "calculation",
"answer": "14",
"explain_level": "brief",
"subject": "Mathematics",
"student_level": "beginner",
"learning_style": "logical"
}'
curl -X POST "http://localhost:8888/api/explain" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"question": "What is the difference between lists and tuples in Python?",
"type": "short_answer",
"explain_level": "comprehensive",
"subject": "Computer Science",
"student_level": "advanced",
"learning_style": "balanced",
"include_examples": true,
"include_practice": true,
"focus_areas": "Data Structure Basics"
}'
curl -X POST "http://localhost:8888/api/explain" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"question": "Earth is the largest planet in the solar system",
"type": "judgement",
"answer": "False",
"explain_level": "detailed",
"subject": "Geography",
"student_level": "intermediate",
"learning_style": "auditory",
"include_examples": true
}'
curl -X POST "http://localhost:8888/api/explain" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"question": "Write a Python function to implement the bubble sort algorithm",
"type": "coding",
"explain_level": "comprehensive",
"subject": "Computer Science",
"student_level": "advanced",
"learning_style": "kinesthetic",
"include_examples": true,
"include_practice": true,
"focus_areas": "Algorithm Basics"
}'
{
"code": 1,
"question": "Which of the following is a prime number?",
"question_type": "single",
"explain_level": "detailed",
"subject": "Mathematics",
"answer": "C",
"explanation": "【Knowledge Point Review】\nA prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. In other words, a prime number can only be divided by 1 and itself.\n\n【Question Analysis】\nThis question tests the concept and judgment method of prime numbers. We need to analyze each option one by one to determine which number meets the definition of a prime number.\n\n【Solution Process】\nLet's analyze each option:\nA. 4 = 2 × 2, besides 1 and 4, it can also be divided by 2, so it's not a prime number\nB. 6 = 2 × 3, besides 1 and 6, it can also be divided by 2 and 3, so it's not a prime number\nC. 7: Besides 1 and 7, there are no other factors, so it is a prime number\nD. 9 = 3 × 3, besides 1 and 9, it can also be divided by 3, so it's not a prime number\n\n【Answer Description】\nThe correct answer is C. 7 is a prime number because it can only be divided by 1 and 7, satisfying the definition of a prime number.\n\n【Notes】\nWhen judging prime numbers, check if the number has only two factors: 1 and itself. You can try dividing it by all prime numbers smaller than it. If none can divide it evenly, then it's a prime number.",
"model": "spark:X1"
}
{
"code": 1,
"question": "Calculate the value of 2 + 3 × 4",
"question_type": "calculation",
"explain_level": "brief",
"original_level": "brief",
"student_level": "beginner",
"learning_style": "logical",
"subject": "Mathematics",
"answer": "14",
"explanation": "【Core Points】\nOperation priority: multiplication and division take precedence over addition and subtraction\n\n【Solution Approach】\nFollow the operation priority, calculate multiplication first, then addition\n\n【Answer Explanation】\n2 + 3 × 4 = 2 + 12 = 14\nFirst calculate 3 × 4 = 12, then calculate 2 + 12 = 14",
"model": "deepseek:deepseek-chat",
"features": {
"adaptive_level": false,
"include_examples": false,
"include_practice": false,
"focus_areas": null
}
}
{
"code": 1,
"question": "Earth is the largest planet in the solar system",
"question_type": "judgement",
"explain_level": "detailed",
"original_level": "detailed",
"student_level": "intermediate",
"learning_style": "auditory",
"subject": "Geography",
"answer": "False",
"explanation": "【Knowledge Point Review】\nThe eight planets in the solar system ranked by size: Jupiter, Saturn, Neptune, Uranus, Earth, Venus, Mars, Mercury\n\n【Question Analysis】\nThis question tests understanding of the size relationships of planets in the solar system, requiring knowledge of the basic characteristics of each planet.\n\n【Solution Process】\nThe largest planet in the solar system is Jupiter, with a diameter about 11 times that of Earth and a mass about 318 times that of Earth. Earth ranks 5th in size among the eight planets in the solar system, far from being the largest.\n\n【Answer Description】\nThe statement in the question is incorrect. Jupiter is the largest planet in the solar system, while Earth is only the largest among the terrestrial planets.\n\n【Related Examples】\nSimilar conceptual questions include: The largest celestial body in the solar system is the Sun, and the largest satellite is Jupiter's moon Ganymede.\n\n【Notes】\nDon't confuse the concepts of 'largest among terrestrial planets' and 'largest in the solar system'. Earth is the largest among terrestrial planets (Mercury, Venus, Earth, Mars), but ranks only 5th in the entire solar system.",
"model": "spark:X1",
"features": {
"adaptive_level": false,
"include_examples": true,
"include_practice": false,
"focus_areas": null
}
}
{
"code": 0,
"msg": "Please provide Question Content"
}
curl -X GET "http://localhost:8888/api/translate?token=YOUR_API_KEY&text=Hello%2C%20world%21&source_lang=auto&target_lang=zh&translate_mode=standard"
curl -X POST "http://localhost:8888/api/translate" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"text": "Hello, world! This is a test.",
"source_lang": "en",
"target_lang": "zh",
"translate_mode": "standard",
"domain": "general"
}'
curl -X POST "http://localhost:8888/api/translate" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"text": "Hello, world! This is a test.",
"source_lang": "zh",
"target_lang": "en",
"translate_mode": "accurate",
"domain": "general"
}'
curl -X POST "http://localhost:8888/api/translate" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"text": "Machine learning is a subset of artificial intelligence that focuses on algorithms and statistical models.",
"source_lang": "en",
"target_lang": "zh",
"translate_mode": "accurate",
"domain": "academic"
}'
curl -X POST "http://localhost:8888/api/translate" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"text": "The API endpoint returns a JSON response with status code 200 on success.",
"source_lang": "en",
"target_lang": "zh",
"translate_mode": "standard",
"domain": "technical"
}'
curl -X POST "http://localhost:8888/api/translate" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"text": "We are pleased to announce our new partnership agreement.",
"source_lang": "en",
"target_lang": "zh",
"translate_mode": "accurate",
"domain": "business"
}'
curl -X POST "http://localhost:8888/api/translate" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"text": "# Title\n\n## Subtitle\n\n* Item 1\n* Item 2\n\n**Bold text**",
"source_lang": "en",
"target_lang": "zh",
"translate_mode": "standard",
"preserve_format": true
}'
curl -X POST "http://localhost:8888/api/translate" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"text": "Hello, world! This is a test.",
"source_lang": "ja",
"target_lang": "zh",
"translate_mode": "standard"
}'
{
"code": 1,
"original_text": "Hello, world! This is a test.",
"translated_text": "Hello, world! This is a test.",
"source_lang": "en",
"target_lang": "zh",
"detected_target_lang": "zh",
"translate_mode": "standard",
"domain": "general",
"preserve_format": false,
"text_length": 29,
"model": "deepseek:deepseek-chat"
}
{
"code": 1,
"original_text": "Machine learning is a subset of artificial intelligence.",
"translated_text": "Machine learning is a subset of artificial intelligence.",
"source_lang": "zh",
"target_lang": "en",
"detected_target_lang": "en",
"translate_mode": "accurate",
"domain": "academic",
"preserve_format": false,
"text_length": 15,
"model": "spark:X1"
}
{
"code": 1,
"original_text": "The API endpoint returns a JSON response with status code 200 on success.",
"translated_text": "The API endpoint returns a JSON response with status code 200 on success.",
"source_lang": "en",
"target_lang": "zh",
"detected_target_lang": "zh",
"translate_mode": "standard",
"domain": "technical",
"preserve_format": false,
"text_length": 73,
"model": "deepseek:deepseek-chat"
}
{
"code": 1,
"original_text": "Bonjour le monde!",
"translated_text": "Hello world!",
"source_lang": "auto",
"target_lang": "zh",
"detected_target_lang": "zh",
"translate_mode": "standard",
"domain": "general",
"preserve_format": false,
"text_length": 17,
"model": "deepseek:deepseek-chat"
}
{
"code": 0,
"msg": "Please provide text content to be translated"
}
| HTTPStatus Codes | Description |
|---|---|
| 200 | Request successful |
| 400 | Request parameters error |
| 401 | Authentication failed |
| 403 | Insufficient permissions |
| 429 | Request rate limit exceeded |
| 500 | Internal server error |
| 502 | Failed to connect to AI server |
| 504 | AI server response timeout |
import requests
API_KEY = "YOUR_API_KEY"
BASE_URL = "http://localhost:8888/api"
def get_answer(title, options=None, question_type=None):
url = f"{BASE_URL}/search"
params = {
"token": API_KEY,
"title": title
}
if options:
params["options"] = options
if question_type:
params["type"] = question_type
response = requests.get(url, params=params)
result = response.json()
if result["code"] == 1:
return result["answer"]
else:
raise Exception(f"API request failed: {result.get('msg', 'Unknown error')}")
# Usage Examples
try:
title = "What is the capital city of China?"
options = "Beijing\nShanghai\nGuangzhou\nShenzhen"
question_type = "single"
answer = get_answer(title, options, question_type)
print(f"Answer: {answer}")
except Exception as e:
print(f"Error: {str(e)}")
import requests
API_KEY = "YOUR_API_KEY"
BASE_URL = "http://localhost:8888/api"
def generate_questions(subject, question_type="single", difficulty="medium", count=1, keywords=None, material_file=None):
url = f"{BASE_URL}/generate"
# Basic question generation (GET request)
if not material_file:
params = {
"token": API_KEY,
"subject": subject,
"type": question_type,
"difficulty": difficulty,
"count": count
}
if keywords:
params["keywords"] = keywords
response = requests.get(url, params=params)
else:
# File upload question generation (POST request)
data = {
"subject": subject,
"type": question_type,
"difficulty": difficulty,
"count": str(count)
}
if keywords:
data["keywords"] = keywords
headers = {"X-API-Key": API_KEY}
with open(material_file, "rb") as f:
files = {"material": f}
response = requests.post(url, data=data, files=files, headers=headers)
result = response.json()
if result["code"] == 1:
return result["questions"]
else:
raise Exception(f"API request failed: {result.get('msg', 'Unknown error')}")
# Usage Examples
try:
# Basic question generation
questions = generate_questions("Mathematics", "single", "medium", 2, "functions")
print(f"Generated questions:\n{questions}")
# File-based question generation
# questions = generate_questions("Physics", "calculation", "hard", 1, material_file="physics.pdf")
# print(f"Material-based questions:\n{questions}")
except Exception as e:
print(f"Error: {str(e)}")
import requests
API_KEY = "YOUR_API_KEY"
BASE_URL = "http://localhost:8888/api"
def grade_essay(content, topic=None, requirements=None, criteria="comprehensive", essay_file=None):
url = f"{BASE_URL}/grade"
headers = {"X-API-Key": API_KEY}
if essay_file:
# File upload request
data = {
"criteria": criteria
}
if topic:
data["topic"] = topic
if requirements:
data["requirements"] = requirements
with open(essay_file, "rb") as f:
files = {"essay_file": f}
response = requests.post(url, data=data, files=files, headers=headers)
else:
# JSON format request
headers["Content-Type"] = "application/json"
data = {
"content": content,
"criteria": criteria
}
if topic:
data["topic"] = topic
if requirements:
data["requirements"] = requirements
response = requests.post(url, json=data, headers=headers)
result = response.json()
if result["code"] == 1:
return result
else:
raise Exception(f"API request failed: {result.get('msg', 'Unknown error')}")
# Usage Examples
try:
# Chinese Essay Grading
chinese_essay = """
My hometown is a beautiful small county town with mountains and water, picturesque scenery.
In spring, flowers bloom all over the mountains and fields; in summer, green trees provide shade; in autumn, fruits are abundant; in winter, snowflakes dance.
I love my hometown, where I have beautiful childhood memories.
"""
result = grade_essay(
content=chinese_essay,
topic="My Hometown",
requirements="Requirements: vivid language, specific descriptions, express true feelings",
criteria="comprehensive"
)
print(f"Grading Result:")
print(f" Language Type: {result['language']}")
print(f" Word Count: {result['word_count']}")
print(f" Model Used: {result['model']}")
print(f" Grading Details: {result['grading_result'][:100]}...")
# File upload grading
# result = grade_essay(
# topic="My Hometown",
# requirements="Requirements: vivid language, specific descriptions",
# criteria="comprehensive",
# essay_file="essay.txt"
# )
# print(f"File grading result: {result['grading_result'][:100]}...")
except Exception as e:
print(f"Error: {str(e)}")
import requests
API_KEY = "YOUR_API_KEY"
BASE_URL = "http://localhost:8888/api"
def generate_similar_questions(original_question, options=None, question_type="single", count=3, similarity_level="medium", variation_type="comprehensive"):
url = f"{BASE_URL}/similar"
headers = {"X-API-Key": API_KEY, "Content-Type": "application/json"}
data = {
"question": original_question,
"type": question_type,
"count": count,
"similarity_level": similarity_level,
"variation_type": variation_type
}
if options:
data["options"] = options
response = requests.post(url, json=data, headers=headers)
result = response.json()
if result["code"] == 1:
return result
else:
raise Exception(f"API request failed: {result.get('msg', 'Unknown error')}")
# Usage Examples
try:
# Single choice numerical variation
result = generate_similar_questions(
original_question="Which of the following is a prime number?",
options="A. 4\nB. 6\nC. 7\nD. 9",
question_type="single",
count=3,
similarity_level="medium",
variation_type="numerical"
)
print(f"Original Question: {result['original_question']}")
print(f"Question Type: {result['question_type']}")
print(f"Similarity Level: {result['similarity_level']}")
print(f"Variation Type: {result['variation_type']}")
print(f"Generated Count: {result['count']}")
print(f"Model Used: {result['model']}")
print(f"Similar Questions:\n{result['similar_questions']}")
# True/False contextual variation
result2 = generate_similar_questions(
original_question="Earth is the largest planet in the solar system",
question_type="judgement",
count=2,
similarity_level="high",
variation_type="contextual"
)
print(f"\nTrue/False Similar Questions:\n{result2['similar_questions']}")
except Exception as e:
print(f"Error: {str(e)}")
import requests
API_KEY = "YOUR_API_KEY"
BASE_URL = "http://localhost:8888/api"
def explain_question(question, options=None, question_type=None, answer=None, explain_level="adaptive", subject=None,
student_level="intermediate", learning_style="balanced", include_examples=True,
include_practice=True, focus_areas=None):
url = f"{BASE_URL}/explain"
headers = {"X-API-Key": API_KEY, "Content-Type": "application/json"}
data = {
"question": question,
"explain_level": explain_level,
"student_level": student_level,
"learning_style": learning_style,
"include_examples": include_examples,
"include_practice": include_practice
}
if options:
data["options"] = options
if question_type:
data["type"] = question_type
if answer:
data["answer"] = answer
if subject:
data["subject"] = subject
if focus_areas:
data["focus_areas"] = focus_areas
response = requests.post(url, json=data, headers=headers)
result = response.json()
if result["code"] == 1:
return result
else:
raise Exception(f"API request failed: {result.get('msg', 'Unknown error')}")
# Usage Examples
try:
# Single choice adaptive explanation
result1 = explain_question(
question="Which of the following is a prime number?",
options="A. 4\nB. 6\nC. 7\nD. 9",
question_type="single",
answer="C",
explain_level="adaptive",
subject="Mathematics",
student_level="intermediate",
learning_style="visual",
include_examples=True,
include_practice=True,
focus_areas="Number Theory Basics"
)
print(f"Question: {result1['question']}")
print(f"Question Type: {result1['question_type']}")
print(f"Explanation Level: {result1['explain_level']} (Original: {result1['original_level']})")
print(f"Student Level: {result1['student_level']}")
print(f"Learning Style: {result1['learning_style']}")
print(f"Subject: {result1['subject']}")
print(f"Answer: {result1['answer']}")
print(f"Model Used: {result1['model']}")
print(f"Features: {result1['features']}")
print(f"Explanation:\n{result1['explanation']}")
print("\n" + "="*50 + "\n")
# Calculation brief explanation
result2 = explain_question(
question="Calculate the value of 2 + 3 × 4",
question_type="calculation",
answer="14",
explain_level="brief",
subject="Mathematics",
student_level="beginner",
learning_style="logical"
)
print(f"Calculation explanation:\n{result2['explanation']}")
print("\n" + "="*50 + "\n")
# Programming comprehensive explanation
result3 = explain_question(
question="Write a Python function to implement the bubble sort algorithm",
question_type="coding",
explain_level="comprehensive",
subject="Computer Science",
student_level="advanced",
learning_style="kinesthetic",
include_examples=True,
include_practice=True,
focus_areas="Algorithm Basics"
)
print(f"Programming explanation:\n{result3['explanation'][:200]}...")
except Exception as e:
print(f"Error: {str(e)}")
import requests
API_KEY = "YOUR_API_KEY"
BASE_URL = "http://localhost:8888/api"
def translate_text(text, source_lang="auto", target_lang="zh", translate_mode="standard", domain="general", preserve_format=False):
url = f"{BASE_URL}/translate"
headers = {"X-API-Key": API_KEY, "Content-Type": "application/json"}
data = {
"text": text,
"source_lang": source_lang,
"target_lang": target_lang,
"translate_mode": translate_mode,
"domain": domain,
"preserve_format": preserve_format
}
response = requests.post(url, json=data, headers=headers)
result = response.json()
if result["code"] == 1:
return result
else:
raise Exception(f"API request failed: {result.get('msg', 'Unknown error')}")
# Usage Examples
try:
# English to Chinese example
result1 = translate_text(
text="Hello, world! This is a test of AI translation.",
source_lang="en",
target_lang="zh",
translate_mode="standard",
domain="general"
)
print(f"Original Text: {result1['original_text']}")
print(f"Translated Text: {result1['translated_text']}")
print(f"Translation Mode: {result1['translate_mode']}")
print(f"Model Used: {result1['model']}")
print("\n" + "="*50 + "\n")
# Chinese to English example
result2 = translate_text(
text="Machine learning is an important branch of artificial intelligence.",
source_lang="zh",
target_lang="en",
translate_mode="accurate",
domain="academic"
)
print(f"Academic Translation Result: {result2['translated_text']}")
print("\n" + "="*50 + "\n")
# Technical document translation
result3 = translate_text(
text="The API returns a JSON response with HTTP status code 200.",
source_lang="en",
target_lang="zh",
translate_mode="standard",
domain="technical"
)
print(f"Technical Translation Result: {result3['translated_text']}")
print("\n" + "="*50 + "\n")
# Auto-detect language translation
result4 = translate_text(
text="Bonjour le monde!",
source_lang="auto",
target_lang="zh",
translate_mode="standard"
)
print(f"Auto-detect Translation: {result4['translated_text']}")
print(f"Detected Target Language: {result4['detected_target_lang']}")
except Exception as e:
print(f"Error: {str(e)}")
const API_KEY = 'YOUR_API_KEY';
const BASE_URL = 'http://localhost:8888/api';
async function getAnswer(title, options = null, questionType = null) {
try {
const params = new URLSearchParams({
token: API_KEY,
title: title
});
if (options) {
params.append('options', options);
}
if (questionType) {
params.append('type', questionType);
}
const response = await fetch(`${BASE_URL}/search?${params.toString()}`);
const result = await response.json();
if (result.code === 1) {
return result.answer;
} else {
throw new Error(`API request failed: ${result.msg || 'Unknown error'}`);
}
} catch (error) {
console.error('Error:', error);
throw error;
}
}
// Usage Examples
getAnswer(
'What is the capital city of China?',
'Beijing\nShanghai\nGuangzhou\nShenzhen',
'single'
)
.then(answer => console.log(`Answer: ${answer}`))
.catch(error => console.error(`Error: ${error.message}`));
const API_KEY = 'YOUR_API_KEY';
const BASE_URL = 'http://localhost:8888/api';
async function generateQuestions(subject, questionType = 'single', difficulty = 'medium', count = 1, keywords = null, materialFile = null) {
try {
if (!materialFile) {
// Basic question generation (GET request)
const params = new URLSearchParams({
token: API_KEY,
subject: subject,
type: questionType,
difficulty: difficulty,
count: count
});
if (keywords) {
params.append('keywords', keywords);
}
const response = await fetch(`${BASE_URL}/generate?${params.toString()}`);
const result = await response.json();
if (result.code === 1) {
return result.questions;
} else {
throw new Error(`API request failed: ${result.msg || 'Unknown error'}`);
}
} else {
// File upload question generation (POST request)
const formData = new FormData();
formData.append('subject', subject);
formData.append('type', questionType);
formData.append('difficulty', difficulty);
formData.append('count', count);
if (keywords) {
formData.append('keywords', keywords);
}
formData.append('material', materialFile);
const response = await fetch(`${BASE_URL}/generate`, {
method: 'POST',
headers: {
'X-API-Key': API_KEY
},
body: formData
});
const result = await response.json();
if (result.code === 1) {
return result.questions;
} else {
throw new Error(`API request failed: ${result.msg || 'Unknown error'}`);
}
}
} catch (error) {
console.error('Error:', error);
throw error;
}
}
// Usage Examples
generateQuestions('Mathematics', 'single', 'medium', 2, 'functions')
.then(questions => console.log(`Generated questions:\n${questions}`))
.catch(error => console.error(`Error: ${error.message}`));
const API_KEY = 'YOUR_API_KEY';
const BASE_URL = 'http://localhost:8888/api';
async function gradeEssay(content, topic = null, requirements = null, criteria = 'comprehensive', essayFile = null) {
try {
const url = `${BASE_URL}/grade`;
if (essayFile) {
// File upload request
const formData = new FormData();
formData.append('criteria', criteria);
if (topic) {
formData.append('topic', topic);
}
if (requirements) {
formData.append('requirements', requirements);
}
formData.append('essay_file', essayFile);
const response = await fetch(url, {
method: 'POST',
headers: {
'X-API-Key': API_KEY
},
body: formData
});
const result = await response.json();
if (result.code === 1) {
return result;
} else {
throw new Error(`API request failed: ${result.msg || 'Unknown error'}`);
}
} else {
// JSON format request
const data = {
content: content,
criteria: criteria
};
if (topic) {
data.topic = topic;
}
if (requirements) {
data.requirements = requirements;
}
const response = await fetch(url, {
method: 'POST',
headers: {
'X-API-Key': API_KEY,
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
});
const result = await response.json();
if (result.code === 1) {
return result;
} else {
throw new Error(`API request failed: ${result.msg || 'Unknown error'}`);
}
}
} catch (error) {
console.error('Error:', error);
throw error;
}
}
// Usage Examples
const chineseEssay = `
My hometown is a beautiful small county town with mountains and water, picturesque scenery.
In spring, flowers bloom all over the mountains and fields; in summer, green trees provide shade; in autumn, fruits are abundant; in winter, snowflakes dance.
I love my hometown, where I have beautiful childhood memories.
`;
gradeEssay(
chineseEssay,
'My Hometown',
'Requirements: vivid language, specific descriptions, express true feelings',
'comprehensive'
)
.then(result => {
console.log('Grading Result:');
console.log(` Language Type: ${result.language}`);
console.log(` Word Count: ${result.word_count}`);
console.log(` Model Used: ${result.model}`);
console.log(` Grading Details: ${result.grading_result.substring(0, 100)}...`);
})
.catch(error => console.error(`Error: ${error.message}`));
const API_KEY = 'YOUR_API_KEY';
const BASE_URL = 'http://localhost:8888/api';
async function generateSimilarQuestions(originalQuestion, options = null, questionType = 'single', count = 3, similarityLevel = 'medium', variationType = 'comprehensive') {
try {
const url = `${BASE_URL}/similar`;
const data = {
question: originalQuestion,
type: questionType,
count: count,
similarity_level: similarityLevel,
variation_type: variationType
};
if (options) {
data.options = options;
}
const response = await fetch(url, {
method: 'POST',
headers: {
'X-API-Key': API_KEY,
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
});
const result = await response.json();
if (result.code === 1) {
return result;
} else {
throw new Error(`API request failed: ${result.msg || 'Unknown error'}`);
}
} catch (error) {
console.error('Error:', error);
throw error;
}
}
// Usage Examples
// Single choice numerical variation
generateSimilarQuestions(
'Which of the following is a prime number?',
'A. 4\nB. 6\nC. 7\nD. 9',
'single',
3,
'medium',
'numerical'
)
.then(result => {
console.log(`Original Question: ${result.original_question}`);
console.log(`Question Type: ${result.question_type}`);
console.log(`Similarity Level: ${result.similarity_level}`);
console.log(`Variation Type: ${result.variation_type}`);
console.log(`Generated Count: ${result.count}`);
console.log(`Model Used: ${result.model}`);
console.log(`Similar Questions:\n${result.similar_questions}`);
})
.catch(error => console.error(`Error: ${error.message}`));
// True/False question context variation
generateSimilarQuestions(
'Earth is the largest planet in the solar system',
null,
'judgement',
2,
'high',
'contextual'
)
.then(result => console.log(`\nTrue/False Similar Questions:\n${result.similar_questions}`))
.catch(error => console.error(`Error: ${error.message}`));
const API_KEY = 'YOUR_API_KEY';
const BASE_URL = 'http://localhost:8888/api';
async function explainQuestion(question, options = null, questionType = null, answer = null, explainLevel = 'adaptive', subject = null,
studentLevel = 'intermediate', learningStyle = 'balanced', includeExamples = true,
includePractice = true, focusAreas = null) {
try {
const url = `${BASE_URL}/explain`;
const data = {
question: question,
explain_level: explainLevel,
student_level: studentLevel,
learning_style: learningStyle,
include_examples: includeExamples,
include_practice: includePractice
};
if (options) data.options = options;
if (questionType) data.type = questionType;
if (answer) data.answer = answer;
if (subject) data.subject = subject;
if (focusAreas) data.focus_areas = focusAreas;
const response = await fetch(url, {
method: 'POST',
headers: {
'X-API-Key': API_KEY,
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
});
const result = await response.json();
if (result.code === 1) {
return result;
} else {
throw new Error(`API request failed: ${result.msg || 'Unknown error'}`);
}
} catch (error) {
console.error('Error:', error);
throw error;
}
}
// Usage Examples
// Single choice adaptive explanation
explainQuestion(
'Which of the following is a prime number?',
'A. 4\nB. 6\nC. 7\nD. 9',
'single',
'C',
'adaptive',
'Mathematics',
'intermediate',
'visual',
true,
true,
'Number Theory Basics'
)
.then(result => {
console.log(`Question: ${result.question}`);
console.log(`Question Type: ${result.question_type}`);
console.log(`Explanation Level: ${result.explain_level} (Original: ${result.original_level})`);
console.log(`Student Level: ${result.student_level}`);
console.log(`Learning Style: ${result.learning_style}`);
console.log(`Subject: ${result.subject}`);
console.log(`Answer: ${result.answer}`);
console.log(`Model Used: ${result.model}`);
console.log(`Features: ${JSON.stringify(result.features)}`);
console.log(`Explanation:\n${result.explanation}`);
})
.catch(error => console.error(`Error: ${error.message}`));
// Calculation brief explanation
explainQuestion(
'Calculate the value of 2 + 3 × 4',
null,
'calculation',
'14',
'brief',
'Mathematics',
'beginner',
'logical'
)
.then(result => console.log(`\nCalculation explanation:\n${result.explanation}`))
.catch(error => console.error(`Error: ${error.message}`));
// Programming comprehensive explanation
explainQuestion(
'Write a Python function to implement the bubble sort algorithm',
null,
'coding',
null,
'comprehensive',
'Computer Science',
'advanced',
'kinesthetic',
true,
true,
'Algorithm Basics'
)
.then(result => console.log(`\nProgramming explanation:\n${result.explanation.substring(0, 200)}...`))
.catch(error => console.error(`Error: ${error.message}`));
const API_KEY = 'YOUR_API_KEY';
const BASE_URL = 'http://localhost:8888/api';
async function translateText(text, sourceLang = 'auto', targetLang = 'zh', translateMode = 'standard', domain = 'general', preserveFormat = false) {
try {
const url = `${BASE_URL}/translate`;
const data = {
text: text,
source_lang: sourceLang,
target_lang: targetLang,
translate_mode: translateMode,
domain: domain,
preserve_format: preserveFormat
};
const response = await fetch(url, {
method: 'POST',
headers: {
'X-API-Key': API_KEY,
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
});
const result = await response.json();
if (result.code === 1) {
return result;
} else {
throw new Error(`API request failed: ${result.msg || 'Unknown error'}`);
}
} catch (error) {
console.error('Error:', error);
throw error;
}
}
// Usage Examples
// English to Chinese example
translateText(
'Hello, world! This is a test of AI translation.',
'en',
'zh',
'standard',
'general'
)
.then(result => {
console.log(`Original Text: ${result.original_text}`);
console.log(`Translated Text: ${result.translated_text}`);
console.log(`Translation Mode: ${result.translate_mode}`);
console.log(`Model Used: ${result.model}`);
})
.catch(error => console.error(`Error: ${error.message}`));
// Chinese to English example
translateText(
'Machine learning is an important branch of artificial intelligence.',
'zh',
'en',
'accurate',
'academic'
)
.then(result => console.log(`\nAcademic Translation Result: ${result.translated_text}`))
.catch(error => console.error(`Error: ${error.message}`));
// Technical document translation
translateText(
'The API returns a JSON response with HTTP status code 200.',
'en',
'zh',
'standard',
'technical'
)
.then(result => console.log(`\nTechnical Translation Result: ${result.translated_text}`))
.catch(error => console.error(`Error: ${error.message}`));
// Auto-detect language translation
translateText(
'Bonjour le monde!',
'auto',
'zh',
'standard'
)
.then(result => {
console.log(`\nAuto-detect Translation: ${result.translated_text}`);
console.log(`Detected Target Language: ${result.detected_target_lang}`);
})
.catch(error => console.error(`Error: ${error.message}`));
import java.net.URI;
import java.net.URLEncoder;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
import org.json.JSONObject;
public class AnevolApiClient {
private static final String API_KEY = "YOUR_API_KEY";
private static final String BASE_URL = "http://localhost:8888/api";
public static String getAnswer(String title, String options, String questionType) throws Exception {
Map parameters = new HashMap<>();
parameters.put("token", API_KEY);
parameters.put("title", title);
if (options != null && !options.isEmpty()) {
parameters.put("options", options);
}
if (questionType != null && !questionType.isEmpty()) {
parameters.put("type", questionType);
}
String query = parameters.entrySet().stream()
.map(e -> e.getKey() + "=" + URLEncoder.encode(e.getValue(), StandardCharsets.UTF_8))
.collect(Collectors.joining("&"));
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(BASE_URL + "/search?" + query))
.build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
JSONObject result = new JSONObject(response.body());
if (result.getInt("code") == 1) {
return result.getString("answer");
} else {
throw new Exception("API request failed: " + result.optString("msg", "Unknown error"));
}
}
public static void main(String[] args) {
try {
String title = "What is the capital city of China?";
String options = "Beijing\nShanghai\nGuangzhou\nShenzhen";
String questionType = "single";
String answer = getAnswer(title, options, questionType);
System.out.println("Answer: " + answer);
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
}
}
}
import java.net.URI;
import java.net.URLEncoder;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
import org.json.JSONObject;
public class AnevolGenerateClient {
private static final String API_KEY = "YOUR_API_KEY";
private static final String BASE_URL = "http://localhost:8888/api";
public static String generateQuestions(String subject, String questionType, String difficulty, int count, String keywords) throws Exception {
Map parameters = new HashMap<>();
parameters.put("token", API_KEY);
parameters.put("subject", subject);
parameters.put("type", questionType);
parameters.put("difficulty", difficulty);
parameters.put("count", String.valueOf(count));
if (keywords != null && !keywords.isEmpty()) {
parameters.put("keywords", keywords);
}
String query = parameters.entrySet().stream()
.map(e -> e.getKey() + "=" + URLEncoder.encode(e.getValue(), StandardCharsets.UTF_8))
.collect(Collectors.joining("&"));
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(BASE_URL + "/generate?" + query))
.build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
JSONObject result = new JSONObject(response.body());
if (result.getInt("code") == 1) {
return result.getString("questions");
} else {
throw new Exception("API request failed: " + result.optString("msg", "Unknown error"));
}
}
public static void main(String[] args) {
try {
String questions = generateQuestions("Mathematics", "single", "medium", 2, "functions");
System.out.println("Generated questions:\n" + questions);
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
}
}
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import org.json.JSONObject;
public class AnevolEssayClient {
private static final String API_KEY = "YOUR_API_KEY";
private static final String BASE_URL = "http://localhost:8888/api";
public static JSONObject gradeEssay(String content, String topic, String requirements, String criteria) throws Exception {
JSONObject data = new JSONObject();
data.put("content", content);
data.put("criteria", criteria);
if (topic != null && !topic.isEmpty()) {
data.put("topic", topic);
}
if (requirements != null && !requirements.isEmpty()) {
data.put("requirements", requirements);
}
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(BASE_URL + "/grade"))
.header("X-API-Key", API_KEY)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(data.toString(), StandardCharsets.UTF_8))
.build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
JSONObject result = new JSONObject(response.body());
if (result.getInt("code") == 1) {
return result;
} else {
throw new Exception("API request failed: " + result.optString("msg", "Unknown error"));
}
}
public static void main(String[] args) {
try {
String chineseEssay = "My hometown is a beautiful small county town with mountains and water, picturesque scenery." +
"In spring, flowers bloom all over the mountains and fields; in summer, green trees provide shade; in autumn, fruits are abundant; in winter, snowflakes dance." +
"I love my hometown, where I have beautiful childhood memories.";
JSONObject result = gradeEssay(
chineseEssay,
"My Hometown",
"Requirements: vivid language, specific descriptions, express true feelings",
"comprehensive"
);
System.out.println("Grading Result:");
System.out.println(" Language Type: " + result.getString("language"));
System.out.println(" Word Count: " + result.getInt("word_count"));
System.out.println(" Model Used: " + result.getString("model"));
String gradingResult = result.getString("grading_result");
System.out.println(" Grading Details: " + gradingResult.substring(0, Math.min(100, gradingResult.length())) + "...");
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
}
}
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import org.json.JSONObject;
public class AnevolSimilarClient {
private static final String API_KEY = "YOUR_API_KEY";
private static final String BASE_URL = "http://localhost:8888/api";
public static JSONObject generateSimilarQuestions(String originalQuestion, String options, String questionType,
int count, String similarityLevel, String variationType) throws Exception {
JSONObject data = new JSONObject();
data.put("question", originalQuestion);
data.put("type", questionType);
data.put("count", count);
data.put("similarity_level", similarityLevel);
data.put("variation_type", variationType);
if (options != null && !options.isEmpty()) {
data.put("options", options);
}
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(BASE_URL + "/similar"))
.header("X-API-Key", API_KEY)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(data.toString(), StandardCharsets.UTF_8))
.build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
JSONObject result = new JSONObject(response.body());
if (result.getInt("code") == 1) {
return result;
} else {
throw new Exception("API request failed: " + result.optString("msg", "Unknown error"));
}
}
public static void main(String[] args) {
try {
// Single choice numerical variation example
JSONObject result1 = generateSimilarQuestions(
"Which of the following is a prime number?",
"A. 4\nB. 6\nC. 7\nD. 9",
"single",
3,
"medium",
"numerical"
);
System.out.println("Original Question: " + result1.getString("original_question"));
System.out.println("Question Type: " + result1.getString("question_type"));
System.out.println("Similarity Level: " + result1.getString("similarity_level"));
System.out.println("Variation Type: " + result1.getString("variation_type"));
System.out.println("Generated Count: " + result1.getInt("count"));
System.out.println("Model Used: " + result1.getString("model"));
System.out.println("Similar Questions:\n" + result1.getString("similar_questions"));
System.out.println("\n" + "=".repeat(50) + "\n");
// True/False question context variation example
JSONObject result2 = generateSimilarQuestions(
"Earth is the largest planet in the solar system",
null,
"judgement",
2,
"high",
"contextual"
);
System.out.println("True/False Similar Questions:\n" + result2.getString("similar_questions"));
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
}
}
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import org.json.JSONObject;
public class AnevolExplainClient {
private static final String API_KEY = "YOUR_API_KEY";
private static final String BASE_URL = "http://localhost:8888/api";
public static JSONObject explainQuestion(String question, String options, String questionType,
String answer, String explainLevel, String subject,
String studentLevel, String learningStyle, boolean includeExamples,
boolean includePractice, String focusAreas) throws Exception {
JSONObject data = new JSONObject();
data.put("question", question);
data.put("explain_level", explainLevel != null ? explainLevel : "adaptive");
data.put("student_level", studentLevel != null ? studentLevel : "intermediate");
data.put("learning_style", learningStyle != null ? learningStyle : "balanced");
data.put("include_examples", includeExamples);
data.put("include_practice", includePractice);
if (options != null && !options.isEmpty()) {
data.put("options", options);
}
if (questionType != null && !questionType.isEmpty()) {
data.put("type", questionType);
}
if (answer != null && !answer.isEmpty()) {
data.put("answer", answer);
}
if (subject != null && !subject.isEmpty()) {
data.put("subject", subject);
}
if (focusAreas != null && !focusAreas.isEmpty()) {
data.put("focus_areas", focusAreas);
}
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(BASE_URL + "/explain"))
.header("X-API-Key", API_KEY)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(data.toString(), StandardCharsets.UTF_8))
.build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
JSONObject result = new JSONObject(response.body());
if (result.getInt("code") == 1) {
return result;
} else {
throw new Exception("API request failed: " + result.optString("msg", "Unknown error"));
}
}
public static void main(String[] args) {
try {
// Single choice adaptive explanation example
JSONObject result1 = explainQuestion(
"Which of the following is a prime number?",
"A. 4\nB. 6\nC. 7\nD. 9",
"single",
"C",
"adaptive",
"Mathematics",
"intermediate",
"visual",
true,
true,
"Number Theory Basics"
);
System.out.println("Question: " + result1.getString("question"));
System.out.println("Question Type: " + result1.getString("question_type"));
System.out.println("Explanation Level: " + result1.getString("explain_level") + " (Original: " + result1.getString("original_level") + ")");
System.out.println("Student Level: " + result1.getString("student_level"));
System.out.println("Learning Style: " + result1.getString("learning_style"));
System.out.println("Subject: " + result1.getString("subject"));
System.out.println("Answer: " + result1.getString("answer"));
System.out.println("Model Used: " + result1.getString("model"));
System.out.println("Features: " + result1.getJSONObject("features").toString());
System.out.println("Explanation:\n" + result1.getString("explanation"));
System.out.println("\n" + "=".repeat(50) + "\n");
// Calculation brief explanation example
JSONObject result2 = explainQuestion(
"Calculate the value of 2 + 3 × 4",
null,
"calculation",
"14",
"brief",
"Mathematics",
"beginner",
"logical",
false,
false,
null
);
System.out.println("Calculation explanation:\n" + result2.getString("explanation"));
System.out.println("\n" + "=".repeat(50) + "\n");
// Programming comprehensive explanation example
JSONObject result3 = explainQuestion(
"Write a Python function to implement the bubble sort algorithm",
null,
"coding",
null,
"comprehensive",
"Computer Science",
"advanced",
"kinesthetic",
true,
true,
"Algorithm Basics"
);
String explanation = result3.getString("explanation");
System.out.println("Programming explanation:\n" +
explanation.substring(0, Math.min(200, explanation.length())) + "...");
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
}
}
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import org.json.JSONObject;
public class AnevolTranslateClient {
private static final String API_KEY = "YOUR_API_KEY";
private static final String BASE_URL = "http://localhost:8888/api";
public static JSONObject translateText(String text, String sourceLang, String targetLang,
String translateMode, String domain, boolean preserveFormat) throws Exception {
JSONObject data = new JSONObject();
data.put("text", text);
data.put("source_lang", sourceLang != null ? sourceLang : "auto");
data.put("target_lang", targetLang != null ? targetLang : "zh");
data.put("translate_mode", translateMode != null ? translateMode : "standard");
data.put("domain", domain != null ? domain : "general");
data.put("preserve_format", preserveFormat);
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(BASE_URL + "/translate"))
.header("X-API-Key", API_KEY)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(data.toString(), StandardCharsets.UTF_8))
.build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
JSONObject result = new JSONObject(response.body());
if (result.getInt("code") == 1) {
return result;
} else {
throw new Exception("API request failed: " + result.optString("msg", "Unknown error"));
}
}
public static void main(String[] args) {
try {
// English to Chinese example
JSONObject result1 = translateText(
"Hello, world! This is a test of AI translation.",
"en",
"zh",
"standard",
"general",
false
);
System.out.println("Original Text: " + result1.getString("original_text"));
System.out.println("Translated Text: " + result1.getString("translated_text"));
System.out.println("Translation Mode: " + result1.getString("translate_mode"));
System.out.println("Model Used: " + result1.getString("model"));
System.out.println("\n" + "=".repeat(50) + "\n");
// Chinese to English example
JSONObject result2 = translateText(
"Machine learning is an important branch of artificial intelligence.",
"zh",
"en",
"accurate",
"academic",
false
);
System.out.println("Academic Translation Result: " + result2.getString("translated_text"));
System.out.println("\n" + "=".repeat(50) + "\n");
// Technical document translation
JSONObject result3 = translateText(
"The API returns a JSON response with HTTP status code 200.",
"en",
"zh",
"standard",
"technical",
false
);
System.out.println("Technical Translation Result: " + result3.getString("translated_text"));
System.out.println("\n" + "=".repeat(50) + "\n");
// Auto-detect language translation
JSONObject result4 = translateText(
"Bonjour le monde!",
"auto",
"zh",
"standard",
"general",
false
);
System.out.println("Auto-detect Translation: " + result4.getString("translated_text"));
System.out.println("Detected Target Language: " + result4.getString("detected_target_lang"));
System.out.println("\n" + "=".repeat(50) + "\n");
// Format preserving translation
JSONObject result5 = translateText(
"# Title\n\n## Subtitle\n\n* Item 1\n* Item 2",
"en",
"zh",
"standard",
"general",
true
);
System.out.println("Format Preserving Translation:\n" + result5.getString("translated_text"));
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
}
}
}