@ruaruababa/vibe-kit 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CATALOG.md +317 -0
- package/README.md +121 -0
- package/aliases.json +65 -0
- package/bin/vibe.js +2 -0
- package/bundles.json +265 -0
- package/catalog.json +1560 -0
- package/dist/antigravity-skills/bin/cli.js +438 -0
- package/dist/antigravity-skills/lib/skill-utils.js +158 -0
- package/dist/antigravity-skills/scripts/build-catalog.js +305 -0
- package/dist/antigravity-skills/scripts/normalize-frontmatter.js +144 -0
- package/dist/antigravity-skills/scripts/validate-skills.js +230 -0
- package/dist/bin/vibe.js +2 -0
- package/dist/dist/src/cli/index.js +26 -0
- package/dist/lib/skill-utils.js +158 -0
- package/dist/scripts/build-catalog.js +50 -0
- package/dist/scripts/normalize-frontmatter.js +144 -0
- package/dist/scripts/validate-skills.js +56 -0
- package/dist/src/cli/index.js +146 -0
- package/dist/src/types/index.js +13 -0
- package/dist/src/utils/fs.js +1 -0
- package/package.json +43 -0
- package/skills/accessibility-compliance-accessibility-audit/SKILL.md +42 -0
- package/skills/accessibility-compliance-accessibility-audit/resources/implementation-playbook.md +502 -0
- package/skills/agent-orchestration-improve-agent/SKILL.md +349 -0
- package/skills/agent-orchestration-multi-agent-optimize/SKILL.md +239 -0
- package/skills/agent-orchestrator/SKILL.md +24 -0
- package/skills/ai-engineer/SKILL.md +171 -0
- package/skills/airflow-dag-patterns/SKILL.md +41 -0
- package/skills/airflow-dag-patterns/resources/implementation-playbook.md +509 -0
- package/skills/angular-migration/SKILL.md +428 -0
- package/skills/anti-reversing-techniques/SKILL.md +42 -0
- package/skills/anti-reversing-techniques/resources/implementation-playbook.md +539 -0
- package/skills/api-design-principles/SKILL.md +37 -0
- package/skills/api-design-principles/assets/api-design-checklist.md +155 -0
- package/skills/api-design-principles/assets/rest-api-template.py +182 -0
- package/skills/api-design-principles/references/graphql-schema-design.md +583 -0
- package/skills/api-design-principles/references/rest-best-practices.md +408 -0
- package/skills/api-design-principles/resources/implementation-playbook.md +513 -0
- package/skills/api-documenter/SKILL.md +184 -0
- package/skills/api-testing-observability-api-mock/SKILL.md +46 -0
- package/skills/api-testing-observability-api-mock/resources/implementation-playbook.md +1327 -0
- package/skills/application-performance-performance-optimization/SKILL.md +154 -0
- package/skills/architect-review/SKILL.md +174 -0
- package/skills/architecture-decision-records/SKILL.md +441 -0
- package/skills/architecture-patterns/SKILL.md +37 -0
- package/skills/architecture-patterns/resources/implementation-playbook.md +479 -0
- package/skills/arm-cortex-expert/SKILL.md +306 -0
- package/skills/async-python-patterns/SKILL.md +39 -0
- package/skills/async-python-patterns/resources/implementation-playbook.md +678 -0
- package/skills/attack-tree-construction/SKILL.md +38 -0
- package/skills/attack-tree-construction/resources/implementation-playbook.md +671 -0
- package/skills/auth-implementation-patterns/SKILL.md +39 -0
- package/skills/auth-implementation-patterns/resources/implementation-playbook.md +618 -0
- package/skills/backend-architect/SKILL.md +333 -0
- package/skills/backend-development-feature-development/SKILL.md +180 -0
- package/skills/backend-security-coder/SKILL.md +156 -0
- package/skills/backtesting-frameworks/SKILL.md +39 -0
- package/skills/backtesting-frameworks/resources/implementation-playbook.md +647 -0
- package/skills/bash-defensive-patterns/SKILL.md +43 -0
- package/skills/bash-defensive-patterns/resources/implementation-playbook.md +517 -0
- package/skills/bash-pro/SKILL.md +310 -0
- package/skills/bats-testing-patterns/SKILL.md +34 -0
- package/skills/bats-testing-patterns/resources/implementation-playbook.md +614 -0
- package/skills/bazel-build-optimization/SKILL.md +397 -0
- package/skills/billing-automation/SKILL.md +42 -0
- package/skills/billing-automation/resources/implementation-playbook.md +544 -0
- package/skills/binary-analysis-patterns/SKILL.md +450 -0
- package/skills/blockchain-developer/SKILL.md +208 -0
- package/skills/business-analyst/SKILL.md +182 -0
- package/skills/c-pro/SKILL.md +56 -0
- package/skills/c4-architecture-c4-architecture/SKILL.md +389 -0
- package/skills/c4-code/SKILL.md +244 -0
- package/skills/c4-component/SKILL.md +153 -0
- package/skills/c4-container/SKILL.md +171 -0
- package/skills/c4-context/SKILL.md +150 -0
- package/skills/changelog-automation/SKILL.md +38 -0
- package/skills/changelog-automation/resources/implementation-playbook.md +538 -0
- package/skills/cicd-automation-workflow-automate/SKILL.md +51 -0
- package/skills/cicd-automation-workflow-automate/resources/implementation-playbook.md +1333 -0
- package/skills/clean-markdown/SKILL.md +23 -0
- package/skills/cloud-architect/SKILL.md +135 -0
- package/skills/code-documentation-code-explain/SKILL.md +46 -0
- package/skills/code-documentation-code-explain/resources/implementation-playbook.md +802 -0
- package/skills/code-documentation-doc-generate/SKILL.md +48 -0
- package/skills/code-documentation-doc-generate/resources/implementation-playbook.md +640 -0
- package/skills/code-refactoring-context-restore/SKILL.md +179 -0
- package/skills/code-refactoring-refactor-clean/SKILL.md +51 -0
- package/skills/code-refactoring-refactor-clean/resources/implementation-playbook.md +879 -0
- package/skills/code-refactoring-tech-debt/SKILL.md +386 -0
- package/skills/code-review-ai-ai-review/SKILL.md +450 -0
- package/skills/code-review-excellence/SKILL.md +40 -0
- package/skills/code-review-excellence/resources/implementation-playbook.md +515 -0
- package/skills/code-reviewer/SKILL.md +178 -0
- package/skills/codebase-cleanup-deps-audit/SKILL.md +51 -0
- package/skills/codebase-cleanup-deps-audit/resources/implementation-playbook.md +766 -0
- package/skills/codebase-cleanup-refactor-clean/SKILL.md +51 -0
- package/skills/codebase-cleanup-refactor-clean/resources/implementation-playbook.md +879 -0
- package/skills/codebase-cleanup-tech-debt/SKILL.md +386 -0
- package/skills/competitive-landscape/SKILL.md +34 -0
- package/skills/competitive-landscape/resources/implementation-playbook.md +494 -0
- package/skills/comprehensive-review-full-review/SKILL.md +146 -0
- package/skills/comprehensive-review-pr-enhance/SKILL.md +46 -0
- package/skills/comprehensive-review-pr-enhance/resources/implementation-playbook.md +691 -0
- package/skills/conductor-implement/SKILL.md +388 -0
- package/skills/conductor-manage/SKILL.md +39 -0
- package/skills/conductor-manage/resources/implementation-playbook.md +1120 -0
- package/skills/conductor-new-track/SKILL.md +433 -0
- package/skills/conductor-revert/SKILL.md +372 -0
- package/skills/conductor-setup/SKILL.md +426 -0
- package/skills/conductor-status/SKILL.md +338 -0
- package/skills/conductor-validator/SKILL.md +62 -0
- package/skills/content-marketer/SKILL.md +170 -0
- package/skills/context-driven-development/SKILL.md +400 -0
- package/skills/context-management-context-restore/SKILL.md +179 -0
- package/skills/context-management-context-save/SKILL.md +177 -0
- package/skills/context-manager/SKILL.md +185 -0
- package/skills/cost-optimization/SKILL.md +286 -0
- package/skills/cpp-pro/SKILL.md +59 -0
- package/skills/cqrs-implementation/SKILL.md +35 -0
- package/skills/cqrs-implementation/resources/implementation-playbook.md +540 -0
- package/skills/csharp-pro/SKILL.md +59 -0
- package/skills/customer-support/SKILL.md +170 -0
- package/skills/data-engineer/SKILL.md +224 -0
- package/skills/data-engineering-data-driven-feature/SKILL.md +182 -0
- package/skills/data-engineering-data-pipeline/SKILL.md +201 -0
- package/skills/data-quality-frameworks/SKILL.md +40 -0
- package/skills/data-quality-frameworks/resources/implementation-playbook.md +573 -0
- package/skills/data-scientist/SKILL.md +199 -0
- package/skills/data-storytelling/SKILL.md +465 -0
- package/skills/database-admin/SKILL.md +165 -0
- package/skills/database-architect/SKILL.md +268 -0
- package/skills/database-cloud-optimization-cost-optimize/SKILL.md +44 -0
- package/skills/database-cloud-optimization-cost-optimize/resources/implementation-playbook.md +1441 -0
- package/skills/database-migration/SKILL.md +436 -0
- package/skills/database-migrations-migration-observability/SKILL.md +420 -0
- package/skills/database-migrations-sql-migrations/SKILL.md +53 -0
- package/skills/database-migrations-sql-migrations/resources/implementation-playbook.md +499 -0
- package/skills/database-optimizer/SKILL.md +167 -0
- package/skills/dbt-transformation-patterns/SKILL.md +34 -0
- package/skills/dbt-transformation-patterns/resources/implementation-playbook.md +547 -0
- package/skills/debugger/SKILL.md +49 -0
- package/skills/debugging-strategies/SKILL.md +34 -0
- package/skills/debugging-strategies/resources/implementation-playbook.md +511 -0
- package/skills/debugging-toolkit-smart-debug/SKILL.md +197 -0
- package/skills/defi-protocol-templates/SKILL.md +466 -0
- package/skills/dependency-management-deps-audit/SKILL.md +44 -0
- package/skills/dependency-management-deps-audit/resources/implementation-playbook.md +766 -0
- package/skills/dependency-upgrade/SKILL.md +421 -0
- package/skills/deployment-engineer/SKILL.md +170 -0
- package/skills/deployment-pipeline-design/SKILL.md +371 -0
- package/skills/deployment-validation-config-validate/SKILL.md +496 -0
- package/skills/devops-troubleshooter/SKILL.md +161 -0
- package/skills/distributed-debugging-debug-trace/SKILL.md +44 -0
- package/skills/distributed-debugging-debug-trace/resources/implementation-playbook.md +1307 -0
- package/skills/distributed-tracing/SKILL.md +450 -0
- package/skills/django-pro/SKILL.md +180 -0
- package/skills/docs-architect/SKILL.md +98 -0
- package/skills/documentation-generation-doc-generate/SKILL.md +48 -0
- package/skills/documentation-generation-doc-generate/resources/implementation-playbook.md +640 -0
- package/skills/dotnet-architect/SKILL.md +197 -0
- package/skills/dotnet-backend-patterns/SKILL.md +37 -0
- package/skills/dotnet-backend-patterns/assets/repository-template.cs +523 -0
- package/skills/dotnet-backend-patterns/assets/service-template.cs +336 -0
- package/skills/dotnet-backend-patterns/references/dapper-patterns.md +544 -0
- package/skills/dotnet-backend-patterns/references/ef-core-best-practices.md +355 -0
- package/skills/dotnet-backend-patterns/resources/implementation-playbook.md +799 -0
- package/skills/dummy-skill/SKILL.md +5 -0
- package/skills/dx-optimizer/SKILL.md +83 -0
- package/skills/e2e-testing-patterns/SKILL.md +41 -0
- package/skills/e2e-testing-patterns/resources/implementation-playbook.md +531 -0
- package/skills/elixir-pro/SKILL.md +59 -0
- package/skills/embedding-strategies/SKILL.md +491 -0
- package/skills/employment-contract-templates/SKILL.md +39 -0
- package/skills/employment-contract-templates/resources/implementation-playbook.md +493 -0
- package/skills/error-debugging-error-analysis/SKILL.md +47 -0
- package/skills/error-debugging-error-analysis/resources/implementation-playbook.md +1143 -0
- package/skills/error-debugging-error-trace/SKILL.md +43 -0
- package/skills/error-debugging-error-trace/resources/implementation-playbook.md +1361 -0
- package/skills/error-debugging-multi-agent-review/SKILL.md +216 -0
- package/skills/error-detective/SKILL.md +53 -0
- package/skills/error-diagnostics-error-analysis/SKILL.md +47 -0
- package/skills/error-diagnostics-error-analysis/resources/implementation-playbook.md +1143 -0
- package/skills/error-diagnostics-error-trace/SKILL.md +48 -0
- package/skills/error-diagnostics-error-trace/resources/implementation-playbook.md +1371 -0
- package/skills/error-diagnostics-smart-debug/SKILL.md +197 -0
- package/skills/error-handling-patterns/SKILL.md +35 -0
- package/skills/error-handling-patterns/resources/implementation-playbook.md +635 -0
- package/skills/event-sourcing-architect/SKILL.md +58 -0
- package/skills/event-store-design/SKILL.md +449 -0
- package/skills/fastapi-pro/SKILL.md +192 -0
- package/skills/fastapi-templates/SKILL.md +32 -0
- package/skills/fastapi-templates/resources/implementation-playbook.md +566 -0
- package/skills/final-test/SKILL.md +5 -0
- package/skills/firmware-analyst/SKILL.md +320 -0
- package/skills/flutter-expert/SKILL.md +200 -0
- package/skills/framework-migration-code-migrate/SKILL.md +48 -0
- package/skills/framework-migration-code-migrate/resources/implementation-playbook.md +1052 -0
- package/skills/framework-migration-deps-upgrade/SKILL.md +48 -0
- package/skills/framework-migration-deps-upgrade/resources/implementation-playbook.md +755 -0
- package/skills/framework-migration-legacy-modernize/SKILL.md +132 -0
- package/skills/frontend-developer/SKILL.md +171 -0
- package/skills/frontend-mobile-development-component-scaffold/SKILL.md +403 -0
- package/skills/frontend-mobile-security-xss-scan/SKILL.md +322 -0
- package/skills/frontend-security-coder/SKILL.md +170 -0
- package/skills/full-stack-orchestration-full-stack-feature/SKILL.md +135 -0
- package/skills/gdpr-data-handling/SKILL.md +33 -0
- package/skills/gdpr-data-handling/resources/implementation-playbook.md +615 -0
- package/skills/git-advanced-workflows/SKILL.md +412 -0
- package/skills/git-pr-workflows-git-workflow/SKILL.md +140 -0
- package/skills/git-pr-workflows-onboard/SKILL.md +416 -0
- package/skills/git-pr-workflows-pr-enhance/SKILL.md +48 -0
- package/skills/git-pr-workflows-pr-enhance/resources/implementation-playbook.md +701 -0
- package/skills/github-actions-templates/SKILL.md +345 -0
- package/skills/gitlab-ci-patterns/SKILL.md +283 -0
- package/skills/gitops-workflow/SKILL.md +303 -0
- package/skills/gitops-workflow/references/argocd-setup.md +134 -0
- package/skills/gitops-workflow/references/sync-policies.md +131 -0
- package/skills/go-concurrency-patterns/SKILL.md +33 -0
- package/skills/go-concurrency-patterns/resources/implementation-playbook.md +654 -0
- package/skills/godot-gdscript-patterns/SKILL.md +33 -0
- package/skills/godot-gdscript-patterns/resources/implementation-playbook.md +804 -0
- package/skills/golang-pro/SKILL.md +179 -0
- package/skills/grafana-dashboards/SKILL.md +381 -0
- package/skills/graphql-architect/SKILL.md +182 -0
- package/skills/haskell-pro/SKILL.md +56 -0
- package/skills/helm-chart-scaffolding/SKILL.md +34 -0
- package/skills/helm-chart-scaffolding/assets/Chart.yaml.template +42 -0
- package/skills/helm-chart-scaffolding/assets/values.yaml.template +185 -0
- package/skills/helm-chart-scaffolding/references/chart-structure.md +500 -0
- package/skills/helm-chart-scaffolding/resources/implementation-playbook.md +543 -0
- package/skills/helm-chart-scaffolding/scripts/validate-chart.sh +244 -0
- package/skills/hr-pro/SKILL.md +126 -0
- package/skills/hybrid-cloud-architect/SKILL.md +168 -0
- package/skills/hybrid-cloud-networking/SKILL.md +238 -0
- package/skills/hybrid-search-implementation/SKILL.md +32 -0
- package/skills/hybrid-search-implementation/resources/implementation-playbook.md +567 -0
- package/skills/incident-responder/SKILL.md +213 -0
- package/skills/incident-response-incident-response/SKILL.md +168 -0
- package/skills/incident-response-smart-fix/SKILL.md +29 -0
- package/skills/incident-response-smart-fix/resources/implementation-playbook.md +838 -0
- package/skills/incident-runbook-templates/SKILL.md +395 -0
- package/skills/ios-developer/SKILL.md +219 -0
- package/skills/istio-traffic-management/SKILL.md +337 -0
- package/skills/java-pro/SKILL.md +177 -0
- package/skills/javascript-pro/SKILL.md +57 -0
- package/skills/javascript-testing-patterns/SKILL.md +35 -0
- package/skills/javascript-testing-patterns/resources/implementation-playbook.md +1024 -0
- package/skills/javascript-typescript-typescript-scaffold/SKILL.md +361 -0
- package/skills/julia-pro/SKILL.md +209 -0
- package/skills/k8s-manifest-generator/SKILL.md +35 -0
- package/skills/k8s-manifest-generator/assets/configmap-template.yaml +296 -0
- package/skills/k8s-manifest-generator/assets/deployment-template.yaml +203 -0
- package/skills/k8s-manifest-generator/assets/service-template.yaml +171 -0
- package/skills/k8s-manifest-generator/references/deployment-spec.md +753 -0
- package/skills/k8s-manifest-generator/references/service-spec.md +724 -0
- package/skills/k8s-manifest-generator/resources/implementation-playbook.md +510 -0
- package/skills/k8s-security-policies/SKILL.md +346 -0
- package/skills/k8s-security-policies/assets/network-policy-template.yaml +177 -0
- package/skills/k8s-security-policies/references/rbac-patterns.md +187 -0
- package/skills/kpi-dashboard-design/SKILL.md +440 -0
- package/skills/kubernetes-architect/SKILL.md +170 -0
- package/skills/langchain-architecture/SKILL.md +350 -0
- package/skills/legacy-modernizer/SKILL.md +53 -0
- package/skills/legal-advisor/SKILL.md +70 -0
- package/skills/linkerd-patterns/SKILL.md +321 -0
- package/skills/llm-application-dev-ai-assistant/SKILL.md +35 -0
- package/skills/llm-application-dev-ai-assistant/resources/implementation-playbook.md +1236 -0
- package/skills/llm-application-dev-langchain-agent/SKILL.md +246 -0
- package/skills/llm-application-dev-prompt-optimize/SKILL.md +37 -0
- package/skills/llm-application-dev-prompt-optimize/resources/implementation-playbook.md +591 -0
- package/skills/llm-evaluation/SKILL.md +483 -0
- package/skills/machine-learning-ops-ml-pipeline/SKILL.md +314 -0
- package/skills/malware-analyst/SKILL.md +247 -0
- package/skills/market-sizing-analysis/SKILL.md +425 -0
- package/skills/market-sizing-analysis/examples/saas-market-sizing.md +349 -0
- package/skills/market-sizing-analysis/references/data-sources.md +360 -0
- package/skills/memory-forensics/SKILL.md +491 -0
- package/skills/memory-safety-patterns/SKILL.md +33 -0
- package/skills/memory-safety-patterns/resources/implementation-playbook.md +603 -0
- package/skills/mermaid-expert/SKILL.md +59 -0
- package/skills/microservices-patterns/SKILL.md +35 -0
- package/skills/microservices-patterns/resources/implementation-playbook.md +607 -0
- package/skills/minecraft-bukkit-pro/SKILL.md +126 -0
- package/skills/ml-engineer/SKILL.md +168 -0
- package/skills/ml-pipeline-workflow/SKILL.md +257 -0
- package/skills/mlops-engineer/SKILL.md +219 -0
- package/skills/mobile-developer/SKILL.md +205 -0
- package/skills/mobile-security-coder/SKILL.md +184 -0
- package/skills/modern-javascript-patterns/SKILL.md +35 -0
- package/skills/modern-javascript-patterns/resources/implementation-playbook.md +910 -0
- package/skills/monorepo-architect/SKILL.md +61 -0
- package/skills/monorepo-management/SKILL.md +35 -0
- package/skills/monorepo-management/resources/implementation-playbook.md +621 -0
- package/skills/mtls-configuration/SKILL.md +359 -0
- package/skills/multi-cloud-architecture/SKILL.md +189 -0
- package/skills/multi-platform-apps-multi-platform/SKILL.md +203 -0
- package/skills/network-engineer/SKILL.md +169 -0
- package/skills/nextjs-app-router-patterns/SKILL.md +33 -0
- package/skills/nextjs-app-router-patterns/resources/implementation-playbook.md +543 -0
- package/skills/nft-standards/SKILL.md +395 -0
- package/skills/node-expert/SKILL.md +23 -0
- package/skills/nodejs-backend-patterns/SKILL.md +35 -0
- package/skills/nodejs-backend-patterns/resources/implementation-playbook.md +1019 -0
- package/skills/nx-workspace-patterns/SKILL.md +464 -0
- package/skills/observability-engineer/SKILL.md +237 -0
- package/skills/observability-monitoring-monitor-setup/SKILL.md +48 -0
- package/skills/observability-monitoring-monitor-setup/resources/implementation-playbook.md +505 -0
- package/skills/observability-monitoring-slo-implement/SKILL.md +43 -0
- package/skills/observability-monitoring-slo-implement/resources/implementation-playbook.md +1077 -0
- package/skills/on-call-handoff-patterns/SKILL.md +453 -0
- package/skills/openapi-spec-generation/SKILL.md +33 -0
- package/skills/openapi-spec-generation/resources/implementation-playbook.md +1027 -0
- package/skills/payment-integration/SKILL.md +77 -0
- package/skills/paypal-integration/SKILL.md +479 -0
- package/skills/pci-compliance/SKILL.md +478 -0
- package/skills/performance-engineer/SKILL.md +180 -0
- package/skills/performance-testing-review-ai-review/SKILL.md +450 -0
- package/skills/performance-testing-review-multi-agent-review/SKILL.md +216 -0
- package/skills/php-pro/SKILL.md +63 -0
- package/skills/posix-shell-pro/SKILL.md +304 -0
- package/skills/postgresql/SKILL.md +230 -0
- package/skills/postmortem-writing/SKILL.md +386 -0
- package/skills/projection-patterns/SKILL.md +33 -0
- package/skills/projection-patterns/resources/implementation-playbook.md +501 -0
- package/skills/prometheus-configuration/SKILL.md +404 -0
- package/skills/prompt-engineer/SKILL.md +272 -0
- package/skills/prompt-engineering-patterns/SKILL.md +213 -0
- package/skills/prompt-engineering-patterns/assets/few-shot-examples.json +106 -0
- package/skills/prompt-engineering-patterns/assets/prompt-template-library.md +246 -0
- package/skills/prompt-engineering-patterns/references/chain-of-thought.md +399 -0
- package/skills/prompt-engineering-patterns/references/few-shot-learning.md +369 -0
- package/skills/prompt-engineering-patterns/references/prompt-optimization.md +414 -0
- package/skills/prompt-engineering-patterns/references/prompt-templates.md +470 -0
- package/skills/prompt-engineering-patterns/references/system-prompts.md +189 -0
- package/skills/prompt-engineering-patterns/scripts/optimize-prompt.py +279 -0
- package/skills/protocol-reverse-engineering/SKILL.md +29 -0
- package/skills/protocol-reverse-engineering/resources/implementation-playbook.md +509 -0
- package/skills/python-development-python-scaffold/SKILL.md +331 -0
- package/skills/python-packaging/SKILL.md +36 -0
- package/skills/python-packaging/resources/implementation-playbook.md +869 -0
- package/skills/python-performance-optimization/SKILL.md +36 -0
- package/skills/python-performance-optimization/resources/implementation-playbook.md +868 -0
- package/skills/python-pro/SKILL.md +158 -0
- package/skills/python-testing-patterns/SKILL.md +37 -0
- package/skills/python-testing-patterns/resources/implementation-playbook.md +906 -0
- package/skills/quant-analyst/SKILL.md +53 -0
- package/skills/rag-implementation/SKILL.md +421 -0
- package/skills/react-modernization/SKILL.md +34 -0
- package/skills/react-modernization/resources/implementation-playbook.md +512 -0
- package/skills/react-native-architecture/SKILL.md +33 -0
- package/skills/react-native-architecture/resources/implementation-playbook.md +670 -0
- package/skills/react-state-management/SKILL.md +441 -0
- package/skills/reference-builder/SKILL.md +188 -0
- package/skills/reverse-engineer/SKILL.md +173 -0
- package/skills/risk-manager/SKILL.md +61 -0
- package/skills/risk-metrics-calculation/SKILL.md +33 -0
- package/skills/risk-metrics-calculation/resources/implementation-playbook.md +554 -0
- package/skills/ruby-pro/SKILL.md +56 -0
- package/skills/rust-async-patterns/SKILL.md +33 -0
- package/skills/rust-async-patterns/resources/implementation-playbook.md +516 -0
- package/skills/rust-pro/SKILL.md +178 -0
- package/skills/saga-orchestration/SKILL.md +496 -0
- package/skills/sales-automator/SKILL.md +55 -0
- package/skills/sast-configuration/SKILL.md +212 -0
- package/skills/scala-pro/SKILL.md +82 -0
- package/skills/screen-reader-testing/SKILL.md +33 -0
- package/skills/screen-reader-testing/resources/implementation-playbook.md +544 -0
- package/skills/search-specialist/SKILL.md +80 -0
- package/skills/secrets-management/SKILL.md +364 -0
- package/skills/security-auditor/SKILL.md +169 -0
- package/skills/security-compliance-compliance-check/SKILL.md +55 -0
- package/skills/security-compliance-compliance-check/resources/implementation-playbook.md +963 -0
- package/skills/security-requirement-extraction/SKILL.md +33 -0
- package/skills/security-requirement-extraction/resources/implementation-playbook.md +676 -0
- package/skills/security-scanning-security-dependencies/SKILL.md +43 -0
- package/skills/security-scanning-security-dependencies/resources/implementation-playbook.md +544 -0
- package/skills/security-scanning-security-hardening/SKILL.md +147 -0
- package/skills/security-scanning-security-sast/SKILL.md +495 -0
- package/skills/seo-authority-builder/SKILL.md +136 -0
- package/skills/seo-cannibalization-detector/SKILL.md +123 -0
- package/skills/seo-content-auditor/SKILL.md +83 -0
- package/skills/seo-content-planner/SKILL.md +108 -0
- package/skills/seo-content-refresher/SKILL.md +118 -0
- package/skills/seo-content-writer/SKILL.md +96 -0
- package/skills/seo-keyword-strategist/SKILL.md +95 -0
- package/skills/seo-meta-optimizer/SKILL.md +92 -0
- package/skills/seo-snippet-hunter/SKILL.md +114 -0
- package/skills/seo-structure-architect/SKILL.md +108 -0
- package/skills/service-mesh-expert/SKILL.md +58 -0
- package/skills/service-mesh-observability/SKILL.md +395 -0
- package/skills/shellcheck-configuration/SKILL.md +466 -0
- package/skills/similarity-search-patterns/SKILL.md +33 -0
- package/skills/similarity-search-patterns/resources/implementation-playbook.md +557 -0
- package/skills/slo-implementation/SKILL.md +341 -0
- package/skills/solidity-security/SKILL.md +34 -0
- package/skills/solidity-security/resources/implementation-playbook.md +524 -0
- package/skills/spark-optimization/SKILL.md +427 -0
- package/skills/sql-optimization-patterns/SKILL.md +35 -0
- package/skills/sql-optimization-patterns/resources/implementation-playbook.md +504 -0
- package/skills/sql-pro/SKILL.md +173 -0
- package/skills/startup-analyst/SKILL.md +328 -0
- package/skills/startup-business-analyst-business-case/SKILL.md +487 -0
- package/skills/startup-business-analyst-financial-projections/SKILL.md +353 -0
- package/skills/startup-business-analyst-market-opportunity/SKILL.md +240 -0
- package/skills/startup-financial-modeling/SKILL.md +467 -0
- package/skills/startup-metrics-framework/SKILL.md +34 -0
- package/skills/startup-metrics-framework/resources/implementation-playbook.md +500 -0
- package/skills/stride-analysis-patterns/SKILL.md +33 -0
- package/skills/stride-analysis-patterns/resources/implementation-playbook.md +655 -0
- package/skills/stripe-integration/SKILL.md +454 -0
- package/skills/systems-programming-rust-project/SKILL.md +440 -0
- package/skills/tailwind-design-system/SKILL.md +33 -0
- package/skills/tailwind-design-system/resources/implementation-playbook.md +665 -0
- package/skills/tdd-orchestrator/SKILL.md +205 -0
- package/skills/tdd-workflows-tdd-cycle/SKILL.md +221 -0
- package/skills/tdd-workflows-tdd-green/SKILL.md +73 -0
- package/skills/tdd-workflows-tdd-green/resources/implementation-playbook.md +870 -0
- package/skills/tdd-workflows-tdd-red/SKILL.md +164 -0
- package/skills/tdd-workflows-tdd-refactor/SKILL.md +187 -0
- package/skills/team-collaboration-issue/SKILL.md +37 -0
- package/skills/team-collaboration-issue/resources/implementation-playbook.md +640 -0
- package/skills/team-collaboration-standup-notes/SKILL.md +44 -0
- package/skills/team-collaboration-standup-notes/resources/implementation-playbook.md +768 -0
- package/skills/team-composition-analysis/SKILL.md +413 -0
- package/skills/temporal-python-pro/SKILL.md +370 -0
- package/skills/temporal-python-testing/SKILL.md +170 -0
- package/skills/temporal-python-testing/resources/integration-testing.md +455 -0
- package/skills/temporal-python-testing/resources/local-setup.md +553 -0
- package/skills/temporal-python-testing/resources/replay-testing.md +462 -0
- package/skills/temporal-python-testing/resources/unit-testing.md +328 -0
- package/skills/terraform-module-library/SKILL.md +261 -0
- package/skills/terraform-module-library/references/aws-modules.md +63 -0
- package/skills/terraform-specialist/SKILL.md +166 -0
- package/skills/test-automator/SKILL.md +224 -0
- package/skills/threat-mitigation-mapping/SKILL.md +33 -0
- package/skills/threat-mitigation-mapping/resources/implementation-playbook.md +744 -0
- package/skills/threat-modeling-expert/SKILL.md +60 -0
- package/skills/track-management/SKILL.md +38 -0
- package/skills/track-management/resources/implementation-playbook.md +591 -0
- package/skills/turborepo-caching/SKILL.md +419 -0
- package/skills/tutorial-engineer/SKILL.md +139 -0
- package/skills/typescript-advanced-types/SKILL.md +35 -0
- package/skills/typescript-advanced-types/resources/implementation-playbook.md +716 -0
- package/skills/typescript-pro/SKILL.md +55 -0
- package/skills/ui-minimal/SKILL.md +23 -0
- package/skills/ui-ux-designer/SKILL.md +209 -0
- package/skills/ui-visual-validator/SKILL.md +214 -0
- package/skills/unit-testing-test-generate/SKILL.md +319 -0
- package/skills/unity-developer/SKILL.md +230 -0
- package/skills/unity-ecs-patterns/SKILL.md +33 -0
- package/skills/unity-ecs-patterns/resources/implementation-playbook.md +625 -0
- package/skills/uv-package-manager/SKILL.md +37 -0
- package/skills/uv-package-manager/resources/implementation-playbook.md +830 -0
- package/skills/vector-database-engineer/SKILL.md +60 -0
- package/skills/vector-index-tuning/SKILL.md +42 -0
- package/skills/vector-index-tuning/resources/implementation-playbook.md +507 -0
- package/skills/wcag-audit-patterns/SKILL.md +41 -0
- package/skills/wcag-audit-patterns/resources/implementation-playbook.md +541 -0
- package/skills/web3-testing/SKILL.md +427 -0
- package/skills/workflow-orchestration-patterns/SKILL.md +333 -0
- package/skills/workflow-patterns/SKILL.md +38 -0
- package/skills/workflow-patterns/resources/implementation-playbook.md +621 -0
|
@@ -0,0 +1,1236 @@
|
|
|
1
|
+
# AI Assistant Development Implementation Playbook
|
|
2
|
+
|
|
3
|
+
This file contains detailed patterns, checklists, and code samples referenced by the skill.
|
|
4
|
+
|
|
5
|
+
# AI Assistant Development
|
|
6
|
+
|
|
7
|
+
You are an AI assistant development expert specializing in creating intelligent conversational interfaces, chatbots, and AI-powered applications. Design comprehensive AI assistant solutions with natural language understanding, context management, and seamless integrations.
|
|
8
|
+
|
|
9
|
+
## Context
|
|
10
|
+
The user needs to develop an AI assistant or chatbot with natural language capabilities, intelligent responses, and practical functionality. Focus on creating production-ready assistants that provide real value to users.
|
|
11
|
+
|
|
12
|
+
## Requirements
|
|
13
|
+
$ARGUMENTS
|
|
14
|
+
|
|
15
|
+
## Instructions
|
|
16
|
+
|
|
17
|
+
### 1. AI Assistant Architecture
|
|
18
|
+
|
|
19
|
+
Design comprehensive assistant architecture:
|
|
20
|
+
|
|
21
|
+
**Assistant Architecture Framework**
|
|
22
|
+
```python
|
|
23
|
+
from typing import Dict, List, Optional, Any
|
|
24
|
+
from dataclasses import dataclass
|
|
25
|
+
from abc import ABC, abstractmethod
|
|
26
|
+
import asyncio
|
|
27
|
+
|
|
28
|
+
@dataclass
|
|
29
|
+
class ConversationContext:
|
|
30
|
+
"""Maintains conversation state and context"""
|
|
31
|
+
user_id: str
|
|
32
|
+
session_id: str
|
|
33
|
+
messages: List[Dict[str, Any]]
|
|
34
|
+
user_profile: Dict[str, Any]
|
|
35
|
+
conversation_state: Dict[str, Any]
|
|
36
|
+
metadata: Dict[str, Any]
|
|
37
|
+
|
|
38
|
+
class AIAssistantArchitecture:
|
|
39
|
+
def __init__(self, config: Dict[str, Any]):
|
|
40
|
+
self.config = config
|
|
41
|
+
self.components = self._initialize_components()
|
|
42
|
+
|
|
43
|
+
def design_architecture(self):
|
|
44
|
+
"""Design comprehensive AI assistant architecture"""
|
|
45
|
+
return {
|
|
46
|
+
'core_components': {
|
|
47
|
+
'nlu': self._design_nlu_component(),
|
|
48
|
+
'dialog_manager': self._design_dialog_manager(),
|
|
49
|
+
'response_generator': self._design_response_generator(),
|
|
50
|
+
'context_manager': self._design_context_manager(),
|
|
51
|
+
'integration_layer': self._design_integration_layer()
|
|
52
|
+
},
|
|
53
|
+
'data_flow': self._design_data_flow(),
|
|
54
|
+
'deployment': self._design_deployment_architecture(),
|
|
55
|
+
'scalability': self._design_scalability_features()
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
def _design_nlu_component(self):
|
|
59
|
+
"""Natural Language Understanding component"""
|
|
60
|
+
return {
|
|
61
|
+
'intent_recognition': {
|
|
62
|
+
'model': 'transformer-based classifier',
|
|
63
|
+
'features': [
|
|
64
|
+
'Multi-intent detection',
|
|
65
|
+
'Confidence scoring',
|
|
66
|
+
'Fallback handling'
|
|
67
|
+
],
|
|
68
|
+
'implementation': '''
|
|
69
|
+
class IntentClassifier:
|
|
70
|
+
def __init__(self, model_path: str, *, config: Optional[Dict[str, Any]] = None):
|
|
71
|
+
self.model = self.load_model(model_path)
|
|
72
|
+
self.intents = self.load_intent_schema()
|
|
73
|
+
default_config = {"threshold": 0.65}
|
|
74
|
+
self.config = {**default_config, **(config or {})}
|
|
75
|
+
|
|
76
|
+
async def classify(self, text: str) -> Dict[str, Any]:
|
|
77
|
+
# Preprocess text
|
|
78
|
+
processed = self.preprocess(text)
|
|
79
|
+
|
|
80
|
+
# Get model predictions
|
|
81
|
+
predictions = await self.model.predict(processed)
|
|
82
|
+
|
|
83
|
+
# Extract intents with confidence
|
|
84
|
+
intents = []
|
|
85
|
+
for intent, confidence in predictions:
|
|
86
|
+
if confidence > self.config['threshold']:
|
|
87
|
+
intents.append({
|
|
88
|
+
'name': intent,
|
|
89
|
+
'confidence': confidence,
|
|
90
|
+
'parameters': self.extract_parameters(text, intent)
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
'intents': intents,
|
|
95
|
+
'primary_intent': intents[0] if intents else None,
|
|
96
|
+
'requires_clarification': len(intents) > 1
|
|
97
|
+
}
|
|
98
|
+
'''
|
|
99
|
+
},
|
|
100
|
+
'entity_extraction': {
|
|
101
|
+
'model': 'NER with custom entities',
|
|
102
|
+
'features': [
|
|
103
|
+
'Domain-specific entities',
|
|
104
|
+
'Contextual extraction',
|
|
105
|
+
'Entity resolution'
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
'sentiment_analysis': {
|
|
109
|
+
'model': 'Fine-tuned sentiment classifier',
|
|
110
|
+
'features': [
|
|
111
|
+
'Emotion detection',
|
|
112
|
+
'Urgency classification',
|
|
113
|
+
'User satisfaction tracking'
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
def _design_dialog_manager(self):
|
|
119
|
+
"""Dialog management system"""
|
|
120
|
+
return '''
|
|
121
|
+
class DialogManager:
|
|
122
|
+
"""Manages conversation flow and state"""
|
|
123
|
+
|
|
124
|
+
def __init__(self):
|
|
125
|
+
self.state_machine = ConversationStateMachine()
|
|
126
|
+
self.policy_network = DialogPolicy()
|
|
127
|
+
|
|
128
|
+
async def process_turn(self,
|
|
129
|
+
context: ConversationContext,
|
|
130
|
+
nlu_result: Dict[str, Any]) -> Dict[str, Any]:
|
|
131
|
+
# Determine current state
|
|
132
|
+
current_state = self.state_machine.get_state(context)
|
|
133
|
+
|
|
134
|
+
# Apply dialog policy
|
|
135
|
+
action = await self.policy_network.select_action(
|
|
136
|
+
current_state,
|
|
137
|
+
nlu_result,
|
|
138
|
+
context
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
# Execute action
|
|
142
|
+
result = await self.execute_action(action, context)
|
|
143
|
+
|
|
144
|
+
# Update state
|
|
145
|
+
new_state = self.state_machine.transition(
|
|
146
|
+
current_state,
|
|
147
|
+
action,
|
|
148
|
+
result
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
return {
|
|
152
|
+
'action': action,
|
|
153
|
+
'new_state': new_state,
|
|
154
|
+
'response_data': result
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
async def execute_action(self, action: str, context: ConversationContext):
|
|
158
|
+
"""Execute dialog action"""
|
|
159
|
+
action_handlers = {
|
|
160
|
+
'greet': self.handle_greeting,
|
|
161
|
+
'provide_info': self.handle_information_request,
|
|
162
|
+
'clarify': self.handle_clarification,
|
|
163
|
+
'confirm': self.handle_confirmation,
|
|
164
|
+
'execute_task': self.handle_task_execution,
|
|
165
|
+
'end_conversation': self.handle_conversation_end
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
handler = action_handlers.get(action, self.handle_unknown)
|
|
169
|
+
return await handler(context)
|
|
170
|
+
'''
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### 2. Natural Language Processing
|
|
174
|
+
|
|
175
|
+
Implement advanced NLP capabilities:
|
|
176
|
+
|
|
177
|
+
**NLP Pipeline Implementation**
|
|
178
|
+
```python
|
|
179
|
+
class NLPPipeline:
|
|
180
|
+
def __init__(self):
|
|
181
|
+
self.tokenizer = self._initialize_tokenizer()
|
|
182
|
+
self.embedder = self._initialize_embedder()
|
|
183
|
+
self.models = self._load_models()
|
|
184
|
+
|
|
185
|
+
async def process_message(self, message: str, context: ConversationContext):
|
|
186
|
+
"""Process user message through NLP pipeline"""
|
|
187
|
+
# Tokenization and preprocessing
|
|
188
|
+
tokens = self.tokenizer.tokenize(message)
|
|
189
|
+
|
|
190
|
+
# Generate embeddings
|
|
191
|
+
embeddings = await self.embedder.embed(tokens)
|
|
192
|
+
|
|
193
|
+
# Parallel processing of NLP tasks
|
|
194
|
+
tasks = [
|
|
195
|
+
self.detect_intent(embeddings),
|
|
196
|
+
self.extract_entities(tokens, embeddings),
|
|
197
|
+
self.analyze_sentiment(embeddings),
|
|
198
|
+
self.detect_language(tokens),
|
|
199
|
+
self.check_spelling(tokens)
|
|
200
|
+
]
|
|
201
|
+
|
|
202
|
+
results = await asyncio.gather(*tasks)
|
|
203
|
+
|
|
204
|
+
return {
|
|
205
|
+
'intent': results[0],
|
|
206
|
+
'entities': results[1],
|
|
207
|
+
'sentiment': results[2],
|
|
208
|
+
'language': results[3],
|
|
209
|
+
'corrections': results[4],
|
|
210
|
+
'original_message': message,
|
|
211
|
+
'processed_tokens': tokens
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
async def detect_intent(self, embeddings):
|
|
215
|
+
"""Advanced intent detection"""
|
|
216
|
+
# Multi-label classification
|
|
217
|
+
intent_scores = await self.models['intent_classifier'].predict(embeddings)
|
|
218
|
+
|
|
219
|
+
# Hierarchical intent detection
|
|
220
|
+
primary_intent = self.get_primary_intent(intent_scores)
|
|
221
|
+
sub_intents = self.get_sub_intents(primary_intent, embeddings)
|
|
222
|
+
|
|
223
|
+
return {
|
|
224
|
+
'primary': primary_intent,
|
|
225
|
+
'secondary': sub_intents,
|
|
226
|
+
'confidence': max(intent_scores.values()),
|
|
227
|
+
'all_scores': intent_scores
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
def extract_entities(self, tokens, embeddings):
|
|
231
|
+
"""Extract and resolve entities"""
|
|
232
|
+
# Named Entity Recognition
|
|
233
|
+
entities = self.models['ner'].extract(tokens, embeddings)
|
|
234
|
+
|
|
235
|
+
# Entity linking and resolution
|
|
236
|
+
resolved_entities = []
|
|
237
|
+
for entity in entities:
|
|
238
|
+
resolved = self.resolve_entity(entity)
|
|
239
|
+
resolved_entities.append({
|
|
240
|
+
'text': entity['text'],
|
|
241
|
+
'type': entity['type'],
|
|
242
|
+
'resolved_value': resolved['value'],
|
|
243
|
+
'confidence': resolved['confidence'],
|
|
244
|
+
'alternatives': resolved.get('alternatives', [])
|
|
245
|
+
})
|
|
246
|
+
|
|
247
|
+
return resolved_entities
|
|
248
|
+
|
|
249
|
+
def build_semantic_understanding(self, nlu_result, context):
|
|
250
|
+
"""Build semantic representation of user intent"""
|
|
251
|
+
return {
|
|
252
|
+
'user_goal': self.infer_user_goal(nlu_result, context),
|
|
253
|
+
'required_information': self.identify_missing_info(nlu_result),
|
|
254
|
+
'constraints': self.extract_constraints(nlu_result),
|
|
255
|
+
'preferences': self.extract_preferences(nlu_result, context)
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### 3. Conversation Flow Design
|
|
260
|
+
|
|
261
|
+
Design intelligent conversation flows:
|
|
262
|
+
|
|
263
|
+
**Conversation Flow Engine**
|
|
264
|
+
```python
|
|
265
|
+
class ConversationFlowEngine:
|
|
266
|
+
def __init__(self):
|
|
267
|
+
self.flows = self._load_conversation_flows()
|
|
268
|
+
self.state_tracker = StateTracker()
|
|
269
|
+
|
|
270
|
+
def design_conversation_flow(self):
|
|
271
|
+
"""Design multi-turn conversation flows"""
|
|
272
|
+
return {
|
|
273
|
+
'greeting_flow': {
|
|
274
|
+
'triggers': ['hello', 'hi', 'greetings'],
|
|
275
|
+
'nodes': [
|
|
276
|
+
{
|
|
277
|
+
'id': 'greet_user',
|
|
278
|
+
'type': 'response',
|
|
279
|
+
'content': self.personalized_greeting,
|
|
280
|
+
'next': 'ask_how_to_help'
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
'id': 'ask_how_to_help',
|
|
284
|
+
'type': 'question',
|
|
285
|
+
'content': "How can I assist you today?",
|
|
286
|
+
'expected_intents': ['request_help', 'ask_question'],
|
|
287
|
+
'timeout': 30,
|
|
288
|
+
'timeout_action': 'offer_suggestions'
|
|
289
|
+
}
|
|
290
|
+
]
|
|
291
|
+
},
|
|
292
|
+
'task_completion_flow': {
|
|
293
|
+
'triggers': ['task_request'],
|
|
294
|
+
'nodes': [
|
|
295
|
+
{
|
|
296
|
+
'id': 'understand_task',
|
|
297
|
+
'type': 'nlu_processing',
|
|
298
|
+
'extract': ['task_type', 'parameters'],
|
|
299
|
+
'next': 'check_requirements'
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
'id': 'check_requirements',
|
|
303
|
+
'type': 'validation',
|
|
304
|
+
'validate': self.validate_task_requirements,
|
|
305
|
+
'on_success': 'confirm_task',
|
|
306
|
+
'on_missing': 'request_missing_info'
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
'id': 'request_missing_info',
|
|
310
|
+
'type': 'slot_filling',
|
|
311
|
+
'slots': self.get_required_slots,
|
|
312
|
+
'prompts': self.get_slot_prompts,
|
|
313
|
+
'next': 'confirm_task'
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
'id': 'confirm_task',
|
|
317
|
+
'type': 'confirmation',
|
|
318
|
+
'content': self.generate_task_summary,
|
|
319
|
+
'on_confirm': 'execute_task',
|
|
320
|
+
'on_deny': 'clarify_task'
|
|
321
|
+
}
|
|
322
|
+
]
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
async def execute_flow(self, flow_id: str, context: ConversationContext):
|
|
327
|
+
"""Execute a conversation flow"""
|
|
328
|
+
flow = self.flows[flow_id]
|
|
329
|
+
current_node = flow['nodes'][0]
|
|
330
|
+
|
|
331
|
+
while current_node:
|
|
332
|
+
result = await self.execute_node(current_node, context)
|
|
333
|
+
|
|
334
|
+
# Determine next node
|
|
335
|
+
if result.get('user_input'):
|
|
336
|
+
next_node_id = self.determine_next_node(
|
|
337
|
+
current_node,
|
|
338
|
+
result['user_input'],
|
|
339
|
+
context
|
|
340
|
+
)
|
|
341
|
+
else:
|
|
342
|
+
next_node_id = current_node.get('next')
|
|
343
|
+
|
|
344
|
+
current_node = self.get_node(flow, next_node_id)
|
|
345
|
+
|
|
346
|
+
# Update context
|
|
347
|
+
context.conversation_state.update(result.get('state_updates', {}))
|
|
348
|
+
|
|
349
|
+
return context
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### 4. Response Generation
|
|
353
|
+
|
|
354
|
+
Create intelligent response generation:
|
|
355
|
+
|
|
356
|
+
**Response Generator**
|
|
357
|
+
```python
|
|
358
|
+
class ResponseGenerator:
|
|
359
|
+
def __init__(self, llm_client=None):
|
|
360
|
+
self.llm = llm_client
|
|
361
|
+
self.templates = self._load_response_templates()
|
|
362
|
+
self.personality = self._load_personality_config()
|
|
363
|
+
|
|
364
|
+
async def generate_response(self,
|
|
365
|
+
intent: str,
|
|
366
|
+
context: ConversationContext,
|
|
367
|
+
data: Dict[str, Any]) -> str:
|
|
368
|
+
"""Generate contextual responses"""
|
|
369
|
+
|
|
370
|
+
# Select response strategy
|
|
371
|
+
if self.should_use_template(intent):
|
|
372
|
+
response = self.generate_from_template(intent, data)
|
|
373
|
+
elif self.should_use_llm(intent, context):
|
|
374
|
+
response = await self.generate_with_llm(intent, context, data)
|
|
375
|
+
else:
|
|
376
|
+
response = self.generate_hybrid_response(intent, context, data)
|
|
377
|
+
|
|
378
|
+
# Apply personality and tone
|
|
379
|
+
response = self.apply_personality(response, context)
|
|
380
|
+
|
|
381
|
+
# Ensure response appropriateness
|
|
382
|
+
response = self.validate_response(response, context)
|
|
383
|
+
|
|
384
|
+
return response
|
|
385
|
+
|
|
386
|
+
async def generate_with_llm(self, intent, context, data):
|
|
387
|
+
"""Generate response using LLM"""
|
|
388
|
+
# Construct prompt
|
|
389
|
+
prompt = self.build_llm_prompt(intent, context, data)
|
|
390
|
+
|
|
391
|
+
# Set generation parameters
|
|
392
|
+
params = {
|
|
393
|
+
'temperature': self.get_temperature(intent),
|
|
394
|
+
'max_tokens': 150,
|
|
395
|
+
'stop_sequences': ['\n\n', 'User:', 'Human:']
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
# Generate response
|
|
399
|
+
response = await self.llm.generate(prompt, **params)
|
|
400
|
+
|
|
401
|
+
# Post-process response
|
|
402
|
+
return self.post_process_llm_response(response)
|
|
403
|
+
|
|
404
|
+
def build_llm_prompt(self, intent, context, data):
|
|
405
|
+
"""Build context-aware prompt for LLM"""
|
|
406
|
+
return f"""
|
|
407
|
+
You are a helpful AI assistant with the following characteristics:
|
|
408
|
+
{self.personality.description}
|
|
409
|
+
|
|
410
|
+
Conversation history:
|
|
411
|
+
{self.format_conversation_history(context.messages[-5:])}
|
|
412
|
+
|
|
413
|
+
User intent: {intent}
|
|
414
|
+
Relevant data: {json.dumps(data, indent=2)}
|
|
415
|
+
|
|
416
|
+
Generate a helpful, concise response that:
|
|
417
|
+
1. Addresses the user's intent
|
|
418
|
+
2. Uses the provided data appropriately
|
|
419
|
+
3. Maintains conversation continuity
|
|
420
|
+
4. Follows the personality guidelines
|
|
421
|
+
|
|
422
|
+
Response:"""
|
|
423
|
+
|
|
424
|
+
def generate_from_template(self, intent, data):
|
|
425
|
+
"""Generate response from templates"""
|
|
426
|
+
template = self.templates.get(intent)
|
|
427
|
+
if not template:
|
|
428
|
+
return self.get_fallback_response()
|
|
429
|
+
|
|
430
|
+
# Select template variant
|
|
431
|
+
variant = self.select_template_variant(template, data)
|
|
432
|
+
|
|
433
|
+
# Fill template slots
|
|
434
|
+
response = variant
|
|
435
|
+
for key, value in data.items():
|
|
436
|
+
response = response.replace(f"{{{key}}}", str(value))
|
|
437
|
+
|
|
438
|
+
return response
|
|
439
|
+
|
|
440
|
+
def apply_personality(self, response, context):
|
|
441
|
+
"""Apply personality traits to response"""
|
|
442
|
+
# Add personality markers
|
|
443
|
+
if self.personality.get('friendly'):
|
|
444
|
+
response = self.add_friendly_markers(response)
|
|
445
|
+
|
|
446
|
+
if self.personality.get('professional'):
|
|
447
|
+
response = self.ensure_professional_tone(response)
|
|
448
|
+
|
|
449
|
+
# Adjust based on user preferences
|
|
450
|
+
if context.user_profile.get('prefers_brief'):
|
|
451
|
+
response = self.make_concise(response)
|
|
452
|
+
|
|
453
|
+
return response
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
### 5. Context Management
|
|
457
|
+
|
|
458
|
+
Implement sophisticated context management:
|
|
459
|
+
|
|
460
|
+
**Context Management System**
|
|
461
|
+
```python
|
|
462
|
+
class ContextManager:
|
|
463
|
+
def __init__(self):
|
|
464
|
+
self.short_term_memory = ShortTermMemory()
|
|
465
|
+
self.long_term_memory = LongTermMemory()
|
|
466
|
+
self.working_memory = WorkingMemory()
|
|
467
|
+
|
|
468
|
+
async def manage_context(self,
|
|
469
|
+
new_input: Dict[str, Any],
|
|
470
|
+
current_context: ConversationContext) -> ConversationContext:
|
|
471
|
+
"""Manage conversation context"""
|
|
472
|
+
|
|
473
|
+
# Update conversation history
|
|
474
|
+
current_context.messages.append({
|
|
475
|
+
'role': 'user',
|
|
476
|
+
'content': new_input['message'],
|
|
477
|
+
'timestamp': datetime.now(),
|
|
478
|
+
'metadata': new_input.get('metadata', {})
|
|
479
|
+
})
|
|
480
|
+
|
|
481
|
+
# Resolve references
|
|
482
|
+
resolved_input = await self.resolve_references(new_input, current_context)
|
|
483
|
+
|
|
484
|
+
# Update working memory
|
|
485
|
+
self.working_memory.update(resolved_input, current_context)
|
|
486
|
+
|
|
487
|
+
# Detect topic changes
|
|
488
|
+
topic_shift = self.detect_topic_shift(resolved_input, current_context)
|
|
489
|
+
if topic_shift:
|
|
490
|
+
current_context = self.handle_topic_shift(topic_shift, current_context)
|
|
491
|
+
|
|
492
|
+
# Maintain entity state
|
|
493
|
+
current_context = self.update_entity_state(resolved_input, current_context)
|
|
494
|
+
|
|
495
|
+
# Prune old context if needed
|
|
496
|
+
if len(current_context.messages) > self.config['max_context_length']:
|
|
497
|
+
current_context = self.prune_context(current_context)
|
|
498
|
+
|
|
499
|
+
return current_context
|
|
500
|
+
|
|
501
|
+
async def resolve_references(self, input_data, context):
|
|
502
|
+
"""Resolve pronouns and references"""
|
|
503
|
+
text = input_data['message']
|
|
504
|
+
|
|
505
|
+
# Pronoun resolution
|
|
506
|
+
pronouns = self.extract_pronouns(text)
|
|
507
|
+
for pronoun in pronouns:
|
|
508
|
+
referent = self.find_referent(pronoun, context)
|
|
509
|
+
if referent:
|
|
510
|
+
text = text.replace(pronoun['text'], referent['resolved'])
|
|
511
|
+
|
|
512
|
+
# Temporal reference resolution
|
|
513
|
+
temporal_refs = self.extract_temporal_references(text)
|
|
514
|
+
for ref in temporal_refs:
|
|
515
|
+
resolved_time = self.resolve_temporal_reference(ref, context)
|
|
516
|
+
text = text.replace(ref['text'], str(resolved_time))
|
|
517
|
+
|
|
518
|
+
input_data['resolved_message'] = text
|
|
519
|
+
return input_data
|
|
520
|
+
|
|
521
|
+
def maintain_entity_state(self):
|
|
522
|
+
"""Track entity states across conversation"""
|
|
523
|
+
return '''
|
|
524
|
+
class EntityStateTracker:
|
|
525
|
+
def __init__(self):
|
|
526
|
+
self.entities = {}
|
|
527
|
+
|
|
528
|
+
def update_entity(self, entity_id: str, updates: Dict[str, Any]):
|
|
529
|
+
"""Update entity state"""
|
|
530
|
+
if entity_id not in self.entities:
|
|
531
|
+
self.entities[entity_id] = {
|
|
532
|
+
'id': entity_id,
|
|
533
|
+
'type': updates.get('type'),
|
|
534
|
+
'attributes': {},
|
|
535
|
+
'history': []
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
# Record history
|
|
539
|
+
self.entities[entity_id]['history'].append({
|
|
540
|
+
'timestamp': datetime.now(),
|
|
541
|
+
'updates': updates
|
|
542
|
+
})
|
|
543
|
+
|
|
544
|
+
# Apply updates
|
|
545
|
+
self.entities[entity_id]['attributes'].update(updates)
|
|
546
|
+
|
|
547
|
+
def get_entity_state(self, entity_id: str) -> Optional[Dict[str, Any]]:
|
|
548
|
+
"""Get current entity state"""
|
|
549
|
+
return self.entities.get(entity_id)
|
|
550
|
+
|
|
551
|
+
def query_entities(self, entity_type: str = None, **filters):
|
|
552
|
+
"""Query entities by type and attributes"""
|
|
553
|
+
results = []
|
|
554
|
+
for entity in self.entities.values():
|
|
555
|
+
if entity_type and entity['type'] != entity_type:
|
|
556
|
+
continue
|
|
557
|
+
|
|
558
|
+
matches = True
|
|
559
|
+
for key, value in filters.items():
|
|
560
|
+
if entity['attributes'].get(key) != value:
|
|
561
|
+
matches = False
|
|
562
|
+
break
|
|
563
|
+
|
|
564
|
+
if matches:
|
|
565
|
+
results.append(entity)
|
|
566
|
+
|
|
567
|
+
return results
|
|
568
|
+
'''
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
### 6. Integration with LLMs
|
|
572
|
+
|
|
573
|
+
Integrate with various LLM providers:
|
|
574
|
+
|
|
575
|
+
**LLM Integration Layer**
|
|
576
|
+
```python
|
|
577
|
+
class LLMIntegrationLayer:
|
|
578
|
+
def __init__(self):
|
|
579
|
+
self.providers = {
|
|
580
|
+
'openai': OpenAIProvider(),
|
|
581
|
+
'anthropic': AnthropicProvider(),
|
|
582
|
+
'local': LocalLLMProvider()
|
|
583
|
+
}
|
|
584
|
+
self.current_provider = None
|
|
585
|
+
|
|
586
|
+
async def setup_llm_integration(self, provider: str, config: Dict[str, Any]):
|
|
587
|
+
"""Setup LLM integration"""
|
|
588
|
+
self.current_provider = self.providers[provider]
|
|
589
|
+
await self.current_provider.initialize(config)
|
|
590
|
+
|
|
591
|
+
return {
|
|
592
|
+
'provider': provider,
|
|
593
|
+
'capabilities': self.current_provider.get_capabilities(),
|
|
594
|
+
'rate_limits': self.current_provider.get_rate_limits()
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
async def generate_completion(self,
|
|
598
|
+
prompt: str,
|
|
599
|
+
system_prompt: str = None,
|
|
600
|
+
**kwargs):
|
|
601
|
+
"""Generate completion with fallback handling"""
|
|
602
|
+
try:
|
|
603
|
+
# Primary attempt
|
|
604
|
+
response = await self.current_provider.complete(
|
|
605
|
+
prompt=prompt,
|
|
606
|
+
system_prompt=system_prompt,
|
|
607
|
+
**kwargs
|
|
608
|
+
)
|
|
609
|
+
|
|
610
|
+
# Validate response
|
|
611
|
+
if self.is_valid_response(response):
|
|
612
|
+
return response
|
|
613
|
+
else:
|
|
614
|
+
return await self.handle_invalid_response(prompt, response)
|
|
615
|
+
|
|
616
|
+
except RateLimitError:
|
|
617
|
+
# Switch to fallback provider
|
|
618
|
+
return await self.use_fallback_provider(prompt, system_prompt, **kwargs)
|
|
619
|
+
except Exception as e:
|
|
620
|
+
# Log error and use cached response if available
|
|
621
|
+
return self.get_cached_response(prompt) or self.get_default_response()
|
|
622
|
+
|
|
623
|
+
def create_function_calling_interface(self):
|
|
624
|
+
"""Create function calling interface for LLMs"""
|
|
625
|
+
return '''
|
|
626
|
+
class FunctionCallingInterface:
|
|
627
|
+
def __init__(self):
|
|
628
|
+
self.functions = {}
|
|
629
|
+
|
|
630
|
+
def register_function(self,
|
|
631
|
+
name: str,
|
|
632
|
+
func: callable,
|
|
633
|
+
description: str,
|
|
634
|
+
parameters: Dict[str, Any]):
|
|
635
|
+
"""Register a function for LLM to call"""
|
|
636
|
+
self.functions[name] = {
|
|
637
|
+
'function': func,
|
|
638
|
+
'description': description,
|
|
639
|
+
'parameters': parameters
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
async def process_function_call(self, llm_response):
|
|
643
|
+
"""Process function calls from LLM"""
|
|
644
|
+
if 'function_call' not in llm_response:
|
|
645
|
+
return llm_response
|
|
646
|
+
|
|
647
|
+
function_name = llm_response['function_call']['name']
|
|
648
|
+
arguments = llm_response['function_call']['arguments']
|
|
649
|
+
|
|
650
|
+
if function_name not in self.functions:
|
|
651
|
+
return {'error': f'Unknown function: {function_name}'}
|
|
652
|
+
|
|
653
|
+
# Validate arguments
|
|
654
|
+
validated_args = self.validate_arguments(
|
|
655
|
+
function_name,
|
|
656
|
+
arguments
|
|
657
|
+
)
|
|
658
|
+
|
|
659
|
+
# Execute function
|
|
660
|
+
result = await self.functions[function_name]['function'](**validated_args)
|
|
661
|
+
|
|
662
|
+
# Return result for LLM to process
|
|
663
|
+
return {
|
|
664
|
+
'function_result': result,
|
|
665
|
+
'function_name': function_name
|
|
666
|
+
}
|
|
667
|
+
'''
|
|
668
|
+
```
|
|
669
|
+
|
|
670
|
+
### 7. Testing Conversational AI
|
|
671
|
+
|
|
672
|
+
Implement comprehensive testing:
|
|
673
|
+
|
|
674
|
+
**Conversation Testing Framework**
|
|
675
|
+
```python
|
|
676
|
+
class ConversationTestFramework:
|
|
677
|
+
def __init__(self):
|
|
678
|
+
self.test_suites = []
|
|
679
|
+
self.metrics = ConversationMetrics()
|
|
680
|
+
|
|
681
|
+
def create_test_suite(self):
|
|
682
|
+
"""Create comprehensive test suite"""
|
|
683
|
+
return {
|
|
684
|
+
'unit_tests': self._create_unit_tests(),
|
|
685
|
+
'integration_tests': self._create_integration_tests(),
|
|
686
|
+
'conversation_tests': self._create_conversation_tests(),
|
|
687
|
+
'performance_tests': self._create_performance_tests(),
|
|
688
|
+
'user_simulation': self._create_user_simulation()
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
def _create_conversation_tests(self):
|
|
692
|
+
"""Test multi-turn conversations"""
|
|
693
|
+
return '''
|
|
694
|
+
class ConversationTest:
|
|
695
|
+
async def test_multi_turn_conversation(self):
|
|
696
|
+
"""Test complete conversation flow"""
|
|
697
|
+
assistant = AIAssistant()
|
|
698
|
+
context = ConversationContext(user_id="test_user")
|
|
699
|
+
|
|
700
|
+
# Conversation script
|
|
701
|
+
conversation = [
|
|
702
|
+
{
|
|
703
|
+
'user': "Hello, I need help with my order",
|
|
704
|
+
'expected_intent': 'order_help',
|
|
705
|
+
'expected_action': 'ask_order_details'
|
|
706
|
+
},
|
|
707
|
+
{
|
|
708
|
+
'user': "My order number is 12345",
|
|
709
|
+
'expected_entities': [{'type': 'order_id', 'value': '12345'}],
|
|
710
|
+
'expected_action': 'retrieve_order'
|
|
711
|
+
},
|
|
712
|
+
{
|
|
713
|
+
'user': "When will it arrive?",
|
|
714
|
+
'expected_intent': 'delivery_inquiry',
|
|
715
|
+
'should_use_context': True
|
|
716
|
+
}
|
|
717
|
+
]
|
|
718
|
+
|
|
719
|
+
for turn in conversation:
|
|
720
|
+
# Send user message
|
|
721
|
+
response = await assistant.process_message(
|
|
722
|
+
turn['user'],
|
|
723
|
+
context
|
|
724
|
+
)
|
|
725
|
+
|
|
726
|
+
# Validate intent detection
|
|
727
|
+
if 'expected_intent' in turn:
|
|
728
|
+
assert response['intent'] == turn['expected_intent']
|
|
729
|
+
|
|
730
|
+
# Validate entity extraction
|
|
731
|
+
if 'expected_entities' in turn:
|
|
732
|
+
self.validate_entities(
|
|
733
|
+
response['entities'],
|
|
734
|
+
turn['expected_entities']
|
|
735
|
+
)
|
|
736
|
+
|
|
737
|
+
# Validate context usage
|
|
738
|
+
if turn.get('should_use_context'):
|
|
739
|
+
assert 'order_id' in response['context_used']
|
|
740
|
+
|
|
741
|
+
def test_error_handling(self):
|
|
742
|
+
"""Test error scenarios"""
|
|
743
|
+
error_cases = [
|
|
744
|
+
{
|
|
745
|
+
'input': "askdjfkajsdf",
|
|
746
|
+
'expected_behavior': 'fallback_response'
|
|
747
|
+
},
|
|
748
|
+
{
|
|
749
|
+
'input': "I want to [REDACTED]",
|
|
750
|
+
'expected_behavior': 'safety_response'
|
|
751
|
+
},
|
|
752
|
+
{
|
|
753
|
+
'input': "Tell me about " + "x" * 1000,
|
|
754
|
+
'expected_behavior': 'length_limit_response'
|
|
755
|
+
}
|
|
756
|
+
]
|
|
757
|
+
|
|
758
|
+
for case in error_cases:
|
|
759
|
+
response = assistant.process_message(case['input'])
|
|
760
|
+
assert response['behavior'] == case['expected_behavior']
|
|
761
|
+
'''
|
|
762
|
+
|
|
763
|
+
def create_automated_testing(self):
|
|
764
|
+
"""Automated conversation testing"""
|
|
765
|
+
return '''
|
|
766
|
+
class AutomatedConversationTester:
|
|
767
|
+
def __init__(self):
|
|
768
|
+
self.test_generator = TestCaseGenerator()
|
|
769
|
+
self.evaluator = ResponseEvaluator()
|
|
770
|
+
|
|
771
|
+
async def run_automated_tests(self, num_tests: int = 100):
|
|
772
|
+
"""Run automated conversation tests"""
|
|
773
|
+
results = {
|
|
774
|
+
'total_tests': num_tests,
|
|
775
|
+
'passed': 0,
|
|
776
|
+
'failed': 0,
|
|
777
|
+
'metrics': {}
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
for i in range(num_tests):
|
|
781
|
+
# Generate test case
|
|
782
|
+
test_case = self.test_generator.generate()
|
|
783
|
+
|
|
784
|
+
# Run conversation
|
|
785
|
+
conversation_log = await self.run_conversation(test_case)
|
|
786
|
+
|
|
787
|
+
# Evaluate results
|
|
788
|
+
evaluation = self.evaluator.evaluate(
|
|
789
|
+
conversation_log,
|
|
790
|
+
test_case['expectations']
|
|
791
|
+
)
|
|
792
|
+
|
|
793
|
+
if evaluation['passed']:
|
|
794
|
+
results['passed'] += 1
|
|
795
|
+
else:
|
|
796
|
+
results['failed'] += 1
|
|
797
|
+
|
|
798
|
+
# Collect metrics
|
|
799
|
+
self.update_metrics(results['metrics'], evaluation['metrics'])
|
|
800
|
+
|
|
801
|
+
return results
|
|
802
|
+
|
|
803
|
+
def generate_adversarial_tests(self):
|
|
804
|
+
"""Generate adversarial test cases"""
|
|
805
|
+
return [
|
|
806
|
+
# Ambiguous inputs
|
|
807
|
+
"I want that thing we discussed",
|
|
808
|
+
|
|
809
|
+
# Context switching
|
|
810
|
+
"Actually, forget that. Tell me about the weather",
|
|
811
|
+
|
|
812
|
+
# Multiple intents
|
|
813
|
+
"Cancel my order and also update my address",
|
|
814
|
+
|
|
815
|
+
# Incomplete information
|
|
816
|
+
"Book a flight",
|
|
817
|
+
|
|
818
|
+
# Contradictions
|
|
819
|
+
"I want a vegetarian meal with bacon"
|
|
820
|
+
]
|
|
821
|
+
'''
|
|
822
|
+
```
|
|
823
|
+
|
|
824
|
+
### 8. Deployment and Scaling
|
|
825
|
+
|
|
826
|
+
Deploy and scale AI assistants:
|
|
827
|
+
|
|
828
|
+
**Deployment Architecture**
|
|
829
|
+
```python
|
|
830
|
+
class AssistantDeployment:
|
|
831
|
+
def create_deployment_architecture(self):
|
|
832
|
+
"""Create scalable deployment architecture"""
|
|
833
|
+
return {
|
|
834
|
+
'containerization': '''
|
|
835
|
+
# Dockerfile for AI Assistant
|
|
836
|
+
FROM python:3.11-slim
|
|
837
|
+
|
|
838
|
+
WORKDIR /app
|
|
839
|
+
|
|
840
|
+
# Install dependencies
|
|
841
|
+
COPY requirements.txt .
|
|
842
|
+
RUN pip install --no-cache-dir -r requirements.txt
|
|
843
|
+
|
|
844
|
+
# Copy application
|
|
845
|
+
COPY . .
|
|
846
|
+
|
|
847
|
+
# Load models at build time
|
|
848
|
+
RUN python -m app.model_loader
|
|
849
|
+
|
|
850
|
+
# Expose port
|
|
851
|
+
EXPOSE 8080
|
|
852
|
+
|
|
853
|
+
# Health check
|
|
854
|
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
|
855
|
+
CMD python -m app.health_check
|
|
856
|
+
|
|
857
|
+
# Run application
|
|
858
|
+
CMD ["gunicorn", "--worker-class", "uvicorn.workers.UvicornWorker", \
|
|
859
|
+
"--workers", "4", "--bind", "0.0.0.0:8080", "app.main:app"]
|
|
860
|
+
''',
|
|
861
|
+
'kubernetes_deployment': '''
|
|
862
|
+
apiVersion: apps/v1
|
|
863
|
+
kind: Deployment
|
|
864
|
+
metadata:
|
|
865
|
+
name: ai-assistant
|
|
866
|
+
spec:
|
|
867
|
+
replicas: 3
|
|
868
|
+
selector:
|
|
869
|
+
matchLabels:
|
|
870
|
+
app: ai-assistant
|
|
871
|
+
template:
|
|
872
|
+
metadata:
|
|
873
|
+
labels:
|
|
874
|
+
app: ai-assistant
|
|
875
|
+
spec:
|
|
876
|
+
containers:
|
|
877
|
+
- name: assistant
|
|
878
|
+
image: ai-assistant:latest
|
|
879
|
+
ports:
|
|
880
|
+
- containerPort: 8080
|
|
881
|
+
resources:
|
|
882
|
+
requests:
|
|
883
|
+
memory: "2Gi"
|
|
884
|
+
cpu: "1000m"
|
|
885
|
+
limits:
|
|
886
|
+
memory: "4Gi"
|
|
887
|
+
cpu: "2000m"
|
|
888
|
+
env:
|
|
889
|
+
- name: MODEL_CACHE_SIZE
|
|
890
|
+
value: "1000"
|
|
891
|
+
- name: MAX_CONCURRENT_SESSIONS
|
|
892
|
+
value: "100"
|
|
893
|
+
livenessProbe:
|
|
894
|
+
httpGet:
|
|
895
|
+
path: /health
|
|
896
|
+
port: 8080
|
|
897
|
+
periodSeconds: 10
|
|
898
|
+
readinessProbe:
|
|
899
|
+
httpGet:
|
|
900
|
+
path: /ready
|
|
901
|
+
port: 8080
|
|
902
|
+
periodSeconds: 5
|
|
903
|
+
---
|
|
904
|
+
apiVersion: v1
|
|
905
|
+
kind: Service
|
|
906
|
+
metadata:
|
|
907
|
+
name: ai-assistant-service
|
|
908
|
+
spec:
|
|
909
|
+
selector:
|
|
910
|
+
app: ai-assistant
|
|
911
|
+
ports:
|
|
912
|
+
- port: 80
|
|
913
|
+
targetPort: 8080
|
|
914
|
+
type: LoadBalancer
|
|
915
|
+
---
|
|
916
|
+
apiVersion: autoscaling/v2
|
|
917
|
+
kind: HorizontalPodAutoscaler
|
|
918
|
+
metadata:
|
|
919
|
+
name: ai-assistant-hpa
|
|
920
|
+
spec:
|
|
921
|
+
scaleTargetRef:
|
|
922
|
+
apiVersion: apps/v1
|
|
923
|
+
kind: Deployment
|
|
924
|
+
name: ai-assistant
|
|
925
|
+
minReplicas: 3
|
|
926
|
+
maxReplicas: 10
|
|
927
|
+
metrics:
|
|
928
|
+
- type: Resource
|
|
929
|
+
resource:
|
|
930
|
+
name: cpu
|
|
931
|
+
target:
|
|
932
|
+
type: Utilization
|
|
933
|
+
averageUtilization: 70
|
|
934
|
+
- type: Resource
|
|
935
|
+
resource:
|
|
936
|
+
name: memory
|
|
937
|
+
target:
|
|
938
|
+
type: Utilization
|
|
939
|
+
averageUtilization: 80
|
|
940
|
+
''',
|
|
941
|
+
'caching_strategy': self._design_caching_strategy(),
|
|
942
|
+
'load_balancing': self._design_load_balancing()
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
def _design_caching_strategy(self):
|
|
946
|
+
"""Design caching for performance"""
|
|
947
|
+
return '''
|
|
948
|
+
class AssistantCache:
|
|
949
|
+
def __init__(self):
|
|
950
|
+
self.response_cache = ResponseCache()
|
|
951
|
+
self.model_cache = ModelCache()
|
|
952
|
+
self.context_cache = ContextCache()
|
|
953
|
+
|
|
954
|
+
async def get_cached_response(self,
|
|
955
|
+
message: str,
|
|
956
|
+
context_hash: str) -> Optional[str]:
|
|
957
|
+
"""Get cached response if available"""
|
|
958
|
+
cache_key = self.generate_cache_key(message, context_hash)
|
|
959
|
+
|
|
960
|
+
# Check response cache
|
|
961
|
+
cached = await self.response_cache.get(cache_key)
|
|
962
|
+
if cached and not self.is_expired(cached):
|
|
963
|
+
return cached['response']
|
|
964
|
+
|
|
965
|
+
return None
|
|
966
|
+
|
|
967
|
+
def cache_response(self,
|
|
968
|
+
message: str,
|
|
969
|
+
context_hash: str,
|
|
970
|
+
response: str,
|
|
971
|
+
ttl: int = 3600):
|
|
972
|
+
"""Cache response with TTL"""
|
|
973
|
+
cache_key = self.generate_cache_key(message, context_hash)
|
|
974
|
+
|
|
975
|
+
self.response_cache.set(
|
|
976
|
+
cache_key,
|
|
977
|
+
{
|
|
978
|
+
'response': response,
|
|
979
|
+
'timestamp': datetime.now(),
|
|
980
|
+
'ttl': ttl
|
|
981
|
+
}
|
|
982
|
+
)
|
|
983
|
+
|
|
984
|
+
def preload_model_cache(self):
|
|
985
|
+
"""Preload frequently used models"""
|
|
986
|
+
models_to_cache = [
|
|
987
|
+
'intent_classifier',
|
|
988
|
+
'entity_extractor',
|
|
989
|
+
'response_generator'
|
|
990
|
+
]
|
|
991
|
+
|
|
992
|
+
for model_name in models_to_cache:
|
|
993
|
+
model = load_model(model_name)
|
|
994
|
+
self.model_cache.store(model_name, model)
|
|
995
|
+
'''
|
|
996
|
+
```
|
|
997
|
+
|
|
998
|
+
### 9. Monitoring and Analytics
|
|
999
|
+
|
|
1000
|
+
Monitor assistant performance:
|
|
1001
|
+
|
|
1002
|
+
**Assistant Analytics System**
|
|
1003
|
+
```python
|
|
1004
|
+
class AssistantAnalytics:
|
|
1005
|
+
def __init__(self):
|
|
1006
|
+
self.metrics_collector = MetricsCollector()
|
|
1007
|
+
self.analytics_engine = AnalyticsEngine()
|
|
1008
|
+
|
|
1009
|
+
def create_monitoring_dashboard(self):
|
|
1010
|
+
"""Create monitoring dashboard configuration"""
|
|
1011
|
+
return {
|
|
1012
|
+
'real_time_metrics': {
|
|
1013
|
+
'active_sessions': 'gauge',
|
|
1014
|
+
'messages_per_second': 'counter',
|
|
1015
|
+
'response_time_p95': 'histogram',
|
|
1016
|
+
'intent_accuracy': 'gauge',
|
|
1017
|
+
'fallback_rate': 'gauge'
|
|
1018
|
+
},
|
|
1019
|
+
'conversation_metrics': {
|
|
1020
|
+
'avg_conversation_length': 'gauge',
|
|
1021
|
+
'completion_rate': 'gauge',
|
|
1022
|
+
'user_satisfaction': 'gauge',
|
|
1023
|
+
'escalation_rate': 'gauge'
|
|
1024
|
+
},
|
|
1025
|
+
'system_metrics': {
|
|
1026
|
+
'model_inference_time': 'histogram',
|
|
1027
|
+
'cache_hit_rate': 'gauge',
|
|
1028
|
+
'error_rate': 'counter',
|
|
1029
|
+
'resource_utilization': 'gauge'
|
|
1030
|
+
},
|
|
1031
|
+
'alerts': [
|
|
1032
|
+
{
|
|
1033
|
+
'name': 'high_fallback_rate',
|
|
1034
|
+
'condition': 'fallback_rate > 0.2',
|
|
1035
|
+
'severity': 'warning'
|
|
1036
|
+
},
|
|
1037
|
+
{
|
|
1038
|
+
'name': 'slow_response_time',
|
|
1039
|
+
'condition': 'response_time_p95 > 2000',
|
|
1040
|
+
'severity': 'critical'
|
|
1041
|
+
}
|
|
1042
|
+
]
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
def analyze_conversation_quality(self):
|
|
1046
|
+
"""Analyze conversation quality metrics"""
|
|
1047
|
+
return '''
|
|
1048
|
+
class ConversationQualityAnalyzer:
|
|
1049
|
+
def analyze_conversations(self, time_range: str):
|
|
1050
|
+
"""Analyze conversation quality"""
|
|
1051
|
+
conversations = self.fetch_conversations(time_range)
|
|
1052
|
+
|
|
1053
|
+
metrics = {
|
|
1054
|
+
'intent_recognition': self.analyze_intent_accuracy(conversations),
|
|
1055
|
+
'response_relevance': self.analyze_response_relevance(conversations),
|
|
1056
|
+
'conversation_flow': self.analyze_conversation_flow(conversations),
|
|
1057
|
+
'user_satisfaction': self.analyze_satisfaction(conversations),
|
|
1058
|
+
'error_patterns': self.identify_error_patterns(conversations)
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
return self.generate_quality_report(metrics)
|
|
1062
|
+
|
|
1063
|
+
def identify_improvement_areas(self, analysis):
|
|
1064
|
+
"""Identify areas for improvement"""
|
|
1065
|
+
improvements = []
|
|
1066
|
+
|
|
1067
|
+
# Low intent accuracy
|
|
1068
|
+
if analysis['intent_recognition']['accuracy'] < 0.85:
|
|
1069
|
+
improvements.append({
|
|
1070
|
+
'area': 'Intent Recognition',
|
|
1071
|
+
'issue': 'Low accuracy in intent detection',
|
|
1072
|
+
'recommendation': 'Retrain intent classifier with more examples',
|
|
1073
|
+
'priority': 'high'
|
|
1074
|
+
})
|
|
1075
|
+
|
|
1076
|
+
# High fallback rate
|
|
1077
|
+
if analysis['conversation_flow']['fallback_rate'] > 0.15:
|
|
1078
|
+
improvements.append({
|
|
1079
|
+
'area': 'Coverage',
|
|
1080
|
+
'issue': 'High fallback rate',
|
|
1081
|
+
'recommendation': 'Expand training data for uncovered intents',
|
|
1082
|
+
'priority': 'medium'
|
|
1083
|
+
})
|
|
1084
|
+
|
|
1085
|
+
return improvements
|
|
1086
|
+
'''
|
|
1087
|
+
```
|
|
1088
|
+
|
|
1089
|
+
### 10. Continuous Improvement
|
|
1090
|
+
|
|
1091
|
+
Implement continuous improvement cycle:
|
|
1092
|
+
|
|
1093
|
+
**Improvement Pipeline**
|
|
1094
|
+
```python
|
|
1095
|
+
class ContinuousImprovement:
|
|
1096
|
+
def create_improvement_pipeline(self):
|
|
1097
|
+
"""Create continuous improvement pipeline"""
|
|
1098
|
+
return {
|
|
1099
|
+
'data_collection': '''
|
|
1100
|
+
class ConversationDataCollector:
|
|
1101
|
+
async def collect_feedback(self, session_id: str):
|
|
1102
|
+
"""Collect user feedback"""
|
|
1103
|
+
feedback_prompt = {
|
|
1104
|
+
'satisfaction': 'How satisfied were you with this conversation? (1-5)',
|
|
1105
|
+
'resolved': 'Was your issue resolved?',
|
|
1106
|
+
'improvements': 'How could we improve?'
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
feedback = await self.prompt_user_feedback(
|
|
1110
|
+
session_id,
|
|
1111
|
+
feedback_prompt
|
|
1112
|
+
)
|
|
1113
|
+
|
|
1114
|
+
# Store feedback
|
|
1115
|
+
await self.store_feedback({
|
|
1116
|
+
'session_id': session_id,
|
|
1117
|
+
'timestamp': datetime.now(),
|
|
1118
|
+
'feedback': feedback,
|
|
1119
|
+
'conversation_metadata': self.get_session_metadata(session_id)
|
|
1120
|
+
})
|
|
1121
|
+
|
|
1122
|
+
return feedback
|
|
1123
|
+
|
|
1124
|
+
def identify_training_opportunities(self):
|
|
1125
|
+
"""Identify conversations for training"""
|
|
1126
|
+
# Find low-confidence interactions
|
|
1127
|
+
low_confidence = self.find_low_confidence_interactions()
|
|
1128
|
+
|
|
1129
|
+
# Find failed conversations
|
|
1130
|
+
failed = self.find_failed_conversations()
|
|
1131
|
+
|
|
1132
|
+
# Find highly-rated conversations
|
|
1133
|
+
exemplary = self.find_exemplary_conversations()
|
|
1134
|
+
|
|
1135
|
+
return {
|
|
1136
|
+
'needs_improvement': low_confidence + failed,
|
|
1137
|
+
'good_examples': exemplary
|
|
1138
|
+
}
|
|
1139
|
+
''',
|
|
1140
|
+
'model_retraining': '''
|
|
1141
|
+
class ModelRetrainer:
|
|
1142
|
+
async def retrain_models(self, new_data):
|
|
1143
|
+
"""Retrain models with new data"""
|
|
1144
|
+
# Prepare training data
|
|
1145
|
+
training_data = self.prepare_training_data(new_data)
|
|
1146
|
+
|
|
1147
|
+
# Validate data quality
|
|
1148
|
+
validation_result = self.validate_training_data(training_data)
|
|
1149
|
+
if not validation_result['passed']:
|
|
1150
|
+
return {'error': 'Data quality check failed', 'issues': validation_result['issues']}
|
|
1151
|
+
|
|
1152
|
+
# Retrain models
|
|
1153
|
+
models_to_retrain = ['intent_classifier', 'entity_extractor']
|
|
1154
|
+
|
|
1155
|
+
for model_name in models_to_retrain:
|
|
1156
|
+
# Load current model
|
|
1157
|
+
current_model = self.load_model(model_name)
|
|
1158
|
+
|
|
1159
|
+
# Create new version
|
|
1160
|
+
new_model = await self.train_model(
|
|
1161
|
+
model_name,
|
|
1162
|
+
training_data,
|
|
1163
|
+
base_model=current_model
|
|
1164
|
+
)
|
|
1165
|
+
|
|
1166
|
+
# Evaluate new model
|
|
1167
|
+
evaluation = await self.evaluate_model(
|
|
1168
|
+
new_model,
|
|
1169
|
+
self.get_test_set()
|
|
1170
|
+
)
|
|
1171
|
+
|
|
1172
|
+
# Deploy if improved
|
|
1173
|
+
if evaluation['performance'] > current_model.performance:
|
|
1174
|
+
await self.deploy_model(new_model, model_name)
|
|
1175
|
+
|
|
1176
|
+
return {'status': 'completed', 'models_updated': models_to_retrain}
|
|
1177
|
+
''',
|
|
1178
|
+
'a_b_testing': '''
|
|
1179
|
+
class ABTestingFramework:
|
|
1180
|
+
def create_ab_test(self,
|
|
1181
|
+
test_name: str,
|
|
1182
|
+
variants: List[Dict[str, Any]],
|
|
1183
|
+
metrics: List[str]):
|
|
1184
|
+
"""Create A/B test for assistant improvements"""
|
|
1185
|
+
test = {
|
|
1186
|
+
'id': generate_test_id(),
|
|
1187
|
+
'name': test_name,
|
|
1188
|
+
'variants': variants,
|
|
1189
|
+
'metrics': metrics,
|
|
1190
|
+
'allocation': self.calculate_traffic_allocation(variants),
|
|
1191
|
+
'duration': self.estimate_test_duration(metrics)
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
# Deploy test
|
|
1195
|
+
self.deploy_test(test)
|
|
1196
|
+
|
|
1197
|
+
return test
|
|
1198
|
+
|
|
1199
|
+
async def analyze_test_results(self, test_id: str):
|
|
1200
|
+
"""Analyze A/B test results"""
|
|
1201
|
+
data = await self.collect_test_data(test_id)
|
|
1202
|
+
|
|
1203
|
+
results = {}
|
|
1204
|
+
for metric in data['metrics']:
|
|
1205
|
+
# Statistical analysis
|
|
1206
|
+
analysis = self.statistical_analysis(
|
|
1207
|
+
data['control'][metric],
|
|
1208
|
+
data['variant'][metric]
|
|
1209
|
+
)
|
|
1210
|
+
|
|
1211
|
+
results[metric] = {
|
|
1212
|
+
'control_mean': analysis['control_mean'],
|
|
1213
|
+
'variant_mean': analysis['variant_mean'],
|
|
1214
|
+
'lift': analysis['lift'],
|
|
1215
|
+
'p_value': analysis['p_value'],
|
|
1216
|
+
'significant': analysis['p_value'] < 0.05
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
return results
|
|
1220
|
+
'''
|
|
1221
|
+
}
|
|
1222
|
+
```
|
|
1223
|
+
|
|
1224
|
+
## Output Format
|
|
1225
|
+
|
|
1226
|
+
1. **Architecture Design**: Complete AI assistant architecture with components
|
|
1227
|
+
2. **NLP Implementation**: Natural language processing pipeline and models
|
|
1228
|
+
3. **Conversation Flows**: Dialog management and flow design
|
|
1229
|
+
4. **Response Generation**: Intelligent response creation with LLM integration
|
|
1230
|
+
5. **Context Management**: Sophisticated context and state management
|
|
1231
|
+
6. **Testing Framework**: Comprehensive testing for conversational AI
|
|
1232
|
+
7. **Deployment Guide**: Scalable deployment architecture
|
|
1233
|
+
8. **Monitoring Setup**: Analytics and performance monitoring
|
|
1234
|
+
9. **Improvement Pipeline**: Continuous improvement processes
|
|
1235
|
+
|
|
1236
|
+
Focus on creating production-ready AI assistants that provide real value through natural conversations, intelligent responses, and continuous learning from user interactions.
|