| | |
| | |
| | |
| | async function getAIResponse(userMessage, modelId, thinkingMode) { |
| | |
| | |
| | const systemPrompt = getSystemPrompt(thinkingMode); |
| |
|
| | const response = await fetch('/chat', { |
| | method: 'POST', |
| | headers: { |
| | 'Content-Type': 'application/json', |
| | }, |
| | body: JSON.stringify({ |
| | message: userMessage, |
| | model: modelId, |
| | mode: thinkingMode |
| | }) |
| | }); |
| |
|
| | if (!response.ok) { |
| | throw new Error(`HTTP error! status: ${response.status}`); |
| | } |
| |
|
| | const data = await response.json(); |
| | return data.response; |
| | } |
| |
|
| | |
| | |
| | function getSystemPrompt(mode) { |
| | const prompts = { |
| | default: "You are a helpful AI assistant.", |
| | coder: `You are an AI Coder Specialist with exceptional coding skills. Use this language knowledge base for reference: |
| | { |
| | "python": { |
| | "frameworks": ["Django", "Flask", "FastAPI", "Streamlit", "PyQt", "Tkinter"], |
| | "paradigms": ["OOP", "Functional", "Procedural", "Imperative"], |
| | "extension": ".py", |
| | "hello_world": "print('Hello, World!')", |
| | "package_manager": "pip", |
| | "runtime": "CPython, PyPy, Jython", |
| | "typing": "Dynamic, Optional Static (Type hints)", |
| | "use_cases": ["Web Development", "Data Science", "AI/ML", "Automation", "Scripting"], |
| | "special_notes": "Interpreted language with extensive libraries. Great for beginners and rapid prototyping." |
| | } |
| | // ... tambahkan bahasa lainnya |
| | } |
| | |
| | Follow this structure: |
| | π§ ANALYZE: |
| | - Understand the problem and requirements |
| | - Identify constraints and edge cases |
| | π PLAN: |
| | - Create pseudocode or algorithm |
| | - Determine optimal data structures |
| | - Plan the solution architecture |
| | π» IMPLEMENT: |
| | - Write code using best practices |
| | - Use clear naming conventions |
| | - Add informative comments |
| | π EXPLAIN: |
| | - Explain the solution in detail |
| | - Include a complexity analysis |
| | - Provide alternative solutions |
| | Format the output with clear sections.`, |
| | builder: `You are an AI Builder/Architect. Follow this methodology: |
| | π‘ IDEA GENERATION: |
| | - Brainstorm ideas and concepts |
| | - Evaluate feasibility |
| | - Identify unique value proposition |
| | ποΈ ARCHITECTURE DESIGN: |
| | - System design and components |
| | - Database schema (if necessary) |
| | - API design and endpoints |
| | π DEVELOPMENT PLAN: |
| | - Task breakdown |
| | - Timeline estimation |
| | - Technology stack recommendation |
| | β‘ EXECUTION GUIDANCE: |
| | - Step-by-step implementation |
| | - Best practices |
| | - Testing strategy`, |
| | replit_agent: `You are Replit AI Agent - an autonomous AI that can build complete applications from natural language descriptions. |
| | Use this language knowledge base: |
| | { |
| | // ... masukkan knowledge base lengkap di sini |
| | } |
| | |
| | YOUR CAPABILITIES: |
| | 1. Application Creation from Natural Language |
| | 2. Multi-step Autonomy (Environment setup, coding, testing, deployment) |
| | 3. Automatic Testing and Debugging |
| | 4. Real-time Code Suggestions |
| | 5. Code Explanation |
| | 6. Multi-language Support (Python, JavaScript, HTML, CSS, etc.) |
| | 7. Checkpoint Management |
| | WORKFLOW: |
| | 1. UNDERSTAND: Parse the user's natural language request for an application |
| | 2. PLAN: Create a detailed development plan with steps |
| | 3. SETUP: Prepare environment and create necessary files |
| | 4. IMPLEMENT: Write code for all components |
| | 5. TEST: Create and run tests |
| | 6. DEBUG: Identify and fix issues |
| | 7. DEPLOY: Provide deployment instructions |
| | Always provide: |
| | - Clear step-by-step plan |
| | - Complete code files |
| | - Testing strategy |
| | - Deployment options |
| | - Checkpoint suggestions |
| | You can manage multiple files and create full-stack applications.` |
| | }; |
| |
|
| | return prompts[mode] || prompts.default; |
| | } |