├── .changeset ├── README.md └── config.json ├── .cursorrules ├── .editorconfig ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md └── workflows │ ├── build-and-test.yml │ ├── ci_cd.yml │ └── npm-publish.yml ├── .gitignore ├── .npmrc ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CODING_RULES.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── ROADMAP.md ├── SECURITY.md ├── docs ├── food_for_toughts │ ├── 01_specification_templates.md │ ├── 02_agent_specification_v1.md │ ├── 03_agentic_worflow_specification.md │ └── 04_ux_article.md ├── project │ └── 01_refactoring_instruction.md ├── scripts │ ├── convert.sh │ ├── mermaid-filter.lua │ └── templates │ │ └── 01_templates_out.md └── training │ ├── content.md │ ├── qllm-cli.yaml │ ├── qllm_training.md │ ├── qllm_tuto-V0.md │ └── qllm_tuto.md ├── jest.config.js ├── package.json ├── packages ├── qllm-cli │ ├── CHANGELOG.md │ ├── README.md │ ├── eslint.config.mjs │ ├── package.json │ ├── rollup.config.mjs │ ├── src │ │ ├── chat │ │ │ ├── chat-config.ts │ │ │ ├── chat.ts │ │ │ ├── command-processor.ts │ │ │ ├── commands │ │ │ │ ├── display-conversation.ts │ │ │ │ ├── display-current-options.ts │ │ │ │ ├── list-models.ts │ │ │ │ ├── list-providers.ts │ │ │ │ └── show-help.ts │ │ │ ├── config-manager.ts │ │ │ ├── image-manager.ts │ │ │ ├── message-handler.ts │ │ │ └── utils.ts │ │ ├── commands │ │ │ ├── ask-command.ts │ │ │ ├── chat-command.ts │ │ │ ├── configure-command.ts │ │ │ ├── list-command.ts │ │ │ └── run-command.ts │ │ ├── constants │ │ │ ├── config-constants.ts │ │ │ └── index.ts │ │ ├── index.ts │ │ ├── qllm.ts │ │ ├── types │ │ │ ├── ask-command-options.ts │ │ │ ├── chat-command-options.ts │ │ │ ├── configure-command-options.ts │ │ │ └── run-command-options.ts │ │ └── utils │ │ │ ├── cli-config-manager.ts │ │ │ ├── clipboard.ts │ │ │ ├── common.ts │ │ │ ├── image-utils.ts │ │ │ ├── input-validator.ts │ │ │ ├── io-manager │ │ │ └── index.ts │ │ │ ├── screenshot │ │ │ ├── index.ts │ │ │ ├── linux-screenshot-capture.ts │ │ │ ├── macos-screenshot-capture.ts │ │ │ ├── types.ts │ │ │ ├── utils.ts │ │ │ └── windows-screenshot-capture.ts │ │ │ ├── template-utils.ts │ │ │ ├── validate-options.ts │ │ │ ├── variable-utils.ts │ │ │ └── write-file.ts │ └── tsconfig.json ├── qllm-lib │ ├── .prettierignore │ ├── .prettierrc │ ├── API_DOCUMENTATION.md │ ├── CHANGELOG.md │ ├── README.md │ ├── data │ │ └── token_price.json │ ├── docs │ │ ├── 01-template.md │ │ └── api │ │ │ └── qllm-lib │ │ │ ├── README.md │ │ │ ├── classes │ │ │ ├── AnthropicProvider.md │ │ │ ├── AuthenticationError.md │ │ │ ├── BaseEmbeddingProvider.md │ │ │ ├── BaseLLMProvider.md │ │ │ ├── ConfigurationError.md │ │ │ ├── ConversationError.md │ │ │ ├── ConversationNotFoundError.md │ │ │ ├── FileOperationError.md │ │ │ ├── GroqProvider.md │ │ │ ├── InputValidationError.md │ │ │ ├── InvalidConversationOperationError.md │ │ │ ├── InvalidRequestError.md │ │ │ ├── InvalidTemplateError.md │ │ │ ├── LLMProviderError.md │ │ │ ├── OllamaProvider.md │ │ │ ├── OpenAIProvider.md │ │ │ ├── OutputValidationError.md │ │ │ ├── OutputVariableExtractor.md │ │ │ ├── ProviderError.md │ │ │ ├── QllmError.md │ │ │ ├── RateLimitError.md │ │ │ ├── TemplateDefinitionBuilder.md │ │ │ ├── TemplateError.md │ │ │ ├── TemplateExecutor.md │ │ │ ├── TemplateLoader.md │ │ │ ├── TemplateManager.md │ │ │ ├── TemplateManagerError.md │ │ │ └── TemplateNotFoundError.md │ │ │ ├── functions │ │ │ ├── createConversationManager.md │ │ │ ├── createEmbeddingProvider.md │ │ │ ├── createFunctionToolFromZod.md │ │ │ ├── createLLMProvider.md │ │ │ ├── createOutputVariable.md │ │ │ ├── createTemplateVariable.md │ │ │ ├── createTextMessageContent.md │ │ │ ├── generatePromptFromTemplate.md │ │ │ ├── getEmbeddingProvider.md │ │ │ ├── getLLMProvider.md │ │ │ ├── getListProviderNames.md │ │ │ ├── imageToBase64.md │ │ │ ├── isImageUrlContent.md │ │ │ └── isTextContent.md │ │ │ ├── globals.md │ │ │ ├── interfaces │ │ │ ├── AIProvider.md │ │ │ ├── Conversation.md │ │ │ ├── ConversationManager.md │ │ │ ├── ConversationMessage.md │ │ │ ├── ConversationMetadata.md │ │ │ ├── CreateConversationOptions.md │ │ │ ├── EmbeddingProvider.md │ │ │ ├── EnvironmentOptions.md │ │ │ ├── ErrorResponse.md │ │ │ ├── ExecutionContext.md │ │ │ ├── GenerationOptions.md │ │ │ ├── LLMOptions.md │ │ │ ├── LLMProvider.md │ │ │ ├── ModelOptions.md │ │ │ ├── StorageProvider.md │ │ │ └── TemplateManagerConfig.md │ │ │ ├── type-aliases │ │ │ ├── ChatCompletionParams.md │ │ │ ├── ChatCompletionResponse.md │ │ │ ├── ChatMessage.md │ │ │ ├── ChatMessageContent.md │ │ │ ├── ChatMessageContentType.md │ │ │ ├── ChatMessageRole.md │ │ │ ├── ChatMessageWithSystem.md │ │ │ ├── ChatStreamCompletionResponse.md │ │ │ ├── ConversationId.md │ │ │ ├── Embedding.md │ │ │ ├── EmbeddingRequestParams.md │ │ │ ├── EmbeddingResponse.md │ │ │ ├── FunctionTool.md │ │ │ ├── FunctionToolConfig.md │ │ │ ├── ImageUrlContent.md │ │ │ ├── MessageContent.md │ │ │ ├── Model.md │ │ │ ├── OutputVariable.md │ │ │ ├── ProviderId.md │ │ │ ├── ResponseFormat.md │ │ │ ├── ResponseFormatJSONObject.md │ │ │ ├── ResponseFormatJSONSchema.md │ │ │ ├── ResponseFormatText.md │ │ │ ├── SystemMessage.md │ │ │ ├── TemplateDefinition.md │ │ │ ├── TemplateDefinitionWithResolvedContent.md │ │ │ ├── TemplateVariable.md │ │ │ ├── TextContent.md │ │ │ ├── Tool.md │ │ │ ├── ToolCall.md │ │ │ ├── ToolCallFunction.md │ │ │ ├── ToolChoiceFunction.md │ │ │ └── Usage.md │ │ │ └── variables │ │ │ ├── default.md │ │ │ ├── logger.md │ │ │ ├── outputVariableSchema.md │ │ │ ├── templateDefinitionSchema.md │ │ │ ├── templateDefinitionSchemaWithResolvedContent.md │ │ │ └── templateVariableSchema.md │ ├── eslint.config.mjs │ ├── jest.config.js │ ├── package.json │ ├── prompts │ │ ├── create_story.yaml │ │ └── story.md │ ├── resources │ │ └── image1.jpeg │ ├── rollup.config.mjs │ ├── src │ │ ├── agents │ │ │ ├── agent-builder.ts │ │ │ ├── agent-loader.ts │ │ │ ├── agent-manager.ts │ │ │ ├── agent-types.ts │ │ │ ├── base-agent.ts │ │ │ ├── index.ts │ │ │ ├── templates │ │ │ │ └── default-agent.yaml │ │ │ └── tools │ │ │ │ ├── index.ts │ │ │ │ ├── rag-search-querytool.ts │ │ │ │ └── rag-search.ts │ │ ├── conversation │ │ │ ├── conversation-manager.ts │ │ │ ├── conversation-reducer.ts │ │ │ └── index.ts │ │ ├── index.ts │ │ ├── providers │ │ │ ├── anthropic │ │ │ │ ├── aws-credentials.ts │ │ │ │ ├── constants.ts │ │ │ │ ├── index.ts │ │ │ │ └── message-util.ts │ │ │ ├── google │ │ │ │ ├── index.ts │ │ │ │ └── models.ts │ │ │ ├── index.ts │ │ │ ├── mistral │ │ │ │ └── index.ts │ │ │ ├── ollama │ │ │ │ ├── index.ts │ │ │ │ └── list-models.ts │ │ │ ├── openai │ │ │ │ └── index.ts │ │ │ ├── openrouter │ │ │ │ └── index.ts │ │ │ ├── ovh │ │ │ │ ├── index.ts │ │ │ │ └── models.ts │ │ │ ├── perplexity │ │ │ │ ├── index.ts │ │ │ │ └── models.ts │ │ │ └── qroq │ │ │ │ └── index.ts │ │ ├── storage │ │ │ ├── in-memory-storage-provider.ts │ │ │ ├── index.ts │ │ │ └── sqlite-conversation-storage-provider.ts │ │ ├── templates │ │ │ ├── index.ts │ │ │ ├── output-variable-extractor.ts │ │ │ ├── samples │ │ │ │ └── prompt-sample.yaml │ │ │ ├── template-definition-builder.ts │ │ │ ├── template-executor.ts │ │ │ ├── template-loader.ts │ │ │ ├── template-manager.ts │ │ │ ├── template-schema.ts │ │ │ ├── template-validator.ts │ │ │ ├── types.ts │ │ │ └── utils │ │ │ │ ├── __test__ │ │ │ │ └── extract-variable-from-content.test.ts │ │ │ │ └── extract-variable-from-content.ts │ │ ├── tools │ │ │ ├── api-server-call.tool.ts │ │ │ ├── base-tool.ts │ │ │ ├── bitbucket-loader.ts │ │ │ ├── custom-api-server-call.tool.ts │ │ │ ├── enhanced-jira.tool.ts │ │ │ ├── file-saver.tool.ts │ │ │ ├── github-loader.ts │ │ │ ├── gitlab-loader.ts │ │ │ ├── html-formatter.tool.ts │ │ │ ├── index.ts │ │ │ ├── jira.tool.ts │ │ │ ├── llamaindex-rag-v1.ts │ │ │ ├── llamaindex-rag.tool.ts │ │ │ ├── local-loader.tool.ts │ │ │ ├── local-project-loader.ts │ │ │ ├── mongodb-saver.tool.ts │ │ │ ├── redis-saver.tool.ts │ │ │ ├── remove_from_local.tool.ts │ │ │ ├── s3.tool.ts │ │ │ ├── s3_to_local.tool.ts │ │ │ ├── slack-streamer.tool.ts │ │ │ └── text-to-json.ts │ │ ├── types │ │ │ ├── conversations-types.ts │ │ │ ├── document-types.ts │ │ │ ├── file-handler.ts │ │ │ ├── index.ts │ │ │ ├── llm-provider.ts │ │ │ ├── llm-types.ts │ │ │ ├── models-cost.ts │ │ │ ├── s3-types.ts │ │ │ ├── storage.ts │ │ │ └── workflow-types.ts │ │ ├── utils │ │ │ ├── cloud │ │ │ │ ├── aws │ │ │ │ │ ├── bedrock.ts │ │ │ │ │ └── credential.ts │ │ │ │ └── index.ts │ │ │ ├── conversation │ │ │ │ ├── conversation-util.ts │ │ │ │ └── index.ts │ │ │ ├── document │ │ │ │ ├── content-validator.ts │ │ │ │ ├── document-inclusion-resolver.ts │ │ │ │ ├── document-loader.ts │ │ │ │ ├── format-handlers.ts │ │ │ │ ├── index.ts │ │ │ │ └── parsers │ │ │ │ │ ├── index.ts │ │ │ │ │ └── parser-registry.ts │ │ │ ├── error │ │ │ │ └── index.ts │ │ │ ├── file-handlers │ │ │ │ ├── factory.ts │ │ │ │ ├── index.ts │ │ │ │ ├── local-handler.ts │ │ │ │ └── s3-handler.ts │ │ │ ├── functions │ │ │ │ └── index.ts │ │ │ ├── images │ │ │ │ ├── image-to-base64.ts │ │ │ │ └── index.ts │ │ │ ├── index.ts │ │ │ ├── logger │ │ │ │ └── index.ts │ │ │ └── models-cost │ │ │ │ └── index.ts │ │ └── workflow │ │ │ ├── index.ts │ │ │ ├── workflow-executor.ts │ │ │ └── workflow-manager.ts │ ├── tsconfig.json │ ├── tsconfig.test.json │ └── typedoc.json ├── qllm-samples │ ├── CHANGELOG.md │ ├── data │ │ ├── default-agent.yaml │ │ ├── quantic_vgio.txt │ │ └── token_price.json │ ├── docs │ │ └── AVIS-MEDECIN.pdf │ ├── eslint.config.mjs │ ├── package.json │ ├── results-openai.json │ ├── src │ │ ├── agents │ │ │ ├── demo-builder-simple.ts │ │ │ ├── demo_simple_agent.ts │ │ │ ├── demo_test.ts │ │ │ ├── demo_test2.ts │ │ │ └── demo_with_storage.ts │ │ ├── api-tool-example.ts │ │ ├── conversation │ │ │ ├── demo-conversation-stream.ts │ │ │ ├── demo-conversation-with-image.ts │ │ │ ├── demo-conversation.ts │ │ │ └── demo-tool.ts │ │ ├── examples │ │ │ └── custom-api-test.ts │ │ ├── index.ts │ │ ├── prompts │ │ │ ├── chain_of_tought_leader.yaml │ │ │ ├── create_story.yaml │ │ │ ├── create_story_no_var.yaml │ │ │ ├── improve.yaml │ │ │ ├── improve_prompt.md │ │ │ ├── improve_prompt.yaml │ │ │ ├── improve_promptv2.md │ │ │ ├── role.md │ │ │ ├── story.md │ │ │ └── story_no_variable.md │ │ ├── providers │ │ │ ├── demo.ts │ │ │ └── google-demo.ts │ │ ├── template-demos │ │ │ ├── demo-common-prompt.ts │ │ │ ├── demo-prompt-builder-api.ts │ │ │ ├── demo-prompt-variable.ts │ │ │ ├── demo-prompt.ts │ │ │ ├── demo-template-builder-and-exec.ts │ │ │ ├── demo-template-builder-exec-url.ts │ │ │ ├── demo-template-builder.ts │ │ │ └── demo-template-loader.ts │ │ ├── template-with-files │ │ │ ├── demo-prompt-with-file-path.ts │ │ │ ├── demo-prompt-with-file.ts │ │ │ └── demo-prompt-with-files-path.ts │ │ ├── template-workflow │ │ │ ├── Quantum.ts │ │ │ ├── ai_research_workflow.ts │ │ │ ├── api-workflow.ts │ │ │ ├── code_review_workflow.ts │ │ │ ├── comprehensive_research_workflow.ts │ │ │ ├── create_verify_jira.ts │ │ │ ├── creative_writing_workflow.ts │ │ │ ├── demo-learning.ts │ │ │ ├── demo-translator.ts │ │ │ ├── demo_rag.ts │ │ │ ├── dynamic_yaml_search-with-s3tool copy.ts │ │ │ ├── dynamic_yaml_search-with-s3tool.ts │ │ │ ├── dynamic_yaml_search-with-tool-bis.ts │ │ │ ├── dynamic_yaml_search-with-tool.ts │ │ │ ├── dynamic_yaml_search-witth-file.ts │ │ │ ├── dynamic_yaml_search.ts │ │ │ ├── git.yaml │ │ │ ├── github-code-analysis-simple.ts │ │ │ ├── github-code-analysis.ts │ │ │ ├── jira_template.yaml │ │ │ ├── jira_workflow_executor.ts │ │ │ ├── s3-code-analysis.ts │ │ │ ├── s3-rag-workflow.ts │ │ │ ├── s3_to_local_workflow.ts │ │ │ ├── test.yml │ │ │ ├── testTool.ts │ │ │ ├── workflow_jira.yaml │ │ │ └── workflow_local.ts │ │ ├── tools │ │ │ ├── demo-jira-createBulk.ts │ │ │ ├── demo-jira-tool.ts │ │ │ ├── demo-remove-from-local.ts │ │ │ ├── demo-s3-single-file.ts │ │ │ ├── demo-s3-to-local.ts │ │ │ └── demo-s3-tool.ts │ │ └── utilities │ │ │ ├── demo-document-loader-local.ts │ │ │ ├── demo-document-loader-multiplesFiles.ts │ │ │ ├── demo-document-loader-remote.ts │ │ │ ├── demo-models-cost.ts │ │ │ └── demo-template-loader-include.ts │ ├── tsconfig.json │ └── upload │ │ └── demo-s3-tool.ts ├── sandbox-docker │ ├── example │ │ ├── nodejs-project │ │ │ ├── Dockerfile │ │ │ ├── docker-compose.yml │ │ │ ├── index.js │ │ │ ├── output │ │ │ │ └── output.txt │ │ │ └── package.json │ │ ├── python-flask │ │ │ ├── Dockerfile │ │ │ ├── app.py │ │ │ ├── docker-compose.yml │ │ │ └── requirements.txt │ │ └── python-project │ │ │ ├── Dockerfile │ │ │ ├── app.py │ │ │ ├── docker-compose.yml │ │ │ ├── output │ │ │ └── output.txt │ │ │ └── requirements.txt │ ├── package.json │ ├── src │ │ ├── core │ │ │ ├── enclave.ts │ │ │ ├── file-manager.ts │ │ │ ├── package-manager.ts │ │ │ └── virtual-fs.ts │ │ ├── security │ │ │ ├── docker-sandbox.ts │ │ │ └── resource-limiter.ts │ │ ├── test.ts │ │ ├── types.ts │ │ └── utils │ │ │ ├── error-handler.ts │ │ │ └── logger.ts │ └── tsconfig.json └── sandbox │ ├── Dockerfile │ ├── README.md │ ├── examples │ └── tools │ │ ├── code_generator.json │ │ └── text-summerize.json │ ├── jest.config.js │ ├── package.json │ ├── src │ ├── __tests__ │ │ ├── enclave.test.ts │ │ ├── file-manager.test.ts │ │ ├── package-manager.test.ts │ │ └── sandbox.test.ts │ ├── ai-tools │ │ ├── code-generator.ts │ │ └── text-summerize.ts │ ├── core │ │ ├── enclave.ts │ │ ├── file-manager.ts │ │ ├── package-manager.ts │ │ └── virtual-fs.ts │ ├── index.ts │ ├── index_example.ts │ ├── security │ │ ├── resource-limiter.ts │ │ └── sandbox.ts │ ├── templates │ │ ├── code_generator.yaml │ │ └── text-summerize.yaml │ ├── types.ts │ └── utils │ │ ├── error-handler.ts │ │ ├── execute_tool_schema.ts │ │ ├── logger.ts │ │ ├── parse_argument.ts │ │ ├── process_tool_schema.ts │ │ └── tools.ts │ ├── test.js │ ├── test │ ├── integration │ │ └── enclave-workflow.test.ts │ ├── security │ │ └── sandbox-escape.test.ts │ └── unit │ │ ├── enclave.test.ts │ │ ├── file-manager.test.ts │ │ └── package-manager.test.ts │ └── tsconfig.json ├── pnpm-workspace.yaml ├── prompts ├── analyse_articles.yaml ├── business │ └── make_comment.yaml ├── chain_of_tought_leader.yaml ├── code_analysis.yaml ├── common │ ├── improve_prompt.md │ ├── role.md │ └── story.md ├── create_story.yaml ├── debate.yaml ├── illustrations │ └── pattern.yaml ├── improve.yaml ├── improve_prompt.yaml ├── improve_promptv2.md ├── learning │ ├── result_sample │ │ └── scala_impatient.md │ └── the_impatient.yaml ├── logic │ ├── cot_prompt.yaml │ └── super_prompt.yaml ├── market_research.yaml ├── pirate.yaml ├── reasoning.yaml ├── software │ ├── create_bruno_collection.yaml │ ├── create_jest_unit_test.yaml │ └── sample │ │ ├── bruo-collection.md │ │ └── swagger-test-1.0.0-resolved.json └── typedoc.yaml └── tsconfig.json /.changeset/README.md: -------------------------------------------------------------------------------- 1 | # Changesets 2 | 3 | Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works 4 | with multi-package repos, or single-package repos to help you version and publish your code. You can 5 | find the full documentation for it [in our repository](https://github.com/changesets/changesets) 6 | 7 | We have a quick list of common questions to get you started engaging with this project in 8 | [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) 9 | -------------------------------------------------------------------------------- /.changeset/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://unpkg.com/@changesets/config@3.0.2/schema.json", 3 | "changelog": "@changesets/cli/changelog", 4 | "commit": false, 5 | "fixed": [], 6 | "linked": [], 7 | "access": "restricted", 8 | "baseBranch": "main", 9 | "updateInternalDependencies": "patch", 10 | "ignore": [] 11 | } 12 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: https://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | [*] 7 | indent_style = space 8 | indent_size = 4 9 | end_of_line = lf 10 | charset = utf-8 11 | trim_trailing_whitespace = false 12 | insert_final_newline = false -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/workflows/build-and-test.yml: -------------------------------------------------------------------------------- 1 | name: Build and Test 2 | 3 | on: 4 | push: 5 | branches: [ '*' ] 6 | pull_request: 7 | branches: [ '*' ] 8 | 9 | jobs: 10 | build-and-test: 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - uses: actions/checkout@v3 15 | 16 | - name: Use Node.js 17 | uses: actions/setup-node@v3 18 | with: 19 | node-version: '20.14.0' 20 | 21 | - name: Install pnpm 22 | uses: pnpm/action-setup@v2 23 | with: 24 | version: 9.9.0 25 | 26 | - name: Install dependencies 27 | run: pnpm install 28 | 29 | - name: Build 30 | run: pnpm run build 31 | 32 | - name: Lint 33 | run: pnpm run lint 34 | 35 | - name: Test 36 | run: pnpm run test -------------------------------------------------------------------------------- /.github/workflows/ci_cd.yml: -------------------------------------------------------------------------------- 1 | name: CI/CD On Demand 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | environment: 7 | description: 'Environment to run tests against' 8 | required: true 9 | default: 'staging' 10 | type: choice 11 | options: 12 | - staging 13 | - production 14 | debug_enabled: 15 | description: 'Run the build with debug logging' 16 | required: false 17 | type: boolean 18 | default: false 19 | 20 | jobs: 21 | build_test: 22 | runs-on: ubuntu-latest 23 | steps: 24 | - uses: actions/checkout@v3 25 | - name: Use Node.js 26 | uses: actions/setup-node@v3 27 | with: 28 | node-version: '18' 29 | - name: Install dependencies 30 | run: npm ci 31 | - name: Build 32 | run: npm run build 33 | - name: Test 34 | run: npm test 35 | env: 36 | TEST_ENVIRONMENT: ${{ github.event.inputs.environment }} 37 | - name: Debug info 38 | if: ${{ github.event.inputs.debug_enabled }} 39 | run: | 40 | echo "Debug mode enabled" 41 | npm run debug 42 | 43 | lint: 44 | runs-on: ubuntu-latest 45 | steps: 46 | - uses: actions/checkout@v3 47 | - name: Use Node.js 48 | uses: actions/setup-node@v3 49 | with: 50 | node-version: '18' 51 | - run: npm ci 52 | - run: npm run lint 53 | - run: npm run format:check 54 | 55 | deploy: 56 | needs: [build_test, lint] 57 | runs-on: ubuntu-latest 58 | steps: 59 | - uses: actions/checkout@v3 60 | - name: Deploy to ${{ github.event.inputs.environment }} 61 | run: | 62 | echo "Deploying to ${{ github.event.inputs.environment }}" 63 | # Add your deployment steps here 64 | -------------------------------------------------------------------------------- /.github/workflows/npm-publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish to NPM 2 | 3 | on: 4 | release: 5 | types: [created] 6 | workflow_dispatch: 7 | 8 | jobs: 9 | publish-npm: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v3 13 | 14 | - name: Setup Node.js 15 | uses: actions/setup-node@v3 16 | with: 17 | node-version: '18.x' 18 | registry-url: 'https://registry.npmjs.org' 19 | 20 | - name: Install pnpm 21 | uses: pnpm/action-setup@v2 22 | with: 23 | version: 8 24 | 25 | - name: Install dependencies 26 | run: pnpm install 27 | 28 | #- name: Run tests 29 | # run: | 30 | # cd packages/qllm-lib 31 | # pnpm test 32 | # cd ../qllm-cli 33 | # pnpm test 34 | 35 | - name: Build packages 36 | run: | 37 | cd packages/qllm-lib 38 | pnpm run build:prod 39 | cd ../qllm-cli 40 | pnpm run build:prod 41 | 42 | - name: Configure npm 43 | run: | 44 | echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc 45 | npm whoami 46 | env: 47 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} 48 | 49 | - name: Publish qllm-lib 50 | env: 51 | NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} 52 | run: | 53 | cd packages/qllm-lib 54 | pnpm publish --no-git-checks --access public 55 | 56 | - name: Publish qllm-cli 57 | env: 58 | NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} 59 | run: | 60 | cd packages/qllm-cli 61 | pnpm publish --no-git-checks --access public 62 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | */node_modules/ 3 | */*/node_modules/ 4 | dist/ 5 | .env 6 | *.log 7 | .DS_Store 8 | tasks/ 9 | package-lock.json 10 | .qllmrc.yaml 11 | .qllmrc.yaml* 12 | dist 13 | *.tsbuildinfo 14 | coverage 15 | .aider* 16 | .obsidian 17 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | # Use pnpm as the package manager 2 | package-manager=pnpm 3 | 4 | # Enable shameful hoisting for better compatibility 5 | shamefully-hoist=true 6 | 7 | # Use strict-peer-dependencies to ensure all peer dependencies are installed 8 | strict-peer-dependencies=true 9 | 10 | # Auto-install peers to avoid manual peer dependency installation 11 | auto-install-peers=true 12 | 13 | # Use workspace protocol for local dependencies 14 | link-workspace-packages=true 15 | 16 | # Save exact versions in package.json 17 | save-exact=true 18 | 19 | # Use the highest available version when installing dependencies 20 | prefer-highest-version=true 21 | 22 | # Disable package-lock.json generation (pnpm uses pnpm-lock.yaml instead) 23 | package-lock=false 24 | 25 | # Set the default node environment 26 | node-env=production 27 | 28 | # Configure registry (uncomment and modify if you're using a custom registry) 29 | # registry=https://registry.npmjs.org/ 30 | 31 | # Configure cache location (uncomment and modify if needed) 32 | # cache=~/.pnpm-store 33 | 34 | strict-peer-dependencies=false 35 | 36 | 37 | hoist=true 38 | hoist-workspace-packages=true 39 | prefer-workspace-packages=true -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 7 | 8 | ## [Unreleased] 9 | 10 | ### Added 11 | - New feature placeholder 12 | 13 | ### Changed 14 | - Change placeholder 15 | 16 | ### Deprecated 17 | - Deprecation placeholder 18 | 19 | ### Removed 20 | - Removal placeholder 21 | 22 | ### Fixed 23 | 24 | ## [1.1.1] 25 | - Bug fix --profile and --region option 26 | - Bug fix placeholder 27 | 28 | ### Security 29 | - Security update placeholder 30 | 31 | ## [0.6.2] - 2024-07-03 32 | 33 | ## Improved 34 | 35 | - Feat: Implement spinner helper and improve stream handling 36 | 37 | ## [0.6.1] - 2024-07-03 38 | 39 | ### Added 40 | - Implemented the ollama provider 41 | 42 | [0.6.1]: https://github.com/raphaelmansuy/qllm/compare/v0.6.1..v6.0.0 -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright Raphaël MANSUY & Quantalogic [Quantalogic] 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /ROADMAP.md: -------------------------------------------------------------------------------- 1 | 2 | [ ] - Add Handlebar support for prompt 3 | [ ] - Add Agents L0 = Model System + Model + parameters 4 | [ ] - Add Agents L1 = L0 + Tools 5 | [ ] - Add Embedding support on command lines 6 | [ ] - Add Storage / search conversation -> Other Storage Provider 7 | [ ] - Add Flow support 8 | [ ] - Add Local index of prompts 9 | [ ] - Add Flux Graph Worflow 10 | [ ] - Add Memory 11 | [ ] - Add Chunking strategy 12 | [ ] - Search prompt / agents / Tools / workflow ... 13 | 14 | -------------------------------------------------------------------------------- /docs/scripts/convert.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | pandoc ./docs/04_ux_article.md --lua-filter ./docs/scripts/mermaid-filter.lua -o ./docs/docx/04_ux_article.docx -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | // jest.config.js 2 | module.exports = { 3 | preset: 'ts-jest', 4 | testEnvironment: 'node', 5 | moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], 6 | transform: { 7 | '^.+\\.tsx?$': 'ts-jest', // Use ts-jest for TypeScript files 8 | '^.+\\.jsx?$': 'babel-jest', // Use babel-jest for JavaScript files 9 | }, 10 | moduleNameMapper: { 11 | // Add any necessary mappings for non-JS modules here 12 | }, 13 | testMatch: ['**/__tests__/**/*.ts?(x)', '**/?(*.)+(spec|test).ts?(x)'], 14 | collectCoverage: true, 15 | coverageDirectory: 'coverage', 16 | }; 17 | -------------------------------------------------------------------------------- /packages/qllm-cli/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # qllm 2 | 3 | ## 2.9.3 4 | 5 | ### Patch Changes 6 | 7 | - Updated dependencies 8 | - qllm-lib@3.6.2 9 | 10 | ## 2.9.2 11 | 12 | ### Patch Changes 13 | 14 | - Add check for update at startup 15 | 16 | ## 2.9.1 17 | 18 | ### Patch Changes 19 | 20 | - 63b73ea: Fix stdin 21 | 22 | ## 2.9.0 23 | 24 | ### Minor Changes 25 | 26 | - Improve configuration, and several fix 27 | 28 | ### Patch Changes 29 | 30 | - Updated dependencies 31 | - qllm-lib@3.6.0 32 | 33 | ## 2.8.0 34 | 35 | ### Minor Changes 36 | 37 | - Improve the chat 38 | 39 | ### Patch Changes 40 | 41 | - Updated dependencies 42 | - qllm-lib@3.5.0 43 | 44 | ## 2.7.2 45 | 46 | ### Patch Changes 47 | 48 | - 72aa8c0: Add run command feature in chat 49 | 50 | ## 2.7.1 51 | 52 | ### Patch Changes 53 | 54 | - 9b93450: Fix parameters parsing for commands 55 | - Updated dependencies [9b93450] 56 | - qllm-lib@3.4.1 57 | 58 | ## 2.7.0 59 | 60 | ### Minor Changes 61 | 62 | - 572a7d0: Improve the configure command 63 | 64 | ## 2.6.0 65 | 66 | ### Minor Changes 67 | 68 | - c95ac72: add run template command, and improve configuration process 69 | 70 | ## 2.5.1 71 | 72 | ### Patch Changes 73 | 74 | - de69b49: support directly run a template 75 | 76 | ## 2.5.0 77 | 78 | ### Minor Changes 79 | 80 | - 4e20449: fix regex issues 81 | 82 | ### Patch Changes 83 | 84 | - 6611cb9: - Add system message and LLM parameters support in template 85 | - Update run command to use the parameters in the template 86 | - Updated dependencies [6611cb9] 87 | - Updated dependencies [4e20449] 88 | - qllm-lib@3.4.0 89 | 90 | ## 2.1.1 91 | 92 | ### Patch Changes 93 | 94 | - Updated dependencies [5c4379f] 95 | - qllm-lib@3.0.1 96 | 97 | ## 2.1.0 98 | 99 | ### Minor Changes 100 | 101 | - 59b58e7: Move to pnpm 102 | - a5f8088: 2.0.0 103 | 104 | ### Patch Changes 105 | 106 | - feeaed4: Minor update 107 | - Updated dependencies [59b58e7] 108 | - Updated dependencies [feeaed4] 109 | - Updated dependencies [a5f8088] 110 | - qllm-lib@3.0.0 111 | 112 | ## 2.0.0 113 | 114 | ### Major Changes 115 | 116 | - Run command improvements 117 | -------------------------------------------------------------------------------- /packages/qllm-cli/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | // packages//qllm-cli/eslint.config.jms 2 | // @ts-check 3 | 4 | import tsPlugin from '@typescript-eslint/eslint-plugin'; 5 | import tsParser from '@typescript-eslint/parser'; 6 | 7 | export default [ 8 | { 9 | ignores: ['**/node_modules/**', '**/dist/**'], // Ignore unnecessary files 10 | }, 11 | { 12 | files: ['*.ts', '*.tsx'], // Apply only to TypeScript files 13 | languageOptions: { 14 | parser: tsParser, 15 | parserOptions: { 16 | ecmaVersion: 'latest', 17 | sourceType: 'module', 18 | project: './tsconfig.json', // Ensure this points to your tsconfig.json 19 | tsconfigRootDir: process.cwd(), 20 | }, 21 | }, 22 | plugins: { 23 | '@typescript-eslint': tsPlugin, 24 | }, 25 | rules: { 26 | ...tsPlugin.configs.recommended.rules, // Use recommended TypeScript rules 27 | ...tsPlugin.configs['recommended-requiring-type-checking'].rules, // Include type-checking rules 28 | '@typescript-eslint/no-unused-vars': [ 29 | 'warn', 30 | { 31 | argsIgnorePattern: '^_', 32 | varsIgnorePattern: '^_', 33 | caughtErrorsIgnorePattern: '^_', 34 | }, 35 | ], 36 | '@typescript-eslint/no-unused-expressions': [ 37 | 'error', 38 | { allowShortCircuit: true, allowTernary: true }, 39 | ], 40 | 'no-empty': 'warn', 41 | 'no-prototype-builtins': 'warn', 42 | '@typescript-eslint/no-explicit-any': 'warn', // Changed from 'error' to 'warn' 43 | 'no-case-declarations': 'warn', // Changed from 'error' to 'warn' 44 | 'require-yield': 'warn', // Changed from 'error' to 'warn' 45 | 'no-useless-catch': 'warn', // Changed from 'error' to 'warn' 46 | }, 47 | }, 48 | ]; -------------------------------------------------------------------------------- /packages/qllm-cli/rollup.config.mjs: -------------------------------------------------------------------------------- 1 | import resolve from "@rollup/plugin-node-resolve"; 2 | import commonjs from "@rollup/plugin-commonjs"; 3 | import json from "@rollup/plugin-json"; 4 | //import { terser } from 'rollup-plugin-terser'; 5 | //import analyze from 'rollup-plugin-analyzer'; 6 | //import gzip from 'rollup-plugin-gzip'; 7 | 8 | export default { 9 | input: "dist/qllm.js", // Change this to point to the compiled TypeScript output 10 | output: [ 11 | { 12 | dir: "dist", 13 | format: "cjs", 14 | sourcemap: true, 15 | exports: "named", 16 | }, 17 | ], 18 | plugins: [ 19 | resolve({ 20 | preferBuiltins: true, 21 | }), 22 | commonjs(), 23 | json(), 24 | // isProduction && terser(), 25 | // analyze({ summaryOnly: true }), 26 | // isProduction && gzip(), 27 | ], 28 | external: [ 29 | "openai", 30 | "groq-sdk", 31 | "@anthropic-ai/sdk", 32 | "@anthropic-ai/bedrock-sdk", 33 | "@aws-sdk/client-bedrock", 34 | "@aws-sdk/credential-providers", 35 | "axios", 36 | "js-yaml", 37 | "mime-types", 38 | "ollama", 39 | "sqlite", 40 | "uuid", 41 | "zod", 42 | ], 43 | }; 44 | -------------------------------------------------------------------------------- /packages/qllm-cli/src/chat/commands/display-current-options.ts: -------------------------------------------------------------------------------- 1 | import { CommandContext } from "../command-processor"; 2 | import { getListProviderNames } from "qllm-lib"; 3 | 4 | export function displayCurrentOptions( 5 | args: string[], 6 | { configManager, ioManager }: CommandContext, 7 | ): Promise { 8 | const config = configManager.getConfig(); 9 | 10 | const options = [ 11 | { name: "Provider", value: configManager.getProvider() }, 12 | { name: "Model", value: config.getModel() }, // Use the stored model directly 13 | { name: "Temperature", value: config.getTemperature() }, 14 | { name: "Max Tokens", value: config.getMaxTokens() }, 15 | { name: "Top P", value: config.getTopP() }, 16 | { name: "Frequency Penalty", value: config.getFrequencyPenalty() }, 17 | { name: "Presence Penalty", value: config.getPresencePenalty() }, 18 | { name: "Stop Sequence", value: config.getStopSequence()?.join(", ") }, 19 | ]; 20 | 21 | const validProviders = getListProviderNames(); 22 | ioManager.displayInfo(`Valid providers: ${validProviders.join(", ")}`); 23 | 24 | ioManager.displayConfigOptions(options); 25 | 26 | return Promise.resolve(); 27 | } 28 | -------------------------------------------------------------------------------- /packages/qllm-cli/src/chat/commands/list-models.ts: -------------------------------------------------------------------------------- 1 | // Modify list-models.ts 2 | 3 | import { getLLMProvider } from "qllm-lib"; 4 | import { DEFAULT_PROVIDER } from "../../constants"; 5 | import { CommandContext } from "../command-processor"; 6 | 7 | export async function listModels( 8 | args: string[], 9 | { ioManager, configManager }: CommandContext, 10 | ): Promise { 11 | const argProviderName = args.length > 0 ? args[0] : null; 12 | const spinner = ioManager.createSpinner("Fetching models..."); 13 | spinner.start(); 14 | 15 | try { 16 | const config = configManager.getConfig(); 17 | const providerName = 18 | argProviderName || config.getProvider() || DEFAULT_PROVIDER; 19 | const provider = await getLLMProvider(providerName); 20 | const models = await provider.listModels(); 21 | 22 | spinner.success({ text: "Models fetched successfully" }); 23 | ioManager.newLine(); 24 | 25 | ioManager.displayTitle(`Available Models for ${providerName}`); 26 | ioManager.newLine(); 27 | 28 | ioManager.displayModelTable( 29 | models.map((model) => ({ 30 | id: model.id, 31 | description: (model.description || "N/A").substring(0, 50), 32 | })), 33 | ); 34 | 35 | ioManager.newLine(); 36 | ioManager.displayInfo(`Total models: ${models.length}`); 37 | ioManager.displayInfo(`Provider: ${providerName}`); 38 | } catch (error) { 39 | spinner.error({ 40 | text: `Failed to list models: ${(error as Error).message}`, 41 | }); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /packages/qllm-cli/src/chat/commands/list-providers.ts: -------------------------------------------------------------------------------- 1 | import { getListProviderNames } from "qllm-lib"; 2 | import { CommandContext } from "../command-processor"; 3 | 4 | export function listProviders( 5 | args: string[], 6 | { ioManager }: CommandContext, 7 | ): Promise { 8 | const providers = getListProviderNames(); 9 | 10 | ioManager.displayProviderList(providers); 11 | 12 | return Promise.resolve(); 13 | } 14 | -------------------------------------------------------------------------------- /packages/qllm-cli/src/constants/config-constants.ts: -------------------------------------------------------------------------------- 1 | export const CONFIG_OPTIONS = [ 2 | "provider", 3 | "model", 4 | "logLevel", 5 | "customPromptDirectory", 6 | ]; 7 | -------------------------------------------------------------------------------- /packages/qllm-cli/src/constants/index.ts: -------------------------------------------------------------------------------- 1 | export const DEFAULT_PROVIDER = "openai"; 2 | export const DEFAULT_MODEL = "gpt-4o-mini"; 3 | export const DEFAULT_MAX_TOKENS = 16 * 1024; 4 | export const DEFAULT_TEMPERATURE = 0.7; 5 | export const DEFAULT_TOP_P = 1; 6 | export const DEFAULT_FREQUENCY_PENALTY = 0; 7 | export const DEFAULT_PRESENCE_PENALTY = 0; 8 | export const DEFAULT_STOP_SEQUENCE = []; 9 | -------------------------------------------------------------------------------- /packages/qllm-cli/src/index.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | import main from "./qllm"; 4 | 5 | main() 6 | .then(() => {}) 7 | .catch((error) => { 8 | console.error("An error occurred:", error); 9 | process.exit(1); 10 | }); 11 | -------------------------------------------------------------------------------- /packages/qllm-cli/src/types/chat-command-options.ts: -------------------------------------------------------------------------------- 1 | import { z } from "zod"; 2 | 3 | export const ChatCommandOptionsSchema = z.object({ 4 | provider: z.string().optional(), 5 | model: z.string().optional(), 6 | maxTokens: z.number().int().positive().optional(), 7 | temperature: z.number().min(0).max(1).optional(), 8 | topP: z.number().min(0).max(1).optional(), 9 | frequencyPenalty: z.number().optional(), 10 | presencePenalty: z.number().optional(), 11 | stopSequence: z.array(z.string()).optional(), 12 | }); 13 | 14 | export type ChatCommandOptions = z.infer; 15 | -------------------------------------------------------------------------------- /packages/qllm-cli/src/types/run-command-options.ts: -------------------------------------------------------------------------------- 1 | import { z } from "zod"; 2 | 3 | export const RunCommandOptionsSchema = z.object({ 4 | type: z.enum(["file", "url", "inline"]).default("file").optional(), 5 | variables: z.string().optional(), 6 | provider: z.string().optional(), 7 | model: z.string().optional(), 8 | maxTokens: z.number().int().positive().optional(), 9 | temperature: z.number().min(0).max(1).optional(), 10 | noStream: z.boolean().optional(), 11 | output: z.string().optional(), 12 | extract: z.string().optional(), 13 | }); 14 | 15 | export type RunCommandOptions = z.infer; 16 | -------------------------------------------------------------------------------- /packages/qllm-cli/src/utils/common.ts: -------------------------------------------------------------------------------- 1 | export const processAndExit = ( 2 | f: (...args: any[]) => void | Promise, 3 | ): ((...args: any[]) => Promise) => { 4 | return async (...args: any[]) => { 5 | try { 6 | await f(...args); 7 | process.exit(0); 8 | } catch (error) { 9 | console.error("An error occurred:", error); 10 | process.exit(1); 11 | } 12 | }; 13 | }; 14 | -------------------------------------------------------------------------------- /packages/qllm-cli/src/utils/image-utils.ts: -------------------------------------------------------------------------------- 1 | import fs from "fs/promises"; 2 | import mime from "mime-types"; 3 | 4 | export async function isImageFile(filePath: string): Promise { 5 | try { 6 | const stats = await fs.stat(filePath); 7 | if (!stats.isFile()) return false; 8 | 9 | const mimeType = mime.lookup(filePath); 10 | return mimeType ? mimeType.startsWith("image/") : false; 11 | } catch { 12 | return false; 13 | } 14 | } 15 | 16 | export async function readImageFileAndConvertToBase64( 17 | imagePath: string, 18 | ): Promise { 19 | if (await isImageFile(imagePath)) { 20 | // Convert file to base64 21 | const fileContent = await fs.readFile(imagePath); 22 | const mimeType = mime.lookup(imagePath) || "application/octet-stream"; 23 | return `data:${mimeType};base64,${fileContent.toString("base64")}`; 24 | } 25 | // Assume it's already a valid URL or base64 string 26 | return imagePath; 27 | } 28 | -------------------------------------------------------------------------------- /packages/qllm-cli/src/utils/screenshot/types.ts: -------------------------------------------------------------------------------- 1 | // interfaces.ts 2 | 3 | export interface CaptureOptions { 4 | windowName?: string; 5 | interactive?: boolean; 6 | fullScreen?: boolean; 7 | clipboard?: boolean; 8 | mainMonitorOnly?: boolean; 9 | displayNumber?: number; 10 | captureMouseCursor?: boolean; 11 | } 12 | 13 | export interface Window { 14 | name: string; 15 | id: string; 16 | app: string; 17 | } 18 | 19 | export interface Screen { 20 | id: string; 21 | type: string; 22 | resolution: string; 23 | } 24 | 25 | export interface ScreenshotCapture { 26 | initialize(): Promise; 27 | captureAndGetBase64(options: CaptureOptions): Promise; 28 | listWindows(): Promise; 29 | listScreens(): Promise; 30 | cleanupTempDir(): Promise; 31 | } 32 | 33 | export interface ScreenshotCaptureOptions { 34 | maxRetries?: number; 35 | retryDelay?: number; 36 | } 37 | -------------------------------------------------------------------------------- /packages/qllm-cli/src/utils/screenshot/utils.ts: -------------------------------------------------------------------------------- 1 | // utils.ts 2 | 3 | import * as fs from "fs/promises"; 4 | import * as path from "path"; 5 | import * as os from "os"; 6 | import { v4 as uuidv4 } from "uuid"; 7 | 8 | export function createTempDir(): string { 9 | const baseDir = os.tmpdir(); 10 | const uniqueDir = `screenshot-capture-${uuidv4()}`; 11 | return path.join(baseDir, uniqueDir); 12 | } 13 | 14 | export async function cleanup(filePath: string): Promise { 15 | try { 16 | await fs.unlink(filePath); 17 | } catch (error) { 18 | console.warn("Failed to delete temporary file:", error); 19 | } 20 | } 21 | 22 | export function delay(ms: number): Promise { 23 | return new Promise((resolve) => setTimeout(resolve, ms)); 24 | } 25 | -------------------------------------------------------------------------------- /packages/qllm-cli/src/utils/template-utils.ts: -------------------------------------------------------------------------------- 1 | export function parseVariables(variablesString?: string): Record { 2 | if (!variablesString) return {}; 3 | try { 4 | return JSON.parse(variablesString); 5 | } catch (error) { 6 | throw new Error("Invalid JSON format for variables"); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/qllm-cli/src/utils/write-file.ts: -------------------------------------------------------------------------------- 1 | import { promises as fs } from "fs"; 2 | import * as path from "path"; 3 | 4 | export async function writeToFile( 5 | filePath: string, 6 | content: string, 7 | options: { 8 | encoding?: BufferEncoding; 9 | mode?: number; 10 | flag?: string; 11 | append?: boolean; 12 | } = {}, 13 | ): Promise { 14 | if (typeof filePath !== "string" || filePath.trim().length === 0) { 15 | throw new Error("Invalid file path"); 16 | } 17 | 18 | if (typeof content !== "string") { 19 | throw new Error("Content must be a string"); 20 | } 21 | 22 | const { encoding = "utf8", mode = 0o666, append = false } = options; 23 | const flag = append ? "a" : "w"; 24 | 25 | let fileHandle: fs.FileHandle | null = null; 26 | try { 27 | // Ensure the directory exists 28 | await fs.mkdir(path.dirname(filePath), { recursive: true }); 29 | 30 | fileHandle = await fs.open(filePath, flag, mode); 31 | await fileHandle.writeFile(content, { encoding }); 32 | } finally { 33 | if (fileHandle) { 34 | try { 35 | await fileHandle.close(); 36 | } catch (closeError) { 37 | // Handle close error if needed 38 | } 39 | } 40 | } 41 | } 42 | 43 | export async function fileExists(filePath: string): Promise { 44 | try { 45 | await fs.access(filePath); 46 | return true; // File exists 47 | } catch { 48 | return false; // File does not exist 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /packages/qllm-cli/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "types": ["node"], 4 | "moduleResolution": "node", 5 | "esModuleInterop": true, 6 | "allowSyntheticDefaultImports": true, 7 | "target": "ES2020", 8 | "module": "commonjs", 9 | "forceConsistentCasingInFileNames": true, 10 | "strict": true, 11 | "skipLibCheck": true, 12 | "outDir": "dist", 13 | "declaration": true, 14 | "declarationMap": true, 15 | "sourceMap": true, 16 | "rootDir": "src", 17 | "rootDirs": ["types"] 18 | }, 19 | "include": ["src/**/*"], 20 | "exclude": ["node_modules", "dist"] 21 | } 22 | -------------------------------------------------------------------------------- /packages/qllm-lib/.prettierignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | build 4 | coverage 5 | dist/*/** -------------------------------------------------------------------------------- /packages/qllm-lib/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": true, 3 | "trailingComma": "all", 4 | "singleQuote": true, 5 | "printWidth": 100, 6 | "tabWidth": 2 7 | } 8 | -------------------------------------------------------------------------------- /packages/qllm-lib/API_DOCUMENTATION.md: -------------------------------------------------------------------------------- 1 | # QLLM Library API Documentation 2 | 3 | This documentation provides details about the QLLM Library API. 4 | 5 | ## Overview 6 | 7 | [Provide a brief overview of your library here] 8 | 9 | ## Key Components 10 | 11 | [List and briefly describe the main components of your library] 12 | 13 | ## Getting Started 14 | 15 | [Provide basic usage instructions] 16 | 17 | For detailed API references, please see the generated documentation below. 18 | -------------------------------------------------------------------------------- /packages/qllm-lib/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # qllm-lib 2 | 3 | ## 3.6.2 4 | 5 | ### Patch Changes 6 | 7 | - update aws-credentials to use profile or environment variables 8 | 9 | ## 3.6.0 10 | 11 | ### Minor Changes 12 | 13 | - Improve configuration, and several fix 14 | 15 | ## 3.5.0 16 | 17 | ### Minor Changes 18 | 19 | - Improve the chat 20 | 21 | ## 3.4.1 22 | 23 | ### Patch Changes 24 | 25 | - 9b93450: Fix parameters parsing for commands 26 | 27 | ## 3.4.0 28 | 29 | ### Minor Changes 30 | 31 | - 4e20449: fix regex issues 32 | 33 | ### Patch Changes 34 | 35 | - 6611cb9: - Add system message and LLM parameters support in template 36 | - Update run command to use the parameters in the template 37 | 38 | ## 3.0.1 39 | 40 | ### Patch Changes 41 | 42 | - 5c4379f: Minor fix 43 | 44 | ## 3.0.0 45 | 46 | ### Major Changes 47 | 48 | - a5f8088: 2.0.0 49 | 50 | ### Minor Changes 51 | 52 | - 59b58e7: Move to pnpm 53 | 54 | ### Patch Changes 55 | 56 | - feeaed4: Minor update 57 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/README.md: -------------------------------------------------------------------------------- 1 | **QLLM Library API Documentation v3.0.6** • [**Docs**](globals.md) 2 | 3 | --- 4 | 5 | # QLLM Library API Documentation 6 | 7 | This documentation provides details about the QLLM Library API. 8 | 9 | ## Overview 10 | 11 | [Provide a brief overview of your library here] 12 | 13 | ## Key Components 14 | 15 | [List and briefly describe the main components of your library] 16 | 17 | ## Getting Started 18 | 19 | [Provide basic usage instructions] 20 | 21 | For detailed API references, please see the generated documentation below. 22 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/classes/AuthenticationError.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / AuthenticationError 6 | 7 | # Class: AuthenticationError 8 | 9 | ## Extends 10 | 11 | - [`LLMProviderError`](LLMProviderError.md) 12 | 13 | ## Constructors 14 | 15 | ### new AuthenticationError() 16 | 17 | > **new AuthenticationError**(`message`, `providerName`, `errorCode`?): [`AuthenticationError`](AuthenticationError.md) 18 | 19 | #### Parameters 20 | 21 | • **message**: `string` 22 | 23 | • **providerName**: `string` 24 | 25 | • **errorCode?**: `string` 26 | 27 | #### Returns 28 | 29 | [`AuthenticationError`](AuthenticationError.md) 30 | 31 | #### Inherited from 32 | 33 | [`LLMProviderError`](LLMProviderError.md).[`constructor`](LLMProviderError.md#constructors) 34 | 35 | #### Defined in 36 | 37 | [packages/qllm-lib/src/types/llm-provider.ts:35](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-provider.ts#L35) 38 | 39 | ## Properties 40 | 41 | ### errorCode? 42 | 43 | > `optional` **errorCode**: `string` 44 | 45 | #### Inherited from 46 | 47 | [`LLMProviderError`](LLMProviderError.md).[`errorCode`](LLMProviderError.md#errorcode) 48 | 49 | #### Defined in 50 | 51 | [packages/qllm-lib/src/types/llm-provider.ts:35](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-provider.ts#L35) 52 | 53 | --- 54 | 55 | ### providerName 56 | 57 | > **providerName**: `string` 58 | 59 | #### Inherited from 60 | 61 | [`LLMProviderError`](LLMProviderError.md).[`providerName`](LLMProviderError.md#providername) 62 | 63 | #### Defined in 64 | 65 | [packages/qllm-lib/src/types/llm-provider.ts:35](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-provider.ts#L35) 66 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/classes/ConfigurationError.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / ConfigurationError 6 | 7 | # Class: ConfigurationError 8 | 9 | ## Extends 10 | 11 | - [`QllmError`](QllmError.md) 12 | 13 | ## Constructors 14 | 15 | ### new ConfigurationError() 16 | 17 | > **new ConfigurationError**(`message`): [`ConfigurationError`](ConfigurationError.md) 18 | 19 | #### Parameters 20 | 21 | • **message**: `string` 22 | 23 | #### Returns 24 | 25 | [`ConfigurationError`](ConfigurationError.md) 26 | 27 | #### Overrides 28 | 29 | [`QllmError`](QllmError.md).[`constructor`](QllmError.md#constructors) 30 | 31 | #### Defined in 32 | 33 | [packages/qllm-lib/src/templates/types.ts:36](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/templates/types.ts#L36) 34 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/classes/ConversationError.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / ConversationError 6 | 7 | # Class: ConversationError 8 | 9 | ## Extends 10 | 11 | - `Error` 12 | 13 | ## Extended by 14 | 15 | - [`ConversationNotFoundError`](ConversationNotFoundError.md) 16 | - [`InvalidConversationOperationError`](InvalidConversationOperationError.md) 17 | 18 | ## Constructors 19 | 20 | ### new ConversationError() 21 | 22 | > **new ConversationError**(`message`): [`ConversationError`](ConversationError.md) 23 | 24 | #### Parameters 25 | 26 | • **message**: `string` 27 | 28 | #### Returns 29 | 30 | [`ConversationError`](ConversationError.md) 31 | 32 | #### Overrides 33 | 34 | `Error.constructor` 35 | 36 | #### Defined in 37 | 38 | [packages/qllm-lib/src/types/conversations-types.ts:74](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/conversations-types.ts#L74) 39 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/classes/ConversationNotFoundError.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / ConversationNotFoundError 6 | 7 | # Class: ConversationNotFoundError 8 | 9 | ## Extends 10 | 11 | - [`ConversationError`](ConversationError.md) 12 | 13 | ## Constructors 14 | 15 | ### new ConversationNotFoundError() 16 | 17 | > **new ConversationNotFoundError**(`id`): [`ConversationNotFoundError`](ConversationNotFoundError.md) 18 | 19 | #### Parameters 20 | 21 | • **id**: `string` 22 | 23 | #### Returns 24 | 25 | [`ConversationNotFoundError`](ConversationNotFoundError.md) 26 | 27 | #### Overrides 28 | 29 | [`ConversationError`](ConversationError.md).[`constructor`](ConversationError.md#constructors) 30 | 31 | #### Defined in 32 | 33 | [packages/qllm-lib/src/types/conversations-types.ts:81](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/conversations-types.ts#L81) 34 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/classes/FileOperationError.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / FileOperationError 6 | 7 | # Class: FileOperationError 8 | 9 | ## Extends 10 | 11 | - [`TemplateManagerError`](TemplateManagerError.md) 12 | 13 | ## Constructors 14 | 15 | ### new FileOperationError() 16 | 17 | > **new FileOperationError**(`operation`, `fileName`, `reason`): [`FileOperationError`](FileOperationError.md) 18 | 19 | #### Parameters 20 | 21 | • **operation**: `string` 22 | 23 | • **fileName**: `string` 24 | 25 | • **reason**: `string` 26 | 27 | #### Returns 28 | 29 | [`FileOperationError`](FileOperationError.md) 30 | 31 | #### Overrides 32 | 33 | [`TemplateManagerError`](TemplateManagerError.md).[`constructor`](TemplateManagerError.md#constructors) 34 | 35 | #### Defined in 36 | 37 | [packages/qllm-lib/src/templates/types.ts:103](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/templates/types.ts#L103) 38 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/classes/InputValidationError.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / InputValidationError 6 | 7 | # Class: InputValidationError 8 | 9 | ## Extends 10 | 11 | - [`QllmError`](QllmError.md) 12 | 13 | ## Constructors 14 | 15 | ### new InputValidationError() 16 | 17 | > **new InputValidationError**(`message`): [`InputValidationError`](InputValidationError.md) 18 | 19 | #### Parameters 20 | 21 | • **message**: `string` 22 | 23 | #### Returns 24 | 25 | [`InputValidationError`](InputValidationError.md) 26 | 27 | #### Overrides 28 | 29 | [`QllmError`](QllmError.md).[`constructor`](QllmError.md#constructors) 30 | 31 | #### Defined in 32 | 33 | [packages/qllm-lib/src/templates/types.ts:63](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/templates/types.ts#L63) 34 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/classes/InvalidConversationOperationError.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / InvalidConversationOperationError 6 | 7 | # Class: InvalidConversationOperationError 8 | 9 | ## Extends 10 | 11 | - [`ConversationError`](ConversationError.md) 12 | 13 | ## Constructors 14 | 15 | ### new InvalidConversationOperationError() 16 | 17 | > **new InvalidConversationOperationError**(`message`): [`InvalidConversationOperationError`](InvalidConversationOperationError.md) 18 | 19 | #### Parameters 20 | 21 | • **message**: `string` 22 | 23 | #### Returns 24 | 25 | [`InvalidConversationOperationError`](InvalidConversationOperationError.md) 26 | 27 | #### Overrides 28 | 29 | [`ConversationError`](ConversationError.md).[`constructor`](ConversationError.md#constructors) 30 | 31 | #### Defined in 32 | 33 | [packages/qllm-lib/src/types/conversations-types.ts:88](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/conversations-types.ts#L88) 34 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/classes/InvalidRequestError.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / InvalidRequestError 6 | 7 | # Class: InvalidRequestError 8 | 9 | ## Extends 10 | 11 | - [`LLMProviderError`](LLMProviderError.md) 12 | 13 | ## Constructors 14 | 15 | ### new InvalidRequestError() 16 | 17 | > **new InvalidRequestError**(`message`, `providerName`, `errorCode`?): [`InvalidRequestError`](InvalidRequestError.md) 18 | 19 | #### Parameters 20 | 21 | • **message**: `string` 22 | 23 | • **providerName**: `string` 24 | 25 | • **errorCode?**: `string` 26 | 27 | #### Returns 28 | 29 | [`InvalidRequestError`](InvalidRequestError.md) 30 | 31 | #### Inherited from 32 | 33 | [`LLMProviderError`](LLMProviderError.md).[`constructor`](LLMProviderError.md#constructors) 34 | 35 | #### Defined in 36 | 37 | [packages/qllm-lib/src/types/llm-provider.ts:35](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-provider.ts#L35) 38 | 39 | ## Properties 40 | 41 | ### errorCode? 42 | 43 | > `optional` **errorCode**: `string` 44 | 45 | #### Inherited from 46 | 47 | [`LLMProviderError`](LLMProviderError.md).[`errorCode`](LLMProviderError.md#errorcode) 48 | 49 | #### Defined in 50 | 51 | [packages/qllm-lib/src/types/llm-provider.ts:35](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-provider.ts#L35) 52 | 53 | --- 54 | 55 | ### providerName 56 | 57 | > **providerName**: `string` 58 | 59 | #### Inherited from 60 | 61 | [`LLMProviderError`](LLMProviderError.md).[`providerName`](LLMProviderError.md#providername) 62 | 63 | #### Defined in 64 | 65 | [packages/qllm-lib/src/types/llm-provider.ts:35](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-provider.ts#L35) 66 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/classes/InvalidTemplateError.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / InvalidTemplateError 6 | 7 | # Class: InvalidTemplateError 8 | 9 | ## Extends 10 | 11 | - [`TemplateManagerError`](TemplateManagerError.md) 12 | 13 | ## Constructors 14 | 15 | ### new InvalidTemplateError() 16 | 17 | > **new InvalidTemplateError**(`templateName`, `reason`): [`InvalidTemplateError`](InvalidTemplateError.md) 18 | 19 | #### Parameters 20 | 21 | • **templateName**: `string` 22 | 23 | • **reason**: `string` 24 | 25 | #### Returns 26 | 27 | [`InvalidTemplateError`](InvalidTemplateError.md) 28 | 29 | #### Overrides 30 | 31 | [`TemplateManagerError`](TemplateManagerError.md).[`constructor`](TemplateManagerError.md#constructors) 32 | 33 | #### Defined in 34 | 35 | [packages/qllm-lib/src/templates/types.ts:95](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/templates/types.ts#L95) 36 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/classes/LLMProviderError.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / LLMProviderError 6 | 7 | # Class: LLMProviderError 8 | 9 | ## Extends 10 | 11 | - `Error` 12 | 13 | ## Extended by 14 | 15 | - [`AuthenticationError`](AuthenticationError.md) 16 | - [`RateLimitError`](RateLimitError.md) 17 | - [`InvalidRequestError`](InvalidRequestError.md) 18 | 19 | ## Constructors 20 | 21 | ### new LLMProviderError() 22 | 23 | > **new LLMProviderError**(`message`, `providerName`, `errorCode`?): [`LLMProviderError`](LLMProviderError.md) 24 | 25 | #### Parameters 26 | 27 | • **message**: `string` 28 | 29 | • **providerName**: `string` 30 | 31 | • **errorCode?**: `string` 32 | 33 | #### Returns 34 | 35 | [`LLMProviderError`](LLMProviderError.md) 36 | 37 | #### Overrides 38 | 39 | `Error.constructor` 40 | 41 | #### Defined in 42 | 43 | [packages/qllm-lib/src/types/llm-provider.ts:35](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-provider.ts#L35) 44 | 45 | ## Properties 46 | 47 | ### errorCode? 48 | 49 | > `optional` **errorCode**: `string` 50 | 51 | #### Defined in 52 | 53 | [packages/qllm-lib/src/types/llm-provider.ts:35](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-provider.ts#L35) 54 | 55 | --- 56 | 57 | ### providerName 58 | 59 | > **providerName**: `string` 60 | 61 | #### Defined in 62 | 63 | [packages/qllm-lib/src/types/llm-provider.ts:35](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-provider.ts#L35) 64 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/classes/OutputValidationError.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / OutputValidationError 6 | 7 | # Class: OutputValidationError 8 | 9 | ## Extends 10 | 11 | - [`QllmError`](QllmError.md) 12 | 13 | ## Constructors 14 | 15 | ### new OutputValidationError() 16 | 17 | > **new OutputValidationError**(`message`): [`OutputValidationError`](OutputValidationError.md) 18 | 19 | #### Parameters 20 | 21 | • **message**: `string` 22 | 23 | #### Returns 24 | 25 | [`OutputValidationError`](OutputValidationError.md) 26 | 27 | #### Overrides 28 | 29 | [`QllmError`](QllmError.md).[`constructor`](QllmError.md#constructors) 30 | 31 | #### Defined in 32 | 33 | [packages/qllm-lib/src/templates/types.ts:71](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/templates/types.ts#L71) 34 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/classes/ProviderError.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / ProviderError 6 | 7 | # Class: ProviderError 8 | 9 | ## Extends 10 | 11 | - [`QllmError`](QllmError.md) 12 | 13 | ## Constructors 14 | 15 | ### new ProviderError() 16 | 17 | > **new ProviderError**(`message`, `providerName`): [`ProviderError`](ProviderError.md) 18 | 19 | #### Parameters 20 | 21 | • **message**: `string` 22 | 23 | • **providerName**: `string` 24 | 25 | #### Returns 26 | 27 | [`ProviderError`](ProviderError.md) 28 | 29 | #### Overrides 30 | 31 | [`QllmError`](QllmError.md).[`constructor`](QllmError.md#constructors) 32 | 33 | #### Defined in 34 | 35 | [packages/qllm-lib/src/templates/types.ts:44](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/templates/types.ts#L44) 36 | 37 | ## Properties 38 | 39 | ### providerName 40 | 41 | > **providerName**: `string` 42 | 43 | #### Defined in 44 | 45 | [packages/qllm-lib/src/templates/types.ts:46](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/templates/types.ts#L46) 46 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/classes/QllmError.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / QllmError 6 | 7 | # Class: QllmError 8 | 9 | ## Extends 10 | 11 | - `Error` 12 | 13 | ## Extended by 14 | 15 | - [`ConfigurationError`](ConfigurationError.md) 16 | - [`ProviderError`](ProviderError.md) 17 | - [`TemplateError`](TemplateError.md) 18 | - [`InputValidationError`](InputValidationError.md) 19 | - [`OutputValidationError`](OutputValidationError.md) 20 | - [`TemplateManagerError`](TemplateManagerError.md) 21 | 22 | ## Constructors 23 | 24 | ### new QllmError() 25 | 26 | > **new QllmError**(`message`): [`QllmError`](QllmError.md) 27 | 28 | #### Parameters 29 | 30 | • **message**: `string` 31 | 32 | #### Returns 33 | 34 | [`QllmError`](QllmError.md) 35 | 36 | #### Overrides 37 | 38 | `Error.constructor` 39 | 40 | #### Defined in 41 | 42 | [packages/qllm-lib/src/templates/types.ts:28](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/templates/types.ts#L28) 43 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/classes/RateLimitError.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / RateLimitError 6 | 7 | # Class: RateLimitError 8 | 9 | ## Extends 10 | 11 | - [`LLMProviderError`](LLMProviderError.md) 12 | 13 | ## Constructors 14 | 15 | ### new RateLimitError() 16 | 17 | > **new RateLimitError**(`message`, `providerName`, `errorCode`?): [`RateLimitError`](RateLimitError.md) 18 | 19 | #### Parameters 20 | 21 | • **message**: `string` 22 | 23 | • **providerName**: `string` 24 | 25 | • **errorCode?**: `string` 26 | 27 | #### Returns 28 | 29 | [`RateLimitError`](RateLimitError.md) 30 | 31 | #### Inherited from 32 | 33 | [`LLMProviderError`](LLMProviderError.md).[`constructor`](LLMProviderError.md#constructors) 34 | 35 | #### Defined in 36 | 37 | [packages/qllm-lib/src/types/llm-provider.ts:35](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-provider.ts#L35) 38 | 39 | ## Properties 40 | 41 | ### errorCode? 42 | 43 | > `optional` **errorCode**: `string` 44 | 45 | #### Inherited from 46 | 47 | [`LLMProviderError`](LLMProviderError.md).[`errorCode`](LLMProviderError.md#errorcode) 48 | 49 | #### Defined in 50 | 51 | [packages/qllm-lib/src/types/llm-provider.ts:35](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-provider.ts#L35) 52 | 53 | --- 54 | 55 | ### providerName 56 | 57 | > **providerName**: `string` 58 | 59 | #### Inherited from 60 | 61 | [`LLMProviderError`](LLMProviderError.md).[`providerName`](LLMProviderError.md#providername) 62 | 63 | #### Defined in 64 | 65 | [packages/qllm-lib/src/types/llm-provider.ts:35](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-provider.ts#L35) 66 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/classes/TemplateError.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / TemplateError 6 | 7 | # Class: TemplateError 8 | 9 | ## Extends 10 | 11 | - [`QllmError`](QllmError.md) 12 | 13 | ## Constructors 14 | 15 | ### new TemplateError() 16 | 17 | > **new TemplateError**(`message`): [`TemplateError`](TemplateError.md) 18 | 19 | #### Parameters 20 | 21 | • **message**: `string` 22 | 23 | #### Returns 24 | 25 | [`TemplateError`](TemplateError.md) 26 | 27 | #### Overrides 28 | 29 | [`QllmError`](QllmError.md).[`constructor`](QllmError.md#constructors) 30 | 31 | #### Defined in 32 | 33 | [packages/qllm-lib/src/templates/types.ts:55](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/templates/types.ts#L55) 34 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/classes/TemplateManagerError.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / TemplateManagerError 6 | 7 | # Class: TemplateManagerError 8 | 9 | ## Extends 10 | 11 | - [`QllmError`](QllmError.md) 12 | 13 | ## Extended by 14 | 15 | - [`TemplateNotFoundError`](TemplateNotFoundError.md) 16 | - [`InvalidTemplateError`](InvalidTemplateError.md) 17 | - [`FileOperationError`](FileOperationError.md) 18 | 19 | ## Constructors 20 | 21 | ### new TemplateManagerError() 22 | 23 | > **new TemplateManagerError**(`message`): [`TemplateManagerError`](TemplateManagerError.md) 24 | 25 | #### Parameters 26 | 27 | • **message**: `string` 28 | 29 | #### Returns 30 | 31 | [`TemplateManagerError`](TemplateManagerError.md) 32 | 33 | #### Overrides 34 | 35 | [`QllmError`](QllmError.md).[`constructor`](QllmError.md#constructors) 36 | 37 | #### Defined in 38 | 39 | [packages/qllm-lib/src/templates/types.ts:79](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/templates/types.ts#L79) 40 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/classes/TemplateNotFoundError.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / TemplateNotFoundError 6 | 7 | # Class: TemplateNotFoundError 8 | 9 | ## Extends 10 | 11 | - [`TemplateManagerError`](TemplateManagerError.md) 12 | 13 | ## Constructors 14 | 15 | ### new TemplateNotFoundError() 16 | 17 | > **new TemplateNotFoundError**(`templateName`): [`TemplateNotFoundError`](TemplateNotFoundError.md) 18 | 19 | #### Parameters 20 | 21 | • **templateName**: `string` 22 | 23 | #### Returns 24 | 25 | [`TemplateNotFoundError`](TemplateNotFoundError.md) 26 | 27 | #### Overrides 28 | 29 | [`TemplateManagerError`](TemplateManagerError.md).[`constructor`](TemplateManagerError.md#constructors) 30 | 31 | #### Defined in 32 | 33 | [packages/qllm-lib/src/templates/types.ts:87](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/templates/types.ts#L87) 34 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/functions/createConversationManager.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / createConversationManager 6 | 7 | # Function: createConversationManager() 8 | 9 | > **createConversationManager**(`initialStorageProvider`?): [`ConversationManager`](../interfaces/ConversationManager.md) 10 | 11 | ## Parameters 12 | 13 | • **initialStorageProvider?**: [`StorageProvider`](../interfaces/StorageProvider.md) 14 | 15 | ## Returns 16 | 17 | [`ConversationManager`](../interfaces/ConversationManager.md) 18 | 19 | ## Defined in 20 | 21 | [packages/qllm-lib/src/conversation/conversation-manager.ts:16](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/conversation/conversation-manager.ts#L16) 22 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/functions/createEmbeddingProvider.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / createEmbeddingProvider 6 | 7 | # Function: createEmbeddingProvider() 8 | 9 | > **createEmbeddingProvider**(`__namedParameters`): [`EmbeddingProvider`](../interfaces/EmbeddingProvider.md) 10 | 11 | ## Parameters 12 | 13 | • **\_\_namedParameters** 14 | 15 | • **\_\_namedParameters.apiKey?**: `string` 16 | 17 | • **\_\_namedParameters.name**: `string` 18 | 19 | • **\_\_namedParameters.url?**: `string` 20 | 21 | ## Returns 22 | 23 | [`EmbeddingProvider`](../interfaces/EmbeddingProvider.md) 24 | 25 | ## Defined in 26 | 27 | [packages/qllm-lib/src/index.ts:49](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/index.ts#L49) 28 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/functions/createFunctionToolFromZod.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / createFunctionToolFromZod 6 | 7 | # Function: createFunctionToolFromZod() 8 | 9 | > **createFunctionToolFromZod**(`config`): [`FunctionTool`](../type-aliases/FunctionTool.md) 10 | 11 | ## Parameters 12 | 13 | • **config**: [`FunctionToolConfig`](../type-aliases/FunctionToolConfig.md) 14 | 15 | ## Returns 16 | 17 | [`FunctionTool`](../type-aliases/FunctionTool.md) 18 | 19 | ## Defined in 20 | 21 | [packages/qllm-lib/src/utils/functions/index.ts:95](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/utils/functions/index.ts#L95) 22 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/functions/createLLMProvider.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / createLLMProvider 6 | 7 | # Function: createLLMProvider() 8 | 9 | > **createLLMProvider**(`__namedParameters`): [`LLMProvider`](../interfaces/LLMProvider.md) 10 | 11 | ## Parameters 12 | 13 | • **\_\_namedParameters** 14 | 15 | • **\_\_namedParameters.apiKey?**: `string` 16 | 17 | • **\_\_namedParameters.name**: `string` 18 | 19 | • **\_\_namedParameters.url?**: `string` 20 | 21 | ## Returns 22 | 23 | [`LLMProvider`](../interfaces/LLMProvider.md) 24 | 25 | ## Defined in 26 | 27 | [packages/qllm-lib/src/index.ts:26](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/index.ts#L26) 28 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/functions/createOutputVariable.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / createOutputVariable 6 | 7 | # Function: createOutputVariable() 8 | 9 | > **createOutputVariable**(`type`, `options`): [`OutputVariable`](../type-aliases/OutputVariable.md) 10 | 11 | ## Parameters 12 | 13 | • **type**: `"string"` \| `"boolean"` \| `"object"` \| `"integer"` \| `"float"` \| `"array"` 14 | 15 | • **options**: `Partial`\<`Omit`\<`object`, `"type"`\>\> = `{}` 16 | 17 | ## Returns 18 | 19 | [`OutputVariable`](../type-aliases/OutputVariable.md) 20 | 21 | ## Defined in 22 | 23 | [packages/qllm-lib/src/templates/template-definition-builder.ts:369](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/templates/template-definition-builder.ts#L369) 24 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/functions/createTemplateVariable.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / createTemplateVariable 6 | 7 | # Function: createTemplateVariable() 8 | 9 | > **createTemplateVariable**(`type`, `description`, `options`): [`TemplateVariable`](../type-aliases/TemplateVariable.md) 10 | 11 | ## Parameters 12 | 13 | • **type**: `"string"` \| `"number"` \| `"boolean"` \| `"array"` 14 | 15 | • **description**: `string` 16 | 17 | • **options**: `Partial`\<`Omit`\<`object`, `"type"` \| `"description"`\>\> = `{}` 18 | 19 | ## Returns 20 | 21 | [`TemplateVariable`](../type-aliases/TemplateVariable.md) 22 | 23 | ## Defined in 24 | 25 | [packages/qllm-lib/src/templates/template-definition-builder.ts:361](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/templates/template-definition-builder.ts#L361) 26 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/functions/createTextMessageContent.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / createTextMessageContent 6 | 7 | # Function: createTextMessageContent() 8 | 9 | > **createTextMessageContent**(`content`): [`ChatMessageContent`](../type-aliases/ChatMessageContent.md) 10 | 11 | ## Parameters 12 | 13 | • **content**: `string` \| `string`[] 14 | 15 | ## Returns 16 | 17 | [`ChatMessageContent`](../type-aliases/ChatMessageContent.md) 18 | 19 | ## Defined in 20 | 21 | [packages/qllm-lib/src/utils/images/index.ts:5](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/utils/images/index.ts#L5) 22 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/functions/generatePromptFromTemplate.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / generatePromptFromTemplate 6 | 7 | # Function: generatePromptFromTemplate() 8 | 9 | > **generatePromptFromTemplate**(`template`, `inputs`): `string` 10 | 11 | ## Parameters 12 | 13 | • **template** 14 | 15 | • **template.author**: `string` = `...` 16 | 17 | • **template.categories?**: `string`[] = `...` 18 | 19 | • **template.content**: `string` = `...` 20 | 21 | • **template.description**: `string` = `...` 22 | 23 | • **template.example_outputs?**: `string`[] = `...` 24 | 25 | • **template.input_variables?**: `Record`\<`string`, `object`\> = `...` 26 | 27 | • **template.model?**: `string` = `...` 28 | 29 | • **template.name**: `string` = `...` 30 | 31 | • **template.output_variables?**: `Record`\<`string`, `object`\> = `...` 32 | 33 | • **template.parameters?** = `...` 34 | 35 | • **template.parameters.max_tokens?**: `number` = `...` 36 | 37 | • **template.parameters.temperature?**: `number` = `...` 38 | 39 | • **template.parameters.top_k?**: `number` = `...` 40 | 41 | • **template.parameters.top_p?**: `number` = `...` 42 | 43 | • **template.prompt_type?**: `string` = `...` 44 | 45 | • **template.provider?**: `string` = `...` 46 | 47 | • **template.tags?**: `string`[] = `...` 48 | 49 | • **template.task_description?**: `string` = `...` 50 | 51 | • **template.version**: `string` = `...` 52 | 53 | • **inputs**: `Record`\<`string`, `any`\> 54 | 55 | ## Returns 56 | 57 | `string` 58 | 59 | ## Defined in 60 | 61 | [packages/qllm-lib/src/templates/template-definition-builder.ts:377](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/templates/template-definition-builder.ts#L377) 62 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/functions/getEmbeddingProvider.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / getEmbeddingProvider 6 | 7 | # Function: getEmbeddingProvider() 8 | 9 | > **getEmbeddingProvider**(`providerName`): `Promise`\<[`EmbeddingProvider`](../interfaces/EmbeddingProvider.md)\> 10 | 11 | ## Parameters 12 | 13 | • **providerName**: `string` 14 | 15 | ## Returns 16 | 17 | `Promise`\<[`EmbeddingProvider`](../interfaces/EmbeddingProvider.md)\> 18 | 19 | ## Defined in 20 | 21 | [packages/qllm-lib/src/providers/index.ts:32](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/providers/index.ts#L32) 22 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/functions/getLLMProvider.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / getLLMProvider 6 | 7 | # Function: getLLMProvider() 8 | 9 | > **getLLMProvider**(`providerName`): `Promise`\<[`LLMProvider`](../interfaces/LLMProvider.md)\> 10 | 11 | ## Parameters 12 | 13 | • **providerName**: `string` 14 | 15 | ## Returns 16 | 17 | `Promise`\<[`LLMProvider`](../interfaces/LLMProvider.md)\> 18 | 19 | ## Defined in 20 | 21 | [packages/qllm-lib/src/providers/index.ts:14](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/providers/index.ts#L14) 22 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/functions/getListProviderNames.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / getListProviderNames 6 | 7 | # Function: getListProviderNames() 8 | 9 | > **getListProviderNames**(): `string`[] 10 | 11 | ## Returns 12 | 13 | `string`[] 14 | 15 | ## Defined in 16 | 17 | [packages/qllm-lib/src/providers/index.ts:9](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/providers/index.ts#L9) 18 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/functions/imageToBase64.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / imageToBase64 6 | 7 | # Function: imageToBase64() 8 | 9 | > **imageToBase64**(`source`): `Promise`\<`ImageToBase64Output`\> 10 | 11 | Converts an image to a base64-encoded string or returns the input if it's already base64-encoded. 12 | 13 | ## Parameters 14 | 15 | • **source**: `string` 16 | 17 | The URL, file path, or base64-encoded string of the image. 18 | 19 | ## Returns 20 | 21 | `Promise`\<`ImageToBase64Output`\> 22 | 23 | A Promise that resolves to the base64-encoded string of the image. 24 | 25 | ## Defined in 26 | 27 | [packages/qllm-lib/src/utils/images/image-to-base64.ts:29](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/utils/images/image-to-base64.ts#L29) 28 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/functions/isImageUrlContent.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / isImageUrlContent 6 | 7 | # Function: isImageUrlContent() 8 | 9 | > **isImageUrlContent**(`content`): `content is ImageUrlContent` 10 | 11 | ## Parameters 12 | 13 | • **content**: [`MessageContent`](../type-aliases/MessageContent.md) 14 | 15 | ## Returns 16 | 17 | `content is ImageUrlContent` 18 | 19 | ## Defined in 20 | 21 | [packages/qllm-lib/src/types/llm-types.ts:40](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L40) 22 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/functions/isTextContent.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / isTextContent 6 | 7 | # Function: isTextContent() 8 | 9 | > **isTextContent**(`content`): `content is TextContent` 10 | 11 | ## Parameters 12 | 13 | • **content**: [`MessageContent`](../type-aliases/MessageContent.md) 14 | 15 | ## Returns 16 | 17 | `content is TextContent` 18 | 19 | ## Defined in 20 | 21 | [packages/qllm-lib/src/types/llm-types.ts:36](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L36) 22 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/interfaces/AIProvider.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / AIProvider 6 | 7 | # Interface: AIProvider 8 | 9 | ## Extended by 10 | 11 | - [`LLMProvider`](LLMProvider.md) 12 | - [`EmbeddingProvider`](EmbeddingProvider.md) 13 | 14 | ## Properties 15 | 16 | ### name 17 | 18 | > `readonly` **name**: `string` 19 | 20 | #### Defined in 21 | 22 | [packages/qllm-lib/src/types/llm-provider.ts:14](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-provider.ts#L14) 23 | 24 | --- 25 | 26 | ### version 27 | 28 | > `readonly` **version**: `string` 29 | 30 | #### Defined in 31 | 32 | [packages/qllm-lib/src/types/llm-provider.ts:15](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-provider.ts#L15) 33 | 34 | ## Methods 35 | 36 | ### listModels() 37 | 38 | > **listModels**(): `Promise`\<[`Model`](../type-aliases/Model.md)[]\> 39 | 40 | #### Returns 41 | 42 | `Promise`\<[`Model`](../type-aliases/Model.md)[]\> 43 | 44 | #### Defined in 45 | 46 | [packages/qllm-lib/src/types/llm-provider.ts:16](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-provider.ts#L16) 47 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/interfaces/Conversation.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / Conversation 6 | 7 | # Interface: Conversation 8 | 9 | ## Properties 10 | 11 | ### activeProviders 12 | 13 | > **activeProviders**: `Set`\<`string`\> 14 | 15 | #### Defined in 16 | 17 | [packages/qllm-lib/src/types/conversations-types.ts:28](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/conversations-types.ts#L28) 18 | 19 | --- 20 | 21 | ### id 22 | 23 | > **id**: `string` 24 | 25 | #### Defined in 26 | 27 | [packages/qllm-lib/src/types/conversations-types.ts:25](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/conversations-types.ts#L25) 28 | 29 | --- 30 | 31 | ### messages 32 | 33 | > **messages**: [`ConversationMessage`](ConversationMessage.md)[] 34 | 35 | #### Defined in 36 | 37 | [packages/qllm-lib/src/types/conversations-types.ts:26](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/conversations-types.ts#L26) 38 | 39 | --- 40 | 41 | ### metadata 42 | 43 | > **metadata**: [`ConversationMetadata`](ConversationMetadata.md) 44 | 45 | #### Defined in 46 | 47 | [packages/qllm-lib/src/types/conversations-types.ts:27](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/conversations-types.ts#L27) 48 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/interfaces/ConversationMetadata.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / ConversationMetadata 6 | 7 | # Interface: ConversationMetadata 8 | 9 | ## Indexable 10 | 11 | \[`key`: `string`\]: `any` 12 | 13 | ## Properties 14 | 15 | ### createdAt 16 | 17 | > **createdAt**: `Date` 18 | 19 | #### Defined in 20 | 21 | [packages/qllm-lib/src/types/conversations-types.ts:9](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/conversations-types.ts#L9) 22 | 23 | --- 24 | 25 | ### description? 26 | 27 | > `optional` **description**: `string` 28 | 29 | #### Defined in 30 | 31 | [packages/qllm-lib/src/types/conversations-types.ts:12](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/conversations-types.ts#L12) 32 | 33 | --- 34 | 35 | ### title? 36 | 37 | > `optional` **title**: `string` 38 | 39 | #### Defined in 40 | 41 | [packages/qllm-lib/src/types/conversations-types.ts:11](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/conversations-types.ts#L11) 42 | 43 | --- 44 | 45 | ### updatedAt 46 | 47 | > **updatedAt**: `Date` 48 | 49 | #### Defined in 50 | 51 | [packages/qllm-lib/src/types/conversations-types.ts:10](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/conversations-types.ts#L10) 52 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/interfaces/CreateConversationOptions.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / CreateConversationOptions 6 | 7 | # Interface: CreateConversationOptions 8 | 9 | ## Properties 10 | 11 | ### initialMessage? 12 | 13 | > `optional` **initialMessage**: `string` 14 | 15 | #### Defined in 16 | 17 | [packages/qllm-lib/src/types/conversations-types.ts:68](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/conversations-types.ts#L68) 18 | 19 | --- 20 | 21 | ### metadata? 22 | 23 | > `optional` **metadata**: `Partial`\<[`ConversationMetadata`](ConversationMetadata.md)\> 24 | 25 | #### Defined in 26 | 27 | [packages/qllm-lib/src/types/conversations-types.ts:69](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/conversations-types.ts#L69) 28 | 29 | --- 30 | 31 | ### providerIds? 32 | 33 | > `optional` **providerIds**: `string`[] 34 | 35 | #### Defined in 36 | 37 | [packages/qllm-lib/src/types/conversations-types.ts:70](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/conversations-types.ts#L70) 38 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/interfaces/EnvironmentOptions.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / EnvironmentOptions 6 | 7 | # Interface: EnvironmentOptions 8 | 9 | ## Extended by 10 | 11 | - [`LLMOptions`](LLMOptions.md) 12 | 13 | ## Properties 14 | 15 | ### awsProfile? 16 | 17 | > `optional` **awsProfile**: `string` 18 | 19 | #### Defined in 20 | 21 | [packages/qllm-lib/src/types/llm-types.ts:115](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L115) 22 | 23 | --- 24 | 25 | ### awsRegion? 26 | 27 | > `optional` **awsRegion**: `string` 28 | 29 | #### Defined in 30 | 31 | [packages/qllm-lib/src/types/llm-types.ts:114](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L114) 32 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/interfaces/ErrorResponse.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / ErrorResponse 6 | 7 | # Interface: ErrorResponse 8 | 9 | ## Properties 10 | 11 | ### code 12 | 13 | > **code**: `string` 14 | 15 | #### Defined in 16 | 17 | [packages/qllm-lib/src/types/llm-types.ts:246](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L246) 18 | 19 | --- 20 | 21 | ### details? 22 | 23 | > `optional` **details**: `string` 24 | 25 | #### Defined in 26 | 27 | [packages/qllm-lib/src/types/llm-types.ts:248](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L248) 28 | 29 | --- 30 | 31 | ### message 32 | 33 | > **message**: `string` 34 | 35 | #### Defined in 36 | 37 | [packages/qllm-lib/src/types/llm-types.ts:247](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L247) 38 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/interfaces/ModelOptions.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / ModelOptions 6 | 7 | # Interface: ModelOptions 8 | 9 | ## Extended by 10 | 11 | - [`LLMOptions`](LLMOptions.md) 12 | 13 | ## Properties 14 | 15 | ### model 16 | 17 | > **model**: `string` 18 | 19 | #### Defined in 20 | 21 | [packages/qllm-lib/src/types/llm-types.ts:110](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L110) 22 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/interfaces/TemplateManagerConfig.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / TemplateManagerConfig 6 | 7 | # Interface: TemplateManagerConfig 8 | 9 | ## Properties 10 | 11 | ### promptDirectory 12 | 13 | > **promptDirectory**: `string` 14 | 15 | #### Defined in 16 | 17 | [packages/qllm-lib/src/templates/template-manager.ts:11](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/templates/template-manager.ts#L11) 18 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/type-aliases/ChatCompletionParams.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / ChatCompletionParams 6 | 7 | # Type Alias: ChatCompletionParams 8 | 9 | > **ChatCompletionParams**: `object` 10 | 11 | ## Type declaration 12 | 13 | ### messages 14 | 15 | > **messages**: [`ChatMessage`](ChatMessage.md)[] 16 | 17 | ### options 18 | 19 | > **options**: [`LLMOptions`](../interfaces/LLMOptions.md) 20 | 21 | ### parallelToolCalls? 22 | 23 | > `optional` **parallelToolCalls**: `boolean` 24 | 25 | ### responseFormat? 26 | 27 | > `optional` **responseFormat**: [`ResponseFormat`](ResponseFormat.md) 28 | 29 | ### toolChoice? 30 | 31 | > `optional` **toolChoice**: `"none"` \| `"auto"` \| `"required"` 32 | 33 | ### tools? 34 | 35 | > `optional` **tools**: [`Tool`](Tool.md)[] 36 | 37 | ## Defined in 38 | 39 | [packages/qllm-lib/src/types/llm-types.ts:259](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L259) 40 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/type-aliases/ChatCompletionResponse.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / ChatCompletionResponse 6 | 7 | # Type Alias: ChatCompletionResponse 8 | 9 | > **ChatCompletionResponse**: `object` 10 | 11 | ## Type declaration 12 | 13 | ### finishReason 14 | 15 | > **finishReason**: `string` \| `null` 16 | 17 | ### model 18 | 19 | > **model**: `string` 20 | 21 | ### refusal 22 | 23 | > **refusal**: `string` \| `null` 24 | 25 | ### text 26 | 27 | > **text**: `string` \| `null` 28 | 29 | ### toolCalls? 30 | 31 | > `optional` **toolCalls**: [`ToolCall`](ToolCall.md)[] 32 | 33 | ### usage? 34 | 35 | > `optional` **usage**: [`Usage`](Usage.md) 36 | 37 | ## Defined in 38 | 39 | [packages/qllm-lib/src/types/llm-types.ts:52](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L52) 40 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/type-aliases/ChatMessage.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / ChatMessage 6 | 7 | # Type Alias: ChatMessage 8 | 9 | > **ChatMessage**: `object` 10 | 11 | ## Type declaration 12 | 13 | ### content 14 | 15 | > **content**: [`ChatMessageContent`](ChatMessageContent.md) 16 | 17 | ### role 18 | 19 | > **role**: [`ChatMessageRole`](ChatMessageRole.md) 20 | 21 | ## Defined in 22 | 23 | [packages/qllm-lib/src/types/llm-types.ts:23](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L23) 24 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/type-aliases/ChatMessageContent.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / ChatMessageContent 6 | 7 | # Type Alias: ChatMessageContent 8 | 9 | > **ChatMessageContent**: [`MessageContent`](MessageContent.md) \| [`MessageContent`](MessageContent.md)[] 10 | 11 | ## Defined in 12 | 13 | [packages/qllm-lib/src/types/llm-types.ts:21](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L21) 14 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/type-aliases/ChatMessageContentType.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / ChatMessageContentType 6 | 7 | # Type Alias: ChatMessageContentType 8 | 9 | > **ChatMessageContentType**: `"text"` \| `"image_url"` 10 | 11 | ## Defined in 12 | 13 | [packages/qllm-lib/src/types/llm-types.ts:8](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L8) 14 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/type-aliases/ChatMessageRole.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / ChatMessageRole 6 | 7 | # Type Alias: ChatMessageRole 8 | 9 | > **ChatMessageRole**: `"user"` \| `"assistant"` 10 | 11 | ## Defined in 12 | 13 | [packages/qllm-lib/src/types/llm-types.ts:7](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L7) 14 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/type-aliases/ChatMessageWithSystem.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / ChatMessageWithSystem 6 | 7 | # Type Alias: ChatMessageWithSystem 8 | 9 | > **ChatMessageWithSystem**: [`ChatMessage`](ChatMessage.md) \| [`SystemMessage`](SystemMessage.md) 10 | 11 | ## Defined in 12 | 13 | [packages/qllm-lib/src/types/llm-types.ts:33](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L33) 14 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/type-aliases/ChatStreamCompletionResponse.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / ChatStreamCompletionResponse 6 | 7 | # Type Alias: ChatStreamCompletionResponse 8 | 9 | > **ChatStreamCompletionResponse**: `object` 10 | 11 | ## Type declaration 12 | 13 | ### finishReason 14 | 15 | > **finishReason**: `string` \| `null` 16 | 17 | ### model 18 | 19 | > **model**: `string` 20 | 21 | ### text 22 | 23 | > **text**: `string` \| `null` 24 | 25 | ## Defined in 26 | 27 | [packages/qllm-lib/src/types/llm-types.ts:61](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L61) 28 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/type-aliases/ConversationId.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / ConversationId 6 | 7 | # Type Alias: ConversationId 8 | 9 | > **ConversationId**: `string` 10 | 11 | ## Defined in 12 | 13 | [packages/qllm-lib/src/types/conversations-types.ts:5](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/conversations-types.ts#L5) 14 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/type-aliases/Embedding.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / Embedding 6 | 7 | # Type Alias: Embedding 8 | 9 | > **Embedding**: `number`[] 10 | 11 | ## Defined in 12 | 13 | [packages/qllm-lib/src/types/llm-types.ts:75](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L75) 14 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/type-aliases/EmbeddingRequestParams.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / EmbeddingRequestParams 6 | 7 | # Type Alias: EmbeddingRequestParams 8 | 9 | > **EmbeddingRequestParams**: `object` 10 | 11 | ## Type declaration 12 | 13 | ### content 14 | 15 | > **content**: `string` \| `string`[] \| `number`[] \| `number`[][] 16 | 17 | ### dimensions? 18 | 19 | > `optional` **dimensions**: `number` 20 | 21 | ### model 22 | 23 | > **model**: `string` 24 | 25 | ## Defined in 26 | 27 | [packages/qllm-lib/src/types/llm-types.ts:69](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L69) 28 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/type-aliases/EmbeddingResponse.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / EmbeddingResponse 6 | 7 | # Type Alias: EmbeddingResponse 8 | 9 | > **EmbeddingResponse**: `object` 10 | 11 | ## Type declaration 12 | 13 | ### embedding 14 | 15 | > **embedding**: [`Embedding`](Embedding.md) 16 | 17 | ### embeddings? 18 | 19 | > `optional` **embeddings**: [`Embedding`](Embedding.md)[] 20 | 21 | ## Defined in 22 | 23 | [packages/qllm-lib/src/types/llm-types.ts:77](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L77) 24 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/type-aliases/FunctionTool.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / FunctionTool 6 | 7 | # Type Alias: FunctionTool 8 | 9 | > **FunctionTool**: `z.infer`\<_typeof_ `FunctionToolSchema`\> 10 | 11 | ## Defined in 12 | 13 | [packages/qllm-lib/src/types/llm-types.ts:201](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L201) 14 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/type-aliases/FunctionToolConfig.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / FunctionToolConfig 6 | 7 | # Type Alias: FunctionToolConfig 8 | 9 | > **FunctionToolConfig**: `object` 10 | 11 | ## Type declaration 12 | 13 | ### description 14 | 15 | > **description**: `string` 16 | 17 | ### name 18 | 19 | > **name**: `string` 20 | 21 | ### schema 22 | 23 | > **schema**: `z.ZodObject`\<`z.ZodRawShape`\> 24 | 25 | ### strict? 26 | 27 | > `optional` **strict**: `boolean` 28 | 29 | ## Defined in 30 | 31 | [packages/qllm-lib/src/utils/functions/index.ts:88](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/utils/functions/index.ts#L88) 32 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/type-aliases/ImageUrlContent.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / ImageUrlContent 6 | 7 | # Type Alias: ImageUrlContent 8 | 9 | > **ImageUrlContent**: `object` 10 | 11 | ## Type declaration 12 | 13 | ### type 14 | 15 | > **type**: `"image_url"` 16 | 17 | ### url 18 | 19 | > **url**: `string` 20 | 21 | ## Defined in 22 | 23 | [packages/qllm-lib/src/types/llm-types.ts:15](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L15) 24 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/type-aliases/MessageContent.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / MessageContent 6 | 7 | # Type Alias: MessageContent 8 | 9 | > **MessageContent**: [`TextContent`](TextContent.md) \| [`ImageUrlContent`](ImageUrlContent.md) 10 | 11 | ## Defined in 12 | 13 | [packages/qllm-lib/src/types/llm-types.ts:20](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L20) 14 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/type-aliases/Model.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / Model 6 | 7 | # Type Alias: Model 8 | 9 | > **Model**: `object` 10 | 11 | ## Type declaration 12 | 13 | ### created? 14 | 15 | > `optional` **created**: `Date` 16 | 17 | ### description? 18 | 19 | > `optional` **description**: `string` 20 | 21 | ### id 22 | 23 | > **id**: `string` 24 | 25 | ## Defined in 26 | 27 | [packages/qllm-lib/src/types/llm-types.ts:251](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L251) 28 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/type-aliases/OutputVariable.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / OutputVariable 6 | 7 | # Type Alias: OutputVariable 8 | 9 | > **OutputVariable**: `z.infer`\<_typeof_ [`outputVariableSchema`](../variables/outputVariableSchema.md)\> 10 | 11 | ## Defined in 12 | 13 | [packages/qllm-lib/src/templates/template-schema.ts:101](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/templates/template-schema.ts#L101) 14 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/type-aliases/ProviderId.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / ProviderId 6 | 7 | # Type Alias: ProviderId 8 | 9 | > **ProviderId**: `string` 10 | 11 | ## Defined in 12 | 13 | [packages/qllm-lib/src/types/conversations-types.ts:6](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/conversations-types.ts#L6) 14 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/type-aliases/ResponseFormat.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / ResponseFormat 6 | 7 | # Type Alias: ResponseFormat 8 | 9 | > **ResponseFormat**: [`ResponseFormatText`](ResponseFormatText.md) \| [`ResponseFormatJSONObject`](ResponseFormatJSONObject.md) \| [`ResponseFormatJSONSchema`](ResponseFormatJSONSchema.md) 10 | 11 | ## Defined in 12 | 13 | [packages/qllm-lib/src/types/llm-types.ts:240](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L240) 14 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/type-aliases/ResponseFormatJSONObject.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / ResponseFormatJSONObject 6 | 7 | # Type Alias: ResponseFormatJSONObject 8 | 9 | > **ResponseFormatJSONObject**: `object` 10 | 11 | ## Type declaration 12 | 13 | ### type 14 | 15 | > **type**: `"json_object"` 16 | 17 | ## Defined in 18 | 19 | [packages/qllm-lib/src/types/llm-types.ts:226](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L226) 20 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/type-aliases/ResponseFormatJSONSchema.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / ResponseFormatJSONSchema 6 | 7 | # Type Alias: ResponseFormatJSONSchema 8 | 9 | > **ResponseFormatJSONSchema**: `object` 10 | 11 | ## Type declaration 12 | 13 | ### json_schema 14 | 15 | > **json_schema**: `object` 16 | 17 | ### json_schema.description? 18 | 19 | > `optional` **description**: `string` 20 | 21 | ### json_schema.name 22 | 23 | > **name**: `string` 24 | 25 | ### json_schema.schema 26 | 27 | > **schema**: `Record`\<`string`, `unknown`\> 28 | 29 | ### json_schema.strict? 30 | 31 | > `optional` **strict**: `boolean` 32 | 33 | ### type 34 | 35 | > **type**: `"json_schema"` 36 | 37 | ## Defined in 38 | 39 | [packages/qllm-lib/src/types/llm-types.ts:230](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L230) 40 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/type-aliases/ResponseFormatText.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / ResponseFormatText 6 | 7 | # Type Alias: ResponseFormatText 8 | 9 | > **ResponseFormatText**: `object` 10 | 11 | ## Type declaration 12 | 13 | ### type 14 | 15 | > **type**: `"text"` 16 | 17 | ## Defined in 18 | 19 | [packages/qllm-lib/src/types/llm-types.ts:222](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L222) 20 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/type-aliases/SystemMessage.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / SystemMessage 6 | 7 | # Type Alias: SystemMessage 8 | 9 | > **SystemMessage**: `object` 10 | 11 | ## Type declaration 12 | 13 | ### content 14 | 15 | > **content**: [`TextContent`](TextContent.md) 16 | 17 | ### role 18 | 19 | > **role**: `"system"` 20 | 21 | ## Defined in 22 | 23 | [packages/qllm-lib/src/types/llm-types.ts:28](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L28) 24 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/type-aliases/TemplateDefinition.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / TemplateDefinition 6 | 7 | # Type Alias: TemplateDefinition 8 | 9 | > **TemplateDefinition**: `z.infer`\<_typeof_ [`templateDefinitionSchema`](../variables/templateDefinitionSchema.md)\> 10 | 11 | ## Defined in 12 | 13 | [packages/qllm-lib/src/templates/template-schema.ts:96](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/templates/template-schema.ts#L96) 14 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/type-aliases/TemplateDefinitionWithResolvedContent.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / TemplateDefinitionWithResolvedContent 6 | 7 | # Type Alias: TemplateDefinitionWithResolvedContent 8 | 9 | > **TemplateDefinitionWithResolvedContent**: `z.infer`\<_typeof_ [`templateDefinitionSchemaWithResolvedContent`](../variables/templateDefinitionSchemaWithResolvedContent.md)\> 10 | 11 | ## Defined in 12 | 13 | [packages/qllm-lib/src/templates/template-schema.ts:97](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/templates/template-schema.ts#L97) 14 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/type-aliases/TemplateVariable.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / TemplateVariable 6 | 7 | # Type Alias: TemplateVariable 8 | 9 | > **TemplateVariable**: `z.infer`\<_typeof_ [`templateVariableSchema`](../variables/templateVariableSchema.md)\> 10 | 11 | ## Defined in 12 | 13 | [packages/qllm-lib/src/templates/template-schema.ts:100](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/templates/template-schema.ts#L100) 14 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/type-aliases/TextContent.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / TextContent 6 | 7 | # Type Alias: TextContent 8 | 9 | > **TextContent**: `object` 10 | 11 | ## Type declaration 12 | 13 | ### text 14 | 15 | > **text**: `string` 16 | 17 | ### type 18 | 19 | > **type**: `"text"` 20 | 21 | ## Defined in 22 | 23 | [packages/qllm-lib/src/types/llm-types.ts:10](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L10) 24 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/type-aliases/Tool.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / Tool 6 | 7 | # Type Alias: Tool 8 | 9 | > **Tool**: `z.infer`\<_typeof_ `ToolSchema`\> 10 | 11 | ## Defined in 12 | 13 | [packages/qllm-lib/src/types/llm-types.ts:202](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L202) 14 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/type-aliases/ToolCall.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / ToolCall 6 | 7 | # Type Alias: ToolCall 8 | 9 | > **ToolCall**: `object` 10 | 11 | ## Type declaration 12 | 13 | ### function 14 | 15 | > **function**: [`ToolCallFunction`](ToolCallFunction.md) 16 | 17 | ### id 18 | 19 | > **id**: `string` 20 | 21 | ### type 22 | 23 | > **type**: `"function"` 24 | 25 | ## Defined in 26 | 27 | [packages/qllm-lib/src/types/llm-types.ts:214](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L214) 28 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/type-aliases/ToolCallFunction.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / ToolCallFunction 6 | 7 | # Type Alias: ToolCallFunction 8 | 9 | > **ToolCallFunction**: `object` 10 | 11 | ## Type declaration 12 | 13 | ### arguments 14 | 15 | > **arguments**: `string` 16 | 17 | ### name 18 | 19 | > **name**: `string` 20 | 21 | ## Defined in 22 | 23 | [packages/qllm-lib/src/types/llm-types.ts:209](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L209) 24 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/type-aliases/ToolChoiceFunction.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / ToolChoiceFunction 6 | 7 | # Type Alias: ToolChoiceFunction 8 | 9 | > **ToolChoiceFunction**: `object` 10 | 11 | ## Type declaration 12 | 13 | ### name 14 | 15 | > **name**: `string` 16 | 17 | ### type 18 | 19 | > **type**: `"function"` 20 | 21 | ## Defined in 22 | 23 | [packages/qllm-lib/src/types/llm-types.ts:204](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L204) 24 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/type-aliases/Usage.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / Usage 6 | 7 | # Type Alias: Usage 8 | 9 | > **Usage**: `object` 10 | 11 | ## Type declaration 12 | 13 | ### completionTokens 14 | 15 | > **completionTokens**: `number` 16 | 17 | ### promptTokens 18 | 19 | > **promptTokens**: `number` 20 | 21 | ### totalTokens 22 | 23 | > **totalTokens**: `number` 24 | 25 | ## Defined in 26 | 27 | [packages/qllm-lib/src/types/llm-types.ts:46](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/types/llm-types.ts#L46) 28 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/variables/default.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / default 6 | 7 | # Variable: default 8 | 9 | > **default**: `object` 10 | 11 | ## Type declaration 12 | 13 | ### TemplateManager 14 | 15 | > **TemplateManager**: _typeof_ [`TemplateManager`](../classes/TemplateManager.md) 16 | 17 | ### createEmbeddingProvider() 18 | 19 | > **createEmbeddingProvider**: (`__namedParameters`) => [`EmbeddingProvider`](../interfaces/EmbeddingProvider.md) 20 | 21 | #### Parameters 22 | 23 | • **\_\_namedParameters** 24 | 25 | • **\_\_namedParameters.apiKey?**: `string` 26 | 27 | • **\_\_namedParameters.name**: `string` 28 | 29 | • **\_\_namedParameters.url?**: `string` 30 | 31 | #### Returns 32 | 33 | [`EmbeddingProvider`](../interfaces/EmbeddingProvider.md) 34 | 35 | ### createLLMProvider() 36 | 37 | > **createLLMProvider**: (`__namedParameters`) => [`LLMProvider`](../interfaces/LLMProvider.md) 38 | 39 | #### Parameters 40 | 41 | • **\_\_namedParameters** 42 | 43 | • **\_\_namedParameters.apiKey?**: `string` 44 | 45 | • **\_\_namedParameters.name**: `string` 46 | 47 | • **\_\_namedParameters.url?**: `string` 48 | 49 | #### Returns 50 | 51 | [`LLMProvider`](../interfaces/LLMProvider.md) 52 | 53 | ## Defined in 54 | 55 | [packages/qllm-lib/src/index.ts:88](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/index.ts#L88) 56 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/variables/logger.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / logger 6 | 7 | # Variable: logger 8 | 9 | > `const` **logger**: `Logger` 10 | 11 | ## Defined in 12 | 13 | [packages/qllm-lib/src/utils/logger/index.ts:79](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/utils/logger/index.ts#L79) 14 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/variables/outputVariableSchema.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / outputVariableSchema 6 | 7 | # Variable: outputVariableSchema 8 | 9 | > `const` **outputVariableSchema**: `ZodObject`\<`object`, `"strip"`, `ZodTypeAny`, `object`, `object`\> 10 | 11 | ## Type declaration 12 | 13 | ### default 14 | 15 | > **default**: `ZodOptional`\<`ZodAny`\> 16 | 17 | ### description 18 | 19 | > **description**: `ZodOptional`\<`ZodString`\> 20 | 21 | ### type 22 | 23 | > **type**: `ZodEnum`\<[`"string"`, `"integer"`, `"float"`, `"boolean"`, `"array"`, `"object"`]\> 24 | 25 | ## Defined in 26 | 27 | [packages/qllm-lib/src/templates/template-schema.ts:24](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/templates/template-schema.ts#L24) 28 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/variables/templateDefinitionSchema.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / templateDefinitionSchema 6 | 7 | # Variable: templateDefinitionSchema 8 | 9 | > `const` **templateDefinitionSchema**: `ZodObject`\<`object`, `"strip"`, `ZodTypeAny`, `object`, `object`\> 10 | 11 | ## Type declaration 12 | 13 | ### author 14 | 15 | > **author**: `ZodString` 16 | 17 | ### categories 18 | 19 | > **categories**: `ZodOptional`\<`ZodArray`\<`ZodString`, `"many"`\>\> 20 | 21 | ### content 22 | 23 | > **content**: `ZodString` 24 | 25 | ### description 26 | 27 | > **description**: `ZodString` 28 | 29 | ### example_outputs 30 | 31 | > **example_outputs**: `ZodOptional`\<`ZodArray`\<`ZodString`, `"many"`\>\> 32 | 33 | ### input_variables 34 | 35 | > **input_variables**: `ZodOptional`\<`ZodRecord`\<`ZodString`, `ZodObject`\<`object`, `"strip"`, `ZodTypeAny`, `object`, `object`\>\>\> 36 | 37 | ### model 38 | 39 | > **model**: `ZodOptional`\<`ZodString`\> 40 | 41 | ### name 42 | 43 | > **name**: `ZodString` 44 | 45 | ### output_variables 46 | 47 | > **output_variables**: `ZodOptional`\<`ZodRecord`\<`ZodString`, `ZodObject`\<`object`, `"strip"`, `ZodTypeAny`, `object`, `object`\>\>\> 48 | 49 | ### parameters 50 | 51 | > **parameters**: `ZodOptional`\<`ZodObject`\<`object`, `"strip"`, `ZodTypeAny`, `object`, `object`\>\> 52 | 53 | ### prompt_type 54 | 55 | > **prompt_type**: `ZodOptional`\<`ZodString`\> 56 | 57 | ### provider 58 | 59 | > **provider**: `ZodOptional`\<`ZodString`\> 60 | 61 | ### tags 62 | 63 | > **tags**: `ZodOptional`\<`ZodArray`\<`ZodString`, `"many"`\>\> 64 | 65 | ### task_description 66 | 67 | > **task_description**: `ZodOptional`\<`ZodString`\> 68 | 69 | ### version 70 | 71 | > **version**: `ZodString` 72 | 73 | ## Defined in 74 | 75 | [packages/qllm-lib/src/templates/template-schema.ts:37](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/templates/template-schema.ts#L37) 76 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/variables/templateDefinitionSchemaWithResolvedContent.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / templateDefinitionSchemaWithResolvedContent 6 | 7 | # Variable: templateDefinitionSchemaWithResolvedContent 8 | 9 | > `const` **templateDefinitionSchemaWithResolvedContent**: `ZodObject`\<`extendShape`\<`object`, `object`\>, `"strip"`, `ZodTypeAny`, `object`, `object`\> 10 | 11 | ## Defined in 12 | 13 | [packages/qllm-lib/src/templates/template-schema.ts:92](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/templates/template-schema.ts#L92) 14 | -------------------------------------------------------------------------------- /packages/qllm-lib/docs/api/qllm-lib/variables/templateVariableSchema.md: -------------------------------------------------------------------------------- 1 | [**QLLM Library API Documentation v3.0.6**](../README.md) • **Docs** 2 | 3 | --- 4 | 5 | [QLLM Library API Documentation v3.0.6](../globals.md) / templateVariableSchema 6 | 7 | # Variable: templateVariableSchema 8 | 9 | > `const` **templateVariableSchema**: `ZodObject`\<`object`, `"strip"`, `ZodTypeAny`, `object`, `object`\> 10 | 11 | ## Type declaration 12 | 13 | ### customValidator 14 | 15 | > **customValidator**: `ZodOptional`\<`ZodFunction`\<`ZodTuple`\<[`ZodAny`], `ZodUnknown`\>, `ZodBoolean`\>\> 16 | 17 | ### default 18 | 19 | > **default**: `ZodOptional`\<`ZodAny`\> 20 | 21 | ### description 22 | 23 | > **description**: `ZodString` 24 | 25 | ### inferred 26 | 27 | > **inferred**: `ZodOptional`\<`ZodBoolean`\> 28 | 29 | ### place_holder 30 | 31 | > **place_holder**: `ZodOptional`\<`ZodAny`\> 32 | 33 | ### type 34 | 35 | > **type**: `ZodEnum`\<[`"string"`, `"number"`, `"boolean"`, `"array"`]\> 36 | 37 | ## Defined in 38 | 39 | [packages/qllm-lib/src/templates/template-schema.ts:3](https://github.com/quantalogic/qllm/blob/b15a3aa4af263bce36ea091a0f29bf1255b95497/packages/qllm-lib/src/templates/template-schema.ts#L3) 40 | -------------------------------------------------------------------------------- /packages/qllm-lib/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | // packages//qllm-lib/eslint.config.jms 2 | // @ts-check 3 | 4 | import tsPlugin from '@typescript-eslint/eslint-plugin'; 5 | import tsParser from '@typescript-eslint/parser'; 6 | 7 | export default [ 8 | { 9 | ignores: ['**/node_modules/**', '**/dist/**'], // Ignore unnecessary files 10 | }, 11 | { 12 | files: ['*.ts', '*.tsx'], // Apply only to TypeScript files 13 | languageOptions: { 14 | parser: tsParser, 15 | parserOptions: { 16 | ecmaVersion: 'latest', 17 | sourceType: 'module', 18 | project: './tsconfig.json', // Ensure this points to your tsconfig.json 19 | tsconfigRootDir: process.cwd(), 20 | }, 21 | }, 22 | plugins: { 23 | '@typescript-eslint': tsPlugin, 24 | }, 25 | rules: { 26 | ...tsPlugin.configs.recommended.rules, // Use recommended TypeScript rules 27 | ...tsPlugin.configs['recommended-requiring-type-checking'].rules, // Include type-checking rules 28 | '@typescript-eslint/no-unused-vars': [ 29 | 'warn', 30 | { 31 | argsIgnorePattern: '^_', 32 | varsIgnorePattern: '^_', 33 | caughtErrorsIgnorePattern: '^_', 34 | }, 35 | ], 36 | '@typescript-eslint/no-unused-expressions': [ 37 | 'error', 38 | { allowShortCircuit: true, allowTernary: true }, 39 | ], 40 | 'no-empty': 'warn', 41 | 'no-prototype-builtins': 'warn', 42 | '@typescript-eslint/no-explicit-any': 'warn', // Changed from 'error' to 'warn' 43 | 'no-case-declarations': 'warn', // Changed from 'error' to 'warn' 44 | 'require-yield': 'warn', // Changed from 'error' to 'warn' 45 | 'no-useless-catch': 'warn', // Changed from 'error' to 'warn' 46 | }, 47 | }, 48 | ]; -------------------------------------------------------------------------------- /packages/qllm-lib/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'ts-jest', 3 | testEnvironment: 'node', 4 | moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], 5 | transform: { 6 | '^.+\\.tsx?$': 'ts-jest', 7 | }, 8 | testMatch: ['**/__tests__/**/*.ts?(x)', '**/?(*.)+(spec|test).ts?(x)'], 9 | testPathIgnorePatterns: [ 10 | '/node_modules/', 11 | '/dist/', 12 | '\\.d\\.ts$' 13 | ], 14 | collectCoverage: true, 15 | coverageDirectory: 'coverage', 16 | coveragePathIgnorePatterns: [ 17 | '/node_modules/', 18 | '/dist/', 19 | '\\.d\\.ts$' 20 | ], 21 | roots: ['/src'] 22 | }; -------------------------------------------------------------------------------- /packages/qllm-lib/prompts/story.md: -------------------------------------------------------------------------------- 1 | Write a story aboout {{subject}} as {{role}} in {{lang}} max length. 2 | 3 | Use the style of this {{author}} 4 | 5 | 1 - First find funny and subversive ideas format as a table 6 | 2 - Select the best 3 ideas 7 | 3 - Create the outline of the story 8 | 4 - Write the full story 9 | 10 | Format markdown: 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /packages/qllm-lib/resources/image1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quantalogic/qllm/ae2bf9d54883a2a9c522f278d9582d680d8ddbf9/packages/qllm-lib/resources/image1.jpeg -------------------------------------------------------------------------------- /packages/qllm-lib/rollup.config.mjs: -------------------------------------------------------------------------------- 1 | import resolve from '@rollup/plugin-node-resolve'; 2 | import commonjs from '@rollup/plugin-commonjs'; 3 | import json from '@rollup/plugin-json'; 4 | import terser from '@rollup/plugin-terser'; 5 | import analyze from 'rollup-plugin-analyzer'; 6 | import gzip from 'rollup-plugin-gzip'; 7 | import wasm from '@rollup/plugin-wasm'; 8 | 9 | const isProduction = false; 10 | 11 | export default { 12 | input: 'dist/tsc/index.js', 13 | output: [ 14 | { 15 | dir: 'dist/esm', 16 | format: 'esm', 17 | sourcemap: true, 18 | preserveModules: true, 19 | preserveModulesRoot: 'dist/tsc', 20 | }, 21 | { 22 | dir: 'dist/cjs', 23 | format: 'cjs', 24 | sourcemap: true, 25 | preserveModules: true, 26 | preserveModulesRoot: 'dist/tsc', 27 | exports: 'auto', 28 | }, 29 | ], 30 | plugins: [ 31 | wasm({ 32 | targetEnv: 'node', 33 | maxFileSize: 10000000 34 | }), 35 | resolve({ 36 | preferBuiltins: true, 37 | }), 38 | commonjs(), 39 | json(), 40 | isProduction && terser(), 41 | analyze({ summaryOnly: true }), 42 | isProduction && gzip(), 43 | ], 44 | external: [ 45 | 'tiktoken', 46 | 'sqlite3', 47 | 'better-sqlite3', 48 | 'bindings', 49 | '@datastax/astra-db-ts', 50 | 'llamaindex', 51 | /* 'openai', 52 | 'groq-sdk', 53 | '@anthropic-ai/sdk', 54 | '@anthropic-ai/bedrock-sdk', 55 | '@aws-sdk/client-bedrock', 56 | '@aws-sdk/credential-providers', 57 | 'axios', 58 | 'js-yaml', 59 | 'mime-types', 60 | 'ollama', 61 | 'sqlite', 62 | 'uuid', 63 | 'tiktoken', 64 | 'zod',*/ 65 | ], 66 | }; 67 | -------------------------------------------------------------------------------- /packages/qllm-lib/src/agents/agent-loader.ts: -------------------------------------------------------------------------------- 1 | import { readFile } from 'fs/promises'; 2 | import { load } from 'js-yaml'; 3 | import { Agent } from './base-agent'; 4 | import { LLMProvider } from '../types'; 5 | 6 | export class AgentLoader { 7 | async loadFromYaml(path: string, provider: LLMProvider): Promise { 8 | const content = await readFile(path, 'utf-8'); 9 | const config = load(content) as any; 10 | 11 | return new Agent({ 12 | role: config.name, 13 | goal: config.description, 14 | backstory: config.description, 15 | llmOptions: { 16 | ...config.model.parameters, 17 | model: config.model.name, 18 | systemMessage: this.processSystemPrompt( 19 | config.system_prompt, 20 | config.role, 21 | config.goal, 22 | config.backstory 23 | ), 24 | streaming: true 25 | } 26 | }, provider); 27 | } 28 | 29 | private processSystemPrompt( 30 | template: string, 31 | role: string, 32 | goal: string, 33 | backstory: string 34 | ): string { 35 | return template 36 | .replace('{role}', role) 37 | .replace('{goal}', goal) 38 | .replace('{backstory}', backstory); 39 | } 40 | } -------------------------------------------------------------------------------- /packages/qllm-lib/src/agents/agent-manager.ts: -------------------------------------------------------------------------------- 1 | import { LLMProvider } from '../types'; 2 | import { Agent } from './base-agent'; 3 | import { AgentConfig } from './agent-types'; 4 | import * as yaml from 'js-yaml'; 5 | import * as fs from 'fs/promises'; 6 | import * as path from 'path'; 7 | 8 | export class AgentManager { 9 | private agents: Map = new Map(); 10 | 11 | constructor( 12 | private provider: LLMProvider, 13 | private templatesPath?: string 14 | ) { 15 | this.templatesPath = templatesPath || path.join(__dirname, 'templates'); 16 | } 17 | 18 | async *streamChat(name: string, message: string): AsyncGenerator { 19 | const agent = this.getAgent(name); 20 | if (!agent) { 21 | throw new Error(`Agent ${name} not found`); 22 | } 23 | for await (const chunk of agent.streamChat(message)) { 24 | yield chunk; 25 | } 26 | } 27 | 28 | async createAgent(name: string, config: AgentConfig): Promise { 29 | const agent = new Agent(config, this.provider); 30 | this.agents.set(name, agent); 31 | return agent; 32 | } 33 | 34 | async loadTemplate(templateName: string): Promise { 35 | const templatePath = path.join(this.templatesPath!, `${templateName}.yaml`); 36 | const content = await fs.readFile(templatePath, 'utf-8'); 37 | return yaml.load(content) as AgentConfig; 38 | } 39 | 40 | async createFromTemplate( 41 | name: string, 42 | templateName: string, 43 | overrides: Partial = {} 44 | ): Promise { 45 | const template = await this.loadTemplate(templateName); 46 | const config = { ...template, ...overrides }; 47 | return this.createAgent(name, config); 48 | } 49 | 50 | getAgent(name: string): Agent | undefined { 51 | return this.agents.get(name); 52 | } 53 | 54 | listAgents(): string[] { 55 | return Array.from(this.agents.keys()); 56 | } 57 | } -------------------------------------------------------------------------------- /packages/qllm-lib/src/agents/agent-types.ts: -------------------------------------------------------------------------------- 1 | import { JSONSchemaType } from 'openai/lib/jsonschema'; 2 | import { MemoryOptions } from '../types'; 3 | import { ChatMessage, LLMOptions } from '../types/llm-types'; 4 | 5 | export interface KnowledgeHandler { 6 | search(query: string): Promise; 7 | add(documents: string[]): Promise; 8 | delete(documentIds: string[]): Promise; 9 | update(documentId: string, content: string): Promise; 10 | } 11 | 12 | export interface AgentConfig { 13 | // Existing fields 14 | role: string; 15 | goal: string; 16 | backstory: string; 17 | llmOptions: LLMOptions; 18 | memoryOptions?: MemoryOptions; 19 | 20 | // New fields 21 | tools?: AgentTool[]; 22 | toolChoice?: 'none' | 'auto' | 'required'; 23 | maxIterations?: number; 24 | maxExecutionTime?: number; 25 | allowDelegation?: boolean; 26 | memory?: boolean; 27 | verbose?: boolean; 28 | cacheEnabled?: boolean; 29 | knowledgeSources?: KnowledgeSource[]; 30 | systemPrompt?: string; 31 | } 32 | 33 | export interface KnowledgeSource { 34 | type: 'rag' | 'graph' | 'vector' | 'hybrid'; 35 | config: Record; 36 | handler: KnowledgeHandler; 37 | } 38 | 39 | export interface AgentContext { 40 | messages: ChatMessage[]; 41 | memory: Map; 42 | tools: Map; 43 | } 44 | 45 | export interface AgentToolkit { 46 | name: string; 47 | description: string; 48 | tools: AgentTool[]; 49 | } 50 | 51 | export interface AgentToolResult { 52 | success: boolean; 53 | output: any; 54 | error?: string; 55 | } 56 | 57 | export interface AgentTool { 58 | name: string; 59 | description: string; 60 | parameters: JSONSchemaType; 61 | execute: (inputs: Record) => Promise; 62 | streamExecute?: (inputs: Record) => AsyncGenerator; 63 | cacheEnabled?: boolean; 64 | metadata?: Record; 65 | } 66 | 67 | export interface ToolExecutionResult { 68 | success: boolean; 69 | output: any; 70 | error?: string; 71 | } -------------------------------------------------------------------------------- /packages/qllm-lib/src/agents/index.ts: -------------------------------------------------------------------------------- 1 | 2 | // New agent exports 3 | export * from './base-agent'; 4 | export * from './agent-manager'; 5 | export * from './agent-types'; 6 | export * from './agent-loader'; 7 | export * from './agent-builder'; 8 | export * from "./tools" -------------------------------------------------------------------------------- /packages/qllm-lib/src/agents/templates/default-agent.yaml: -------------------------------------------------------------------------------- 1 | name: research_assistant 2 | version: 1.0.0 3 | description: An AI research assistant 4 | system_prompt: | 5 | You are an AI assistant with the following characteristics: 6 | Role: {role} 7 | Goal: {goal} 8 | Backstory: {backstory} 9 | Instructions: 10 | 1. Use your expertise to provide accurate and helpful responses 11 | 2. Maintain conversation context 12 | 3. Use available tools when appropriate 13 | 4. Stay focused on your assigned role and goal 14 | 5. Provide clear and structured responses 15 | 16 | model: 17 | provider: openai 18 | name: gpt-4o-mini 19 | parameters: 20 | max_tokens: 1000 21 | temperature: 0.7 22 | top_p: 1 23 | top_k: 250 24 | streaming: true -------------------------------------------------------------------------------- /packages/qllm-lib/src/agents/tools/index.ts: -------------------------------------------------------------------------------- 1 | 2 | export * from "./rag-search" 3 | export * from "./rag-search-querytool" -------------------------------------------------------------------------------- /packages/qllm-lib/src/conversation/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Entry point for the conversation management system. 3 | * Re-exports all conversation-related functionality from the conversation manager module. 4 | * 5 | * @module conversation 6 | * @see module:conversation-manager 7 | */ 8 | 9 | export * from './conversation-manager'; 10 | -------------------------------------------------------------------------------- /packages/qllm-lib/src/providers/anthropic/constants.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Configuration constants for the Anthropic provider. 3 | * Defines default values for AWS Bedrock integration and model settings. 4 | * 5 | * @author QLLM Team 6 | * @version 1.0.0 7 | */ 8 | 9 | /** Default AWS region for Bedrock service */ 10 | export const DEFAULT_AWS_BEDROCK_REGION = 'us-west-2'; 11 | 12 | /** Default AWS profile name for Bedrock service */ 13 | export const DEFAULT_AWS_BEDROCK_PROFILE = 'bedrock'; 14 | 15 | /** Default Anthropic model identifier */ 16 | export const DEFAULT_MODEL = 'anthropic.claude-3-haiku-20240307-v1:0'; 17 | 18 | /** Default maximum tokens for model responses (128K tokens) */ 19 | export const DEFAULT_MAX_TOKENS = 128 * 1024; // 128,000 tokens 20 | -------------------------------------------------------------------------------- /packages/qllm-lib/src/providers/ovh/models.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview OVH model configuration for the QLLM library. 3 | * Defines the DeepSeek-R1-Distill-Llama-70B model provided by OVH. 4 | */ 5 | 6 | export type OVHModelKey = 'DeepSeek-R1-Distill-Llama-70B'; 7 | 8 | export type OVHModelConfig = { 9 | id: string; 10 | name: string; 11 | parameterCount: string; 12 | contextLength: number; 13 | type: string; 14 | endpoint: string; 15 | }; 16 | 17 | export const OVH_MODELS: Record = { 18 | "DeepSeek-R1-Distill-Llama-70B": { 19 | id: 'DeepSeek-R1-Distill-Llama-70B', 20 | name: 'DeepSeek R1 Distilled Llama 70B', 21 | parameterCount: '70B', 22 | contextLength: 64*1024, // Adjust based on actual model specs 23 | type: 'Chat Completion', 24 | endpoint: 'https://deepseek-r1-distill-llama-70b.endpoints.kepler.ai.cloud.ovh.net/api/openai_compat/v1', 25 | }, 26 | }; 27 | 28 | export const ALL_OVH_MODELS: Record = { 29 | ...OVH_MODELS, 30 | }; 31 | 32 | export const DEFAULT_OVH_MODEL = "DeepSeek-R1-Distill-Llama-70B" -------------------------------------------------------------------------------- /packages/qllm-lib/src/templates/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview QLLM Template Module Entry Point 3 | * 4 | * This module serves as the main entry point for the QLLM template system. 5 | * It exports all template-related functionality including: 6 | * - Template management and execution 7 | * - Variable extraction and validation 8 | * - Type definitions and error classes 9 | * 10 | * @version 1.0.0 11 | * @module qllm-lib/templates 12 | * 13 | * @example 14 | * ```typescript 15 | * import { TemplateManager, TemplateExecutor } from 'qllm-lib/templates'; 16 | * 17 | * // Create and initialize a template manager 18 | * const manager = new TemplateManager({ promptDirectory: './templates' }); 19 | * await manager.init(); 20 | * 21 | * // Execute a template 22 | * const executor = new TemplateExecutor(); 23 | * const result = await executor.execute(template, variables); 24 | * ``` 25 | */ 26 | 27 | export * from './output-variable-extractor'; 28 | export * from './template-manager'; 29 | export * from './template-executor'; 30 | export * from './template-loader'; 31 | export * from './types'; 32 | -------------------------------------------------------------------------------- /packages/qllm-lib/src/templates/samples/prompt-sample.yaml: -------------------------------------------------------------------------------- 1 | name: 'Text Generation Template' 2 | version: '1.0.0' 3 | description: 'A template for generating creative text based on user input.' 4 | author: 'Raphaël MANSUY' 5 | provider: 'OpenAI' 6 | tags: 7 | - 'text generation' 8 | - 'AI' 9 | categories: 10 | - 'NLP' 11 | - 'Content Creation' 12 | model: 'gpt-4o-mini' 13 | input_variables: 14 | user_input: 15 | type: 'string' 16 | description: 'The input text provided by the user to generate a response.' 17 | place_holder: 'Once upon a time' 18 | inferred: false 19 | tone: 20 | type: 'string' 21 | description: 'The tone of the generated text (e.g., formal, informal, humorous).' 22 | place_holder: 'informal' 23 | inferred: false 24 | output_variables: 25 | generated_text: 26 | type: 'string' 27 | description: 'The text generated by the model based on the user input.' 28 | default: '' 29 | parameters: 30 | max_tokens: 200 # Increased max tokens for longer responses 31 | temperature: 0.8 # Adjusted temperature for more creativity 32 | top_p: 0.95 # Increased top_p for more diverse outputs 33 | top_k: 60 # Increased top_k for broader sampling 34 | prompt_type: 'text_generation' 35 | target_language: 'en' 36 | task_description: "Generate a creative story based on the user's input and specified tone." 37 | example_outputs: 38 | - 'Once upon a time, in a land far away, there lived a brave knight named Sir Lancelot...' 39 | - 'Cats are furry, cats are fun, they chase the laser, they run and run!' 40 | content: | 41 | ## As author write a Creative Story 42 | 43 | Generate a creative story based on the user's input and specified tone. 44 | 45 | Start of the story: `{{user_input}}` 46 | Tone: `{{tone}}` 47 | 48 | ## Steps 49 | 50 | 1. First find 10 ideas for the story. 51 | 2. Select the best 3 ideas. 52 | 3. Write the story based on the selected ideas in the section. 53 | 54 | ## Output format, you must respect. 55 | 56 | The story to generate ... 57 | -------------------------------------------------------------------------------- /packages/qllm-lib/src/tools/index.ts: -------------------------------------------------------------------------------- 1 | import { S3ToLocalTool } from "./s3_to_local.tool"; 2 | 3 | export * from "./base-tool"; 4 | export * from "./github-loader"; 5 | export * from "./gitlab-loader"; 6 | export * from "./bitbucket-loader"; 7 | export * from "./file-saver.tool"; 8 | export * from "./local-project-loader"; 9 | export * from "./s3.tool"; 10 | export * from "./llamaindex-rag-v1"; 11 | export * from "./jira.tool"; 12 | export * from "./s3_to_local.tool"; 13 | export * from "./remove_from_local.tool" 14 | export * from "./api-server-call.tool" 15 | export * from "./enhanced-jira.tool" 16 | export * from "./custom-api-server-call.tool" 17 | -------------------------------------------------------------------------------- /packages/qllm-lib/src/types/document-types.ts: -------------------------------------------------------------------------------- 1 | // src/utils/document/document-types.ts 2 | export interface FormatHandler { 3 | mimeTypes: string[]; 4 | handle(buffer: Buffer): Promise; 5 | } 6 | 7 | export interface ParseResult { 8 | content: string; 9 | mimeType: string; 10 | parsedContent?: string; 11 | } 12 | 13 | export interface DocumentParser { 14 | parse(buffer: Buffer, filename: string): Promise; 15 | supports(filename: string): boolean; 16 | } 17 | 18 | export type LoadResult = { 19 | content: T; 20 | mimeType: string; 21 | parsedContent?: string; 22 | }; -------------------------------------------------------------------------------- /packages/qllm-lib/src/types/file-handler.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Type definitions for file handling operations in the QLLM library. 3 | * This file defines the interface for file system operations used throughout the library. 4 | * 5 | * @version 1.0.0 6 | * @license MIT 7 | */ 8 | 9 | /** 10 | * Interface for handling file system operations 11 | * Provides methods for reading, checking existence, and determining file types 12 | */ 13 | export interface FileHandler { 14 | /** 15 | * Reads the contents of a file 16 | * @param path - Path to the file to read 17 | * @returns Promise resolving to the file contents as a string 18 | */ 19 | read(path: string): Promise; 20 | 21 | /** 22 | * Checks if a file exists 23 | * @param path - Path to check for existence 24 | * @returns Promise resolving to true if file exists, false otherwise 25 | */ 26 | exists(path: string): Promise; 27 | 28 | /** 29 | * Gets the MIME type or content type of a file 30 | * @param path - Path to the file to check 31 | * @returns Promise resolving to the file's content type 32 | */ 33 | getType(path: string): Promise; 34 | } 35 | 36 | -------------------------------------------------------------------------------- /packages/qllm-lib/src/types/index.ts: -------------------------------------------------------------------------------- 1 | export * from './llm-provider'; 2 | export * from './llm-types'; 3 | export * from './conversations-types'; 4 | export * from './workflow-types'; 5 | export * from './file-handler'; 6 | export * from './models-cost'; 7 | export {MemoryOptions} from './storage'; 8 | export {ProviderOptions} from './llm-provider'; 9 | -------------------------------------------------------------------------------- /packages/qllm-lib/src/types/s3-types.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @interface S3Config 3 | * @description Configuration options for S3 client 4 | */ 5 | export interface S3Config { 6 | /** AWS access key ID */ 7 | aws_s3_access_key?: string; 8 | /** AWS secret access key */ 9 | aws_s3_secret_key?: string; 10 | /** AWS region */ 11 | aws_s3_bucket_region?: string; 12 | /** Optional AWS endpoint URL for custom endpoints */ 13 | aws_s3_endpoint_url?: string; 14 | /** Additional S3 client options */ 15 | custom_options?: Record; 16 | } 17 | -------------------------------------------------------------------------------- /packages/qllm-lib/src/types/storage.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | import { StorageProvider } from '../types'; 4 | 5 | 6 | export interface MemoryOptions { 7 | shortTermSize: number; 8 | longTermEnabled: boolean; 9 | storageProvider: StorageProvider; 10 | vectorSearchConfig?: { 11 | similarity: number; 12 | maxResults: number; 13 | }; 14 | } -------------------------------------------------------------------------------- /packages/qllm-lib/src/types/workflow-types.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Type definitions for workflow management in the QLLM library. 3 | * This file defines the core types and interfaces for handling workflows, 4 | * including steps, definitions, and execution contexts. 5 | * 6 | * @version 1.0.0 7 | * @license MIT 8 | */ 9 | 10 | import { TemplateDefinition } from '../templates/types'; 11 | 12 | /** 13 | * Represents a single step in a workflow 14 | * Each step contains a template, optional provider, input parameters, and output specification 15 | */ 16 | export interface WorkflowStep { 17 | template?: TemplateDefinition; 18 | templateUrl?: string; 19 | name?: string; 20 | description?: string; 21 | tool?: string; 22 | toolConfig?: Record; 23 | provider?: string; 24 | input?: Record; 25 | output: string | Record; 26 | } 27 | 28 | /** 29 | * Defines a complete workflow including its metadata and steps 30 | */ 31 | export interface WorkflowDefinition { 32 | /** Name of the workflow */ 33 | name: string; 34 | /** Optional description of the workflow's purpose */ 35 | description?: string; 36 | /** Optional version identifier */ 37 | version?: string; 38 | /** Default provider to use if not specified in steps */ 39 | defaultProvider?: string; 40 | /** Ordered array of workflow steps */ 41 | steps: WorkflowStep[]; 42 | } 43 | 44 | /** 45 | * Result of executing a workflow step 46 | */ 47 | export interface WorkflowExecutionResult { 48 | /** Response text or data from the step execution */ 49 | response: string; 50 | /** Variables produced by the step execution */ 51 | outputVariables: Record; 52 | } 53 | 54 | /** 55 | * Context maintained during workflow execution 56 | * Contains variables and results from previous steps 57 | */ 58 | export interface WorkflowExecutionContext { 59 | /** Variables available during workflow execution */ 60 | variables: Record; 61 | /** Results from executed steps */ 62 | results: Record; 63 | } -------------------------------------------------------------------------------- /packages/qllm-lib/src/utils/cloud/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Cloud service utilities for AWS and other cloud providers. 3 | * Provides functionality for authentication and interaction with cloud services. 4 | * 5 | * Currently supported cloud providers: 6 | * - AWS 7 | * - Bedrock (foundation models) 8 | * - STS (credential management) 9 | * 10 | * @author QLLM Team 11 | * @module utils/cloud 12 | */ 13 | 14 | export * as aws from './aws/bedrock'; 15 | export * as awsCredentials from './aws/credential'; 16 | -------------------------------------------------------------------------------- /packages/qllm-lib/src/utils/conversation/index.ts: -------------------------------------------------------------------------------- 1 | export * from './conversation-util'; 2 | -------------------------------------------------------------------------------- /packages/qllm-lib/src/utils/document/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Document handling utilities for loading and processing various document formats. 3 | * Provides functionality for document loading, inclusion resolution, and format-specific handling. 4 | * 5 | * @author QLLM Team 6 | * @module utils/document 7 | */ 8 | 9 | export * from "./document-inclusion-resolver"; 10 | export * from "./document-loader"; -------------------------------------------------------------------------------- /packages/qllm-lib/src/utils/document/parsers/parser-registry.ts: -------------------------------------------------------------------------------- 1 | // parser-registry.ts 2 | import { DocumentParser } from '../../../types/document-types'; 3 | import { TextParser, PDFParser } from './index'; 4 | 5 | export interface ParserRegistry { 6 | getParser(filename: string): DocumentParser | undefined; 7 | } 8 | 9 | export class DefaultParserRegistry implements ParserRegistry { 10 | private parsers: DocumentParser[]; 11 | 12 | constructor() { 13 | this.parsers = [ 14 | new TextParser(), 15 | new PDFParser() 16 | ]; 17 | } 18 | 19 | getParser(filename: string): DocumentParser | undefined { 20 | return this.parsers.find(parser => parser.supports(filename)); 21 | } 22 | } -------------------------------------------------------------------------------- /packages/qllm-lib/src/utils/file-handlers/factory.ts: -------------------------------------------------------------------------------- 1 | // src/utils/file-handlers/factory.ts 2 | import { FileHandler } from '../../types/file-handler'; 3 | import { LocalFileHandler } from './local-handler'; 4 | import { S3FileHandler } from './s3-handler'; 5 | 6 | export function createFileHandler(path: string): FileHandler { 7 | if (path.startsWith('s3://')) { 8 | return new S3FileHandler(); 9 | } 10 | return new LocalFileHandler(); 11 | } -------------------------------------------------------------------------------- /packages/qllm-lib/src/utils/file-handlers/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./local-handler"; 2 | export * from "./s3-handler"; 3 | export * from "./factory"; -------------------------------------------------------------------------------- /packages/qllm-lib/src/utils/file-handlers/local-handler.ts: -------------------------------------------------------------------------------- 1 | // src/utils/file-handlers/local-handler.ts 2 | import fs from 'fs/promises'; 3 | import mime from 'mime-types'; 4 | import path from 'path'; 5 | import { FileHandler } from '../../types'; 6 | 7 | export class LocalFileHandler implements FileHandler { 8 | async read(filePath: string): Promise { 9 | try { 10 | const content = await fs.readFile(filePath, 'utf-8'); 11 | return content; 12 | } catch (error) { 13 | throw new Error(`Failed to read local file: ${error as Error}`); 14 | } 15 | } 16 | 17 | async exists(filePath: string): Promise { 18 | try { 19 | await fs.access(filePath); 20 | return true; 21 | } catch { 22 | return false; 23 | } 24 | } 25 | 26 | async getType(filePath: string): Promise { 27 | return mime.lookup(filePath) || 'text/plain'; 28 | } 29 | } -------------------------------------------------------------------------------- /packages/qllm-lib/src/utils/file-handlers/s3-handler.ts: -------------------------------------------------------------------------------- 1 | // src/utils/file-handlers/s3-handler.ts 2 | import { S3Client, GetObjectCommand, HeadObjectCommand } from '@aws-sdk/client-s3'; 3 | import { FileHandler } from '../../types'; 4 | 5 | export class S3FileHandler implements FileHandler { 6 | private client: S3Client; 7 | 8 | constructor(region: string = 'us-east-1') { 9 | this.client = new S3Client({ region }); 10 | } 11 | 12 | private parseS3Url(s3Url: string): { Bucket: string; Key: string } { 13 | const url = new URL(s3Url); 14 | return { 15 | Bucket: url.hostname.split('.')[0], 16 | Key: url.pathname.slice(1) 17 | }; 18 | } 19 | 20 | async read(s3Url: string): Promise { 21 | try { 22 | const params = this.parseS3Url(s3Url); 23 | const command = new GetObjectCommand(params); 24 | const response = await this.client.send(command); 25 | 26 | if (!response.Body) { 27 | throw new Error('Empty response from S3'); 28 | } 29 | 30 | return await response.Body.transformToString(); 31 | } catch (error) { 32 | throw new Error(`Failed to read S3 file: ${error as Error}`); 33 | } 34 | } 35 | 36 | async exists(s3Url: string): Promise { 37 | try { 38 | const params = this.parseS3Url(s3Url); 39 | const command = new HeadObjectCommand(params); 40 | await this.client.send(command); 41 | return true; 42 | } catch { 43 | return false; 44 | } 45 | } 46 | 47 | async getType(s3Url: string): Promise { 48 | try { 49 | const params = this.parseS3Url(s3Url); 50 | const command = new HeadObjectCommand(params); 51 | const response = await this.client.send(command); 52 | return response.ContentType || 'text/plain'; 53 | } catch { 54 | return 'text/plain'; 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /packages/qllm-lib/src/utils/images/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Image utility module providing functions for handling chat message content and image conversions. 3 | * Exports utilities for creating text message content and image-to-base64 conversion functionality. 4 | * 5 | * @author QLLM Team 6 | * @module utils/images 7 | */ 8 | 9 | import { ChatMessageContent, ImageUrlContent } from '../../types'; 10 | import { imageToBase64 } from './image-to-base64'; 11 | export { imageToBase64 } from './image-to-base64'; 12 | 13 | /** 14 | * Creates a chat message content object from text input. 15 | * Supports both single strings and arrays of strings, converting them to the appropriate message format. 16 | * 17 | * @param {string | string[]} content - Text content to convert into message format 18 | * @returns {ChatMessageContent} Formatted chat message content object(s) 19 | * 20 | * @example 21 | * ```typescript 22 | * // Single message 23 | * const singleMessage = createTextMessageContent('Hello'); 24 | * // Multiple messages 25 | * const multiMessage = createTextMessageContent(['Hello', 'World']); 26 | * ``` 27 | */ 28 | export const createTextMessageContent = (content: string | string[]): ChatMessageContent => { 29 | if (Array.isArray(content)) { 30 | return content.map((text) => ({ type: 'text', text })); 31 | } else { 32 | return { type: 'text', text: content }; 33 | } 34 | }; 35 | -------------------------------------------------------------------------------- /packages/qllm-lib/src/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './images'; 2 | export * from './functions'; 3 | export * from './logger'; 4 | export * from "./document"; 5 | export * from "./models-cost"; -------------------------------------------------------------------------------- /packages/qllm-lib/src/workflow/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview Entry point for the workflow module. Exports workflow execution and management functionality. 3 | * 4 | * This module provides: 5 | * - WorkflowExecutor: Handles step-by-step execution of workflow definitions 6 | * - WorkflowManager: Manages workflow lifecycle including loading and running workflows 7 | * 8 | * @module workflow 9 | */ 10 | 11 | export * from './workflow-executor'; 12 | export * from './workflow-manager'; 13 | -------------------------------------------------------------------------------- /packages/qllm-lib/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "types": ["jest", "node"], 4 | "target": "ES2020", 5 | "module": "ESNext", 6 | "moduleResolution": "node", 7 | "esModuleInterop": true, 8 | "declaration": true, 9 | "declarationMap": true, 10 | "sourceMap": true, 11 | "outDir": "./dist/tsc", 12 | "rootDir": "./src", 13 | "strict": true, 14 | "skipLibCheck": true, 15 | "forceConsistentCasingInFileNames": true, 16 | "typeRoots": [ 17 | "./node_modules/@types", 18 | "./src/types" 19 | ], 20 | "allowSyntheticDefaultImports": true, 21 | "allowJs": true, 22 | "resolveJsonModule": true, 23 | "baseUrl": ".", 24 | "paths": { 25 | "*": ["src/types/*"] 26 | } 27 | }, 28 | "include": [ 29 | "src/**/*", 30 | "__tests__/**/*", 31 | "src/**/*.ts", 32 | "src/**/*.d.ts", 33 | "src/types/*.d.ts" 34 | ], 35 | "exclude": ["node_modules", "dist"] 36 | } -------------------------------------------------------------------------------- /packages/qllm-lib/tsconfig.test.json: -------------------------------------------------------------------------------- 1 | // tsconfig.test.json 2 | { 3 | "extends": "./tsconfig.json", 4 | "include": ["src/**/*.ts", "src/**/*.spec.ts"] // Include test files 5 | } 6 | -------------------------------------------------------------------------------- /packages/qllm-lib/typedoc.json: -------------------------------------------------------------------------------- 1 | { 2 | "entryPoints": ["src/index.ts"], 3 | "out": "docs/api/qllm-lib", 4 | "name": "QLLM Library API Documentation", 5 | "theme": "default", 6 | "plugin": ["typedoc-plugin-markdown"], 7 | "excludePrivate": true, 8 | "excludeProtected": true, 9 | "excludeExternals": true, 10 | "includeVersion": true, 11 | "readme": "API_DOCUMENTATION.md" 12 | } 13 | -------------------------------------------------------------------------------- /packages/qllm-samples/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # qllm-samples 2 | 3 | ## 1.0.5 4 | 5 | ### Patch Changes 6 | 7 | - Updated dependencies 8 | - qllm-lib@3.6.2 9 | 10 | ## 1.0.4 11 | 12 | ### Patch Changes 13 | 14 | - Updated dependencies 15 | - qllm-lib@3.6.0 16 | 17 | ## 1.0.3 18 | 19 | ### Patch Changes 20 | 21 | - Updated dependencies 22 | - qllm-lib@3.5.0 23 | 24 | ## 1.0.2 25 | 26 | ### Patch Changes 27 | 28 | - Updated dependencies [9b93450] 29 | - qllm-lib@3.4.1 30 | 31 | ## 1.0.1 32 | 33 | ### Patch Changes 34 | 35 | - Updated dependencies [6611cb9] 36 | - Updated dependencies [4e20449] 37 | - qllm-lib@3.4.0 38 | -------------------------------------------------------------------------------- /packages/qllm-samples/data/default-agent.yaml: -------------------------------------------------------------------------------- 1 | name: research_assistant 2 | version: 1.0.0 3 | description: An AI research assistant 4 | system_prompt: | 5 | You are an AI assistant with the following characteristics: 6 | Role: {role} 7 | Goal: {goal} 8 | Backstory: {backstory} 9 | 10 | Instructions: 11 | 1. Use your expertise to provide accurate and helpful responses 12 | 2. Maintain conversation context 13 | 3. Use available tools when appropriate 14 | 4. Stay focused on your assigned role and goal 15 | 5. Provide clear and structured responses 16 | 17 | model: 18 | provider: openai 19 | name: gpt-4o-mini 20 | parameters: 21 | max_tokens: 1000 22 | temperature: 0.7 23 | top_p: 1 24 | top_k: 250 25 | 26 | tools: 27 | - name: rag_search 28 | description: Search the web for information 29 | parameters: 30 | type: object 31 | 32 | - name: rag_search_query 33 | description: Search the web for information 34 | parameters: 35 | type: object -------------------------------------------------------------------------------- /packages/qllm-samples/data/token_price.json: -------------------------------------------------------------------------------- 1 | { 2 | "providers": [ 3 | { 4 | "name": "openai", 5 | "models": [ 6 | { 7 | "name": "gpt-4", 8 | "input_price": 0.03, 9 | "output_price": 0.06 10 | }, 11 | { 12 | "name": "gpt-3.5-turbo", 13 | "input_price": 0.0015, 14 | "output_price": 0.002 15 | } 16 | ] 17 | } 18 | ] 19 | } -------------------------------------------------------------------------------- /packages/qllm-samples/docs/AVIS-MEDECIN.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quantalogic/qllm/ae2bf9d54883a2a9c522f278d9582d680d8ddbf9/packages/qllm-samples/docs/AVIS-MEDECIN.pdf -------------------------------------------------------------------------------- /packages/qllm-samples/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | // packages//qllm-samples/eslint.config.jms 2 | // @ts-check 3 | 4 | import tsPlugin from '@typescript-eslint/eslint-plugin'; 5 | import tsParser from '@typescript-eslint/parser'; 6 | 7 | export default [ 8 | { 9 | ignores: ['**/node_modules/**', '**/dist/**'], // Ignore unnecessary files 10 | }, 11 | { 12 | files: ['*.ts', '*.tsx'], // Apply only to TypeScript files 13 | languageOptions: { 14 | parser: tsParser, 15 | parserOptions: { 16 | ecmaVersion: 'latest', 17 | sourceType: 'module', 18 | project: './tsconfig.json', // Ensure this points to your tsconfig.json 19 | tsconfigRootDir: process.cwd(), 20 | }, 21 | }, 22 | plugins: { 23 | '@typescript-eslint': tsPlugin, 24 | }, 25 | rules: { 26 | ...tsPlugin.configs.recommended.rules, // Use recommended TypeScript rules 27 | ...tsPlugin.configs['recommended-requiring-type-checking'].rules, // Include type-checking rules 28 | '@typescript-eslint/no-unused-vars': [ 29 | 'warn', 30 | { 31 | argsIgnorePattern: '^_', 32 | varsIgnorePattern: '^_', 33 | caughtErrorsIgnorePattern: '^_', 34 | }, 35 | ], 36 | '@typescript-eslint/no-unused-expressions': [ 37 | 'error', 38 | { allowShortCircuit: true, allowTernary: true }, 39 | ], 40 | 'no-empty': 'warn', 41 | 'no-prototype-builtins': 'warn', 42 | '@typescript-eslint/no-explicit-any': 'warn', // Changed from 'error' to 'warn' 43 | 'no-case-declarations': 'warn', // Changed from 'error' to 'warn' 44 | 'require-yield': 'warn', // Changed from 'error' to 'warn' 45 | 'no-useless-catch': 'warn', // Changed from 'error' to 'warn' 46 | }, 47 | }, 48 | ]; -------------------------------------------------------------------------------- /packages/qllm-samples/src/agents/demo_test.ts: -------------------------------------------------------------------------------- 1 | import { Agent, AgentBuilder, createLLMProvider,RAGTool } from "qllm-lib"; 2 | 3 | async function main() { 4 | // Initialize the LLM provider 5 | const provider = createLLMProvider({ 6 | name: 'openai', 7 | apiKey: process.env.OPENAI_API_KEY 8 | }); 9 | 10 | // Initialize the RAG tool 11 | const ragTool = new RAGTool('./docs', { 12 | embedModel: { 13 | type: 'openai', 14 | options: { 15 | modelType: 'text-embedding-ada-002' 16 | } 17 | }, 18 | name: 'document_search', 19 | description: 'Search through project documentation', 20 | similarityTopK: 5 21 | }); 22 | 23 | 24 | // Create the agent with the RAG tool 25 | const agent = AgentBuilder.create({ 26 | role: "Research Assistant", 27 | goal: "Help users find information in documents", 28 | backstory: "An intelligent AI assistant specialized in document search and analysis" 29 | }) 30 | .withProvider(provider) 31 | .withLLMOptions({ 32 | model: "gpt-4", 33 | maxTokens: 1000, 34 | temperature: 0.7 35 | }) 36 | .withTool(ragTool) 37 | .withMemory(true) 38 | .withSystemPrompt(` 39 | You are a research assistant that helps users find information in documents. 40 | When asked a question, use the document_search tool to find relevant information. 41 | Always cite your sources and provide context from the documents. 42 | `) 43 | .build(); 44 | 45 | // Test queries 46 | const queries = [ 47 | "What are the main topics discussed in the documents?", 48 | "tell me more about trump ?", 49 | ]; 50 | 51 | for (const query of queries) { 52 | console.log(`\nQuery: ${query}`); 53 | console.log("Response:"); 54 | 55 | // Use streaming for real-time responses 56 | for await (const chunk of agent.streamChat(query)) { 57 | process.stdout.write(chunk); 58 | } 59 | console.log("\n---"); 60 | } 61 | } 62 | 63 | main().catch(console.error); -------------------------------------------------------------------------------- /packages/qllm-samples/src/agents/demo_test2.ts: -------------------------------------------------------------------------------- 1 | import { Agent, AgentBuilder, createLLMProvider,RAGTool } from "qllm-lib"; 2 | 3 | 4 | async function main() { 5 | // Initialize the LLM provider 6 | const provider = createLLMProvider({ 7 | name: 'openai', 8 | apiKey: process.env.OPENAI_API_KEY 9 | }); 10 | // Create agent with RAG tool 11 | const agent = await AgentBuilder.create({ 12 | role: "Research Assistant", 13 | goal: "Help users find and analyze information from documents", 14 | backstory: "I am an AI assistant specialized in searching and analyzing documents" 15 | }) 16 | .withTool(new RAGTool("./docs", { 17 | embedModel: { 18 | type: 'openai', 19 | options: { 20 | modelType: 'text-embedding-ada-002' 21 | } 22 | }, 23 | similarityTopK: 3 24 | })) 25 | .withProvider(provider) 26 | .withLLMOptions({ 27 | model: "gpt-4o-mini", 28 | maxTokens: 1000, 29 | temperature: 0.7 30 | }) 31 | .withMemory(true) 32 | .build(); 33 | 34 | // Test regular chat 35 | const response = await agent.chat("What are the main topics discussed in my documents ?"); 36 | console.log("Regular response:", response); 37 | 38 | // Test streaming chat 39 | console.log("\nStreaming response:"); 40 | for await (const chunk of agent.streamChat("What are the main topics discussed in my documents ?")) { 41 | process.stdout.write(chunk); 42 | } 43 | 44 | console.log("\nStreaming response:"); 45 | for await (const chunk of agent.streamChat("tell me about trump ?")) { 46 | process.stdout.write(chunk); 47 | } 48 | } 49 | 50 | main().catch(console.error); -------------------------------------------------------------------------------- /packages/qllm-samples/src/api-tool-example.ts: -------------------------------------------------------------------------------- 1 | import { ApiServerCallTool } from 'qllm-lib'; 2 | 3 | async function testApiTool() { 4 | const apiTool = new ApiServerCallTool(); 5 | 6 | try { 7 | // Example 1: GET request 8 | console.log('Testing GET request...'); 9 | const getPosts = await apiTool.execute({ 10 | url: 'https://jsonplaceholder.typicode.com/posts/1', 11 | method: 'GET' 12 | }); 13 | console.log('GET Result:', getPosts); 14 | 15 | // Example 2: POST request 16 | console.log('\nTesting POST request...'); 17 | const createPost = await apiTool.execute({ 18 | url: 'https://jsonplaceholder.typicode.com/posts', 19 | method: 'POST', 20 | data: { 21 | title: 'Test Post', 22 | body: 'This is a test post', 23 | userId: 1 24 | } 25 | }); 26 | console.log('POST Result:', createPost); 27 | 28 | // Example 3: GET request with query parameters 29 | console.log('\nTesting GET request with query parameters...'); 30 | const getComments = await apiTool.execute({ 31 | url: 'https://jsonplaceholder.typicode.com/comments?postId=1', 32 | method: 'GET' 33 | }); 34 | console.log('GET Comments Result:', getComments.slice(0, 2)); // Show only first 2 comments 35 | 36 | } catch (error) { 37 | console.error('Error:', error); 38 | } 39 | } 40 | 41 | // Run the test 42 | testApiTool().catch(console.error); 43 | -------------------------------------------------------------------------------- /packages/qllm-samples/src/examples/custom-api-test.ts: -------------------------------------------------------------------------------- 1 | import { CustomApiServerCallTool } from "qllm-lib"; 2 | import dotenv from 'dotenv'; 3 | 4 | dotenv.config(); 5 | 6 | async function main(): Promise { 7 | try { 8 | console.log("\n Debug - Starting custom API test"); 9 | 10 | const customApiCall = new CustomApiServerCallTool(); 11 | 12 | // Define input data 13 | const workflowInput = { 14 | repository: "/tmp/s3_to_local/FRGTY", 15 | query: "give me the main points discussed" , 16 | headers: JSON.stringify({ 17 | "Content-Type": "application/json", 18 | "accept": "application/json" 19 | }) 20 | }; 21 | 22 | // Debug: Print input 23 | console.log('\n Debug: API input:', JSON.stringify(workflowInput, null, 2)); 24 | 25 | const result = await customApiCall.execute({ 26 | url: "http://localhost:8001/api/raglite/upload_and_query", 27 | method: "POST", 28 | ...workflowInput 29 | }); 30 | 31 | console.log("\n API call completed"); 32 | console.log('Response:', JSON.stringify(result, null, 2)); 33 | 34 | } catch (error) { 35 | console.error('\n Error during API call:', error); 36 | if (error instanceof Error) { 37 | console.error('Error name:', error.name); 38 | console.error('Error message:', error.message); 39 | console.error('Stack trace:', error.stack); 40 | } 41 | process.exit(1); 42 | } 43 | } 44 | 45 | // Error handling 46 | process.on('unhandledRejection', (reason, promise) => { 47 | console.error('\n Debug: Unhandled rejection:', reason); 48 | if (reason instanceof Error) { 49 | console.error('Error name:', reason.name); 50 | console.error('Error message:', reason.message); 51 | console.error('Stack trace:', reason.stack); 52 | } 53 | process.exit(1); 54 | }); 55 | 56 | // Run the main function 57 | main(); 58 | -------------------------------------------------------------------------------- /packages/qllm-samples/src/index.ts: -------------------------------------------------------------------------------- 1 | console.log("Demo completed successfully"); 2 | -------------------------------------------------------------------------------- /packages/qllm-samples/src/prompts/create_story.yaml: -------------------------------------------------------------------------------- 1 | name: create_story 2 | version: "1.0" 3 | description: Create a nice story 4 | author: Raphaël MANSUY 5 | #provider: ollama 6 | #model: mistral 7 | input_variables: 8 | subject: 9 | type: string 10 | description: The subject of the story 11 | default: "Emmanuel Macron dissout l'assemblée" 12 | genre: 13 | type: string 14 | description: The genre of the story 15 | default: "Humour et satire" 16 | role: 17 | type: string 18 | description: The role of the user 19 | default: "Gaspar PROUST" 20 | lang: 21 | type: string 22 | description: The language of the story 23 | default: "Français" 24 | max_length: 25 | type: number 26 | description: The maximum length of the story 27 | default: 100 28 | output_variables: 29 | story: 30 | type: string 31 | description: The story 32 | 33 | content: > 34 | {{file:./story.md}} 35 | -------------------------------------------------------------------------------- /packages/qllm-samples/src/prompts/create_story_no_var.yaml: -------------------------------------------------------------------------------- 1 | name: create_story 2 | version: "1.0" 3 | description: Create a nice story 4 | author: Raphaël MANSUY 5 | content: > 6 | 'Write a small story about Paris. Less than 200 words. 7 | -------------------------------------------------------------------------------- /packages/qllm-samples/src/prompts/improve.yaml: -------------------------------------------------------------------------------- 1 | name: improve 2 | version: 1.0.0 3 | description: Improve a prompt 4 | author: Raphaël MANSUY 5 | provider: anthropic 6 | model: sonnet35 7 | content: "" 8 | -------------------------------------------------------------------------------- /packages/qllm-samples/src/prompts/improve_prompt.yaml: -------------------------------------------------------------------------------- 1 | name: improve_prompt 2 | version: "1.0" 3 | description: Improve a prompt 4 | author: Raphaël MANSUY 5 | max_tokens: 2048 6 | #provider: ollama 7 | #model: mistral 8 | input_variables: 9 | prompt: 10 | type: string 11 | description: The prompt to improve 12 | default: "" 13 | output_variables: 14 | prompt_final: 15 | type: string 16 | description: The improved prompt 17 | content: > 18 | {{file:./improve_prompt.md}} 19 | -------------------------------------------------------------------------------- /packages/qllm-samples/src/prompts/role.md: -------------------------------------------------------------------------------- 1 | ## Your role 2 | 3 | You are {{role}} 4 | -------------------------------------------------------------------------------- /packages/qllm-samples/src/prompts/story.md: -------------------------------------------------------------------------------- 1 | ## Your role 2 | 3 | {{file:./role.md}} 4 | 5 | ## Your task 6 | 7 | Write a {{genre}} story about {{subject}} 8 | 9 | Use {{lang}} to write the story. 10 | 11 | ## OUTPUT example 12 | 13 | ```xml 14 | 15 | 16 | ... the story formatted using Markdown. . Length {{max_length}} words ... 17 | 18 | 19 | ``` 20 | -------------------------------------------------------------------------------- /packages/qllm-samples/src/prompts/story_no_variable.md: -------------------------------------------------------------------------------- 1 | ## Your task 2 | 3 | Write a story about Paris. 4 | 5 | ## OUTPUT example 6 | 7 | ```xml 8 | 9 | 10 | ... the story formatted using Markdown. . Length 200 words. 11 | 12 | 13 | ``` 14 | -------------------------------------------------------------------------------- /packages/qllm-samples/src/template-demos/demo-prompt-variable.ts: -------------------------------------------------------------------------------- 1 | import path from "path"; 2 | import { runLLMTests } from "./demo-common-prompt"; 3 | 4 | const filePath = path.join(__dirname, "./prompts/chain_of_tought_leader.yaml"); 5 | 6 | // Execute the LLM Tests 7 | runLLMTests(filePath) 8 | .then(() => console.log("🎉 All LLM Tests executed successfully")) 9 | .catch((error) => 10 | console.error("❌ Error during LLM tests execution:", error), 11 | ); 12 | -------------------------------------------------------------------------------- /packages/qllm-samples/src/template-demos/demo-prompt.ts: -------------------------------------------------------------------------------- 1 | import path from "path"; 2 | import { runLLMTests } from "./demo-common-prompt"; 3 | 4 | const filePath = path.join(__dirname, "./prompts/create_story_no_var.yaml"); 5 | 6 | // Execute the LLM Tests 7 | runLLMTests(filePath) 8 | .then(() => console.log("🎉 All LLM Tests executed successfully")) 9 | .catch((error) => 10 | console.error("❌ Error during LLM tests execution:", error), 11 | ); 12 | -------------------------------------------------------------------------------- /packages/qllm-samples/src/template-demos/demo-template-loader.ts: -------------------------------------------------------------------------------- 1 | import * as path from "path"; 2 | import { TemplateLoader } from "qllm-lib"; 3 | import { TemplateDefinition } from "qllm-lib"; 4 | 5 | async function loadChainOfThoughtLeaderTemplate(): Promise { 6 | try { 7 | const templateLoader = new TemplateLoader(); 8 | const filePath = path.resolve( 9 | __dirname, 10 | "./prompts/chain_of_tought_leader.yaml", 11 | ); 12 | 13 | const templateDefinition = await TemplateLoader.load(filePath); 14 | 15 | console.log("Successfully loaded template:"); 16 | console.log(templateDefinition); 17 | 18 | return templateDefinition; 19 | } catch (error) { 20 | console.error("Error loading template:", error); 21 | throw error; 22 | } 23 | } 24 | 25 | // Execute the function 26 | loadChainOfThoughtLeaderTemplate() 27 | .then(() => console.log("Template loading complete")) 28 | .catch((error) => console.error("Template loading failed:", error)); 29 | -------------------------------------------------------------------------------- /packages/qllm-samples/src/template-workflow/demo_rag.ts: -------------------------------------------------------------------------------- 1 | import { RAGToolWithEmbedding } from 'qllm-lib'; 2 | import { writeFile } from 'fs/promises'; 3 | import path from 'path'; 4 | 5 | 6 | 7 | async function main(): Promise { 8 | console.log("\n🔍 Starting RAG Search Demo"); 9 | 10 | // Initialize the RAG tool 11 | const ragTool = new RAGToolWithEmbedding(); 12 | 13 | try { 14 | // Example 2: Using OpenAI embeddings 15 | console.log("\n📚 Running search with OpenAI embeddings..."); 16 | const resultOpenAI = await ragTool.execute({ 17 | directory: './docs', 18 | query: "Give me the main points discussed in my document, and improve them to have a better understanding of the topic, generate a full article", 19 | embedModel: "openai", 20 | topK: "5" 21 | }); 22 | 23 | console.log("resultOpenAI : ", resultOpenAI) 24 | 25 | // Save OpenAI results 26 | if (resultOpenAI.success) { 27 | await writeFile( 28 | 'results-openai.json', 29 | JSON.stringify(resultOpenAI, null, 2), 30 | 'utf-8' 31 | ); 32 | console.log("\n✅ OpenAI search results saved to results-openai.json"); 33 | console.log("Found sources:", resultOpenAI.sources.length); 34 | console.log("Response:", resultOpenAI.response); 35 | } else { 36 | console.error("❌ OpenAI search failed:", resultOpenAI.error); 37 | } 38 | 39 | // Print tool definition for reference 40 | console.log("\n📋 Tool Definition:"); 41 | console.log(JSON.stringify(ragTool.getDefinition(), null, 2)); 42 | 43 | } catch (error) { 44 | console.error("\n❌ Error:", error); 45 | throw error; 46 | } 47 | } 48 | 49 | // Run the demo with error handling 50 | main().catch((error) => { 51 | console.error("\n💥 Fatal Error:", error); 52 | process.exit(1); 53 | }); 54 | -------------------------------------------------------------------------------- /packages/qllm-samples/src/template-workflow/git.yaml: -------------------------------------------------------------------------------- 1 | name: github_doc_analysis 2 | description: Generate a story and create scene visualizations 3 | defaultProvider: openai 4 | steps: 5 | - tool: githubLoader 6 | name: "github donwloader" 7 | description: "bhyjnk,l;m" 8 | input: 9 | repositoryUrl: "{{input}}" 10 | authToken: "{{token}}" 11 | exclude: "{{exclude}}" 12 | include: "{{include}}" 13 | returnLocalPath: "{{returnLocalPath}}" 14 | cleanupDelay: "{{cleanupDelay}}" 15 | cleanupOnExit: "{{cleanupOnExit}}" 16 | output: template_content 17 | 18 | - tool: LlamaIndexRAGV1 19 | name: "analyze_files" 20 | description: "Analyze downloaded files using RAG" 21 | input: 22 | directory: "$template_content" 23 | query: "{{query}}" 24 | embedModel: "{{embedModel}}" 25 | topK: "{{topK}}" 26 | output: save_result -------------------------------------------------------------------------------- /packages/qllm-samples/src/template-workflow/test.yml: -------------------------------------------------------------------------------- 1 | name: s3_to_local 2 | description: Download file from S3 and save it to local 3 | defaultProvider: openai 4 | 5 | steps: 6 | - tool: s3ToLocal 7 | input: 8 | keys: "{{s3_keys}}" 9 | bucket_name: "{{s3_bucket}}" 10 | separator: "{{s3_separator}}" 11 | output: s3_files 12 | 13 | - templateUrl: https://github.com/novagen-conseil/qlstorage-test/blob/main/templates/fb156521-9b94-4937-acd0-8ce9cd6866c3/eabc7a8e-5415-4629-9542-2693b9e5beba/ai-story-generator.yaml 14 | provider: openai 15 | input: 16 | genre: "{{template_content}}" 17 | theme: "{{theme}}" 18 | word_count: "{{word_count}}" 19 | target_audience: "{{target_audience}}" 20 | output: 21 | story: generated_story 22 | story_elements: story_elements -------------------------------------------------------------------------------- /packages/qllm-samples/src/template-workflow/testTool.ts: -------------------------------------------------------------------------------- 1 | import { LocalProjectLoaderTool } from "qllm-lib"; 2 | import { writeFile } from 'fs/promises'; 3 | 4 | async function main(): Promise { 5 | console.log("\n🔍 Starting Local Project Analysis"); 6 | 7 | const localLoader = new LocalProjectLoaderTool({ 8 | excludeFolders: ['node_modules', '.git', 'dist', 'coverage'], 9 | excludeExtensions: ['.log', '.lock'] 10 | }); 11 | 12 | try { 13 | const result = await localLoader.execute({ 14 | projectPath: '/path/to/your/project', 15 | // Optional: additional excludes 16 | excludeFolders: ['temp', 'cache'], 17 | excludeExtensions: ['.env'] 18 | }); 19 | 20 | await writeFile('project-content.md', result.content, 'utf-8'); 21 | 22 | console.log(`\n✅ Project content saved to project-content.md`); 23 | console.log(`Processed ${result.fileCount} of ${result.totalFiles} files`); 24 | console.log('Excluded folders:', result.excludedFolders); 25 | console.log('Excluded extensions:', result.excludedExtensions); 26 | 27 | } catch (error) { 28 | console.error("\n❌ Error:", error); 29 | throw error; 30 | } 31 | } 32 | 33 | main().catch((error) => { 34 | console.error("\n💥 Fatal Error:", error); 35 | process.exit(1); 36 | }); -------------------------------------------------------------------------------- /packages/qllm-samples/src/template-workflow/workflow_jira.yaml: -------------------------------------------------------------------------------- 1 | name: jira_template_workflow 2 | version: '2.0' 3 | description: Generate and create Jira tickets from template 4 | defaultProvider: openai 5 | steps: 6 | - name: Generate Ticket Templates 7 | templateUrl: /home/yarab/Bureau/qllm/packages/qllm-samples/src/template-workflow/jira_template.yaml 8 | provider: openai 9 | input: 10 | project_key: "{{project_key}}" 11 | feature_name: "{{feature_name}}" 12 | feature_overview: "{{feature_overview}}" 13 | feature_requirements: "{{feature_requirements}}" 14 | technical_requirements: "{{technical_requirements}}" 15 | api_endpoints: "{{api_endpoints}}" 16 | test_scenarios: "{{test_scenarios}}" 17 | output: 18 | feature_tickets: feature_templates 19 | 20 | - tool: EnhancedJira 21 | input: 22 | operation: createFromTemplate 23 | templateJson: "$feature_templates" 24 | project_key: "{{project_key}}" 25 | feature_name: "{{feature_name}}" 26 | host: "{{host}}" 27 | email: "{{email}}" 28 | token: "{{token}}" 29 | output: 30 | feature_tickets: feature_tickets -------------------------------------------------------------------------------- /packages/qllm-samples/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "types": ["node"], 4 | "moduleResolution": "node", 5 | "esModuleInterop": true, 6 | "allowSyntheticDefaultImports": true, 7 | "target": "ES2020", 8 | "module": "commonjs", 9 | "forceConsistentCasingInFileNames": true, 10 | "strict": true, 11 | "skipLibCheck": true, 12 | "outDir": "dist", 13 | "declaration": true, 14 | "declarationMap": true, 15 | "sourceMap": true, 16 | "rootDir": "src", 17 | "rootDirs": ["types"] 18 | }, 19 | "include": ["src/**/*"], 20 | "exclude": ["node_modules", "dist"] 21 | } 22 | -------------------------------------------------------------------------------- /packages/sandbox-docker/example/nodejs-project/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:20 2 | WORKDIR /app 3 | COPY . . 4 | RUN npm install 5 | CMD ["node", "index.js"] -------------------------------------------------------------------------------- /packages/sandbox-docker/example/nodejs-project/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | app: 4 | build: . 5 | environment: 6 | - INPUT_VALUE=${INPUT_VALUE} 7 | volumes: 8 | - ./output:/app/output -------------------------------------------------------------------------------- /packages/sandbox-docker/example/nodejs-project/index.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | 3 | const inputValue = process.env.INPUT_VALUE || 'Default Value'; 4 | console.log(`Received input: ${inputValue}`); 5 | 6 | const output = `Processed: ${inputValue.toUpperCase()}`; 7 | fs.writeFileSync('/app/output/output.txt', output); 8 | 9 | console.log('Processing complete'); -------------------------------------------------------------------------------- /packages/sandbox-docker/example/nodejs-project/output/output.txt: -------------------------------------------------------------------------------- 1 | Processed: HELLO, FROM DOCKER! -------------------------------------------------------------------------------- /packages/sandbox-docker/example/nodejs-project/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "your-project-name", 3 | "version": "1.0.0", 4 | "dependencies": {} 5 | } -------------------------------------------------------------------------------- /packages/sandbox-docker/example/python-flask/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.9-slim 2 | WORKDIR /app 3 | COPY requirements.txt . 4 | RUN pip install --no-cache-dir -r requirements.txt 5 | COPY . . 6 | EXPOSE 8081 7 | CMD ["python", "app.py"] -------------------------------------------------------------------------------- /packages/sandbox-docker/example/python-flask/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask 2 | import os 3 | 4 | app = Flask(__name__) 5 | 6 | @app.route('/') 7 | def hello(): 8 | input_value = os.environ.get('INPUT_VALUE', 'Default Value') 9 | return f"Hello docker file from Flask! Input: {input_value}" 10 | 11 | if __name__ == '__main__': 12 | app.run(host='0.0.0.0', port=8081) -------------------------------------------------------------------------------- /packages/sandbox-docker/example/python-flask/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | web: 4 | build: . 5 | ports: 6 | - "8081:8081" 7 | environment: 8 | - INPUT_VALUE=${INPUT_VALUE} 9 | volumes: 10 | - ./output:/app/output -------------------------------------------------------------------------------- /packages/sandbox-docker/example/python-flask/requirements.txt: -------------------------------------------------------------------------------- 1 | Flask==2.2.5 2 | Werkzeug==3.0.3 -------------------------------------------------------------------------------- /packages/sandbox-docker/example/python-project/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.11-slim 2 | WORKDIR /app 3 | COPY requirements.txt . 4 | RUN pip install --no-cache-dir -r requirements.txt 5 | COPY . . 6 | RUN mkdir -p /app/output && chown -R 1000:1000 /app/output 7 | RUN useradd -m -u 1000 appuser 8 | USER appuser 9 | CMD ["python", "app.py"] -------------------------------------------------------------------------------- /packages/sandbox-docker/example/python-project/app.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | input_value = os.environ.get('INPUT_VALUE', 'default') 4 | result = f"Processed input: {input_value.upper()}" 5 | 6 | os.makedirs('/app/output', exist_ok=True) 7 | with open('/app/output/output.txt', 'w') as f: 8 | f.write(result) 9 | 10 | print(result) -------------------------------------------------------------------------------- /packages/sandbox-docker/example/python-project/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | web: 4 | build: . 5 | ports: 6 | - "5001:5000" 7 | environment: 8 | - INPUT_VALUE=${INPUT_VALUE} 9 | volumes: 10 | - ./output:/app/output -------------------------------------------------------------------------------- /packages/sandbox-docker/example/python-project/output/output.txt: -------------------------------------------------------------------------------- 1 | Processed input: HELLO DUDE ! -------------------------------------------------------------------------------- /packages/sandbox-docker/example/python-project/requirements.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quantalogic/qllm/ae2bf9d54883a2a9c522f278d9582d680d8ddbf9/packages/sandbox-docker/example/python-project/requirements.txt -------------------------------------------------------------------------------- /packages/sandbox-docker/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "secure-nodejs-code-enclave", 3 | "version": "1.0.0", 4 | "description": "A secure execution environment for untrusted JavaScript/TypeScript code", 5 | "main": "dist/test.js", 6 | "scripts": { 7 | "build": "tsc", 8 | "start": "node dist/test.js", 9 | "start_example": "node dist/test.js", 10 | "test:watch": "jest --watch", 11 | "test:coverage": "jest --coverage", 12 | "start:server": "node dist/test.js --server" 13 | }, 14 | "dependencies": { 15 | "@types/js-yaml": "^4.0.9", 16 | "@vitalets/google-translate-api": "^9.2.0", 17 | "axios": "^1.7.5", 18 | "body-parser": "^1.20.2", 19 | "dotenv": "^16.4.5", 20 | "escodegen": "^2.1.0", 21 | "esprima": "^4.0.1", 22 | "express": "^4.19.2", 23 | "js-yaml": "^4.1.0", 24 | "natural": "^8.0.1", 25 | "openai": "^4.56.1", 26 | "qllm-lib": "^3.2.1", 27 | "uuid": "^8.3.2", 28 | "vm2": "^3.9.11", 29 | "yaml": "^2.5.0", 30 | "yargs": "^17.5.1", 31 | "zod": "^3.23.8" 32 | }, 33 | "devDependencies": { 34 | "@types/body-parser": "^1.19.5", 35 | "@types/escodegen": "^0.0.10", 36 | "@types/esprima": "^4.0.6", 37 | "@types/express": "^4.17.21", 38 | "@types/jest": "^27.5.2", 39 | "@types/node": "^16.18.106", 40 | "@types/uuid": "^8.3.4", 41 | "@types/yargs": "^17.0.33", 42 | "jest": "^27.5.1", 43 | "ts-jest": "^27.1.5", 44 | "typescript": "^4.9.5" 45 | }, 46 | "jest": { 47 | "preset": "ts-jest", 48 | "testEnvironment": "node", 49 | "testMatch": [ 50 | "**/__tests__/**/*.ts", 51 | "**/?(*.)+(spec|test).ts" 52 | ] 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /packages/sandbox-docker/src/core/file-manager.ts: -------------------------------------------------------------------------------- 1 | import * as fs from 'fs/promises'; 2 | import * as path from 'path'; 3 | import { FileInput } from '../types'; 4 | 5 | export class FileManager { 6 | constructor(private tempDir: string) {} 7 | 8 | async writeFiles(files: FileInput[]): Promise { 9 | for (const file of files) { 10 | if (!this.validateFileName(file.name)) { 11 | throw new Error(`Invalid file name: ${file.name}`); 12 | } 13 | const filePath = path.join(this.tempDir, file.name); 14 | await fs.writeFile(filePath, file.content); 15 | } 16 | } 17 | 18 | async readFile(fileName: string): Promise { 19 | if (!this.validateFileName(fileName)) { 20 | throw new Error(`Invalid file name: ${fileName}`); 21 | } 22 | const filePath = path.join(this.tempDir, fileName); 23 | return fs.readFile(filePath, 'utf-8'); 24 | } 25 | 26 | validateFileName(fileName: string): boolean { 27 | const normalizedPath = path.normalize(fileName); 28 | return !normalizedPath.startsWith('..') && !path.isAbsolute(normalizedPath); 29 | } 30 | 31 | async listFiles(): Promise { 32 | return fs.readdir(this.tempDir); 33 | } 34 | 35 | async cleanup(): Promise { 36 | await fs.rm(this.tempDir, { recursive: true, force: true }); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /packages/sandbox-docker/src/core/virtual-fs.ts: -------------------------------------------------------------------------------- 1 | import * as fs from 'fs/promises'; 2 | import * as path from 'path'; 3 | 4 | export class VirtualFileSystem { 5 | constructor(private rootDir: string) {} 6 | 7 | async readFile(filePath: string): Promise { 8 | const fullPath = this.resolvePath(filePath); 9 | return fs.readFile(fullPath); 10 | } 11 | 12 | async writeFile(filePath: string, data: Buffer): Promise { 13 | const fullPath = this.resolvePath(filePath); 14 | await fs.writeFile(fullPath, data); 15 | } 16 | 17 | async exists(filePath: string): Promise { 18 | const fullPath = this.resolvePath(filePath); 19 | try { 20 | await fs.access(fullPath); 21 | return true; 22 | } catch { 23 | return false; 24 | } 25 | } 26 | 27 | async mkdir(dirPath: string): Promise { 28 | const fullPath = this.resolvePath(dirPath); 29 | await fs.mkdir(fullPath, { recursive: true }); 30 | } 31 | 32 | private resolvePath(filePath: string): string { 33 | const normalizedPath = path.normalize(filePath); 34 | if (normalizedPath.startsWith('..') || path.isAbsolute(normalizedPath)) { 35 | throw new Error('Access denied: Attempting to access outside of virtual file system'); 36 | } 37 | return path.join(this.rootDir, normalizedPath); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /packages/sandbox-docker/src/test.ts: -------------------------------------------------------------------------------- 1 | import { Enclave } from './core/enclave'; 2 | import { Logger } from './utils/logger'; 3 | 4 | async function runDockerProject(projectPath: string, inputValue: string) { 5 | const logger = new Logger({ debugMode: true }); 6 | logger.info(`Starting Docker project execution: ${projectPath}`); 7 | 8 | const enclave = new Enclave({ 9 | cacheDir: './cache', 10 | sandboxConfig: { rootDir: './sandbox' }, 11 | resourceLimits: { 12 | maxExecutionTime: 30000, 13 | maxMemory: 100 * 1024 * 1024, 14 | }, 15 | loggerConfig: { debugMode: true }, 16 | dockerConfig: { timeout: 300000 }, // 5 minutes, 17 | }); 18 | 19 | const params = { 20 | INPUT_VALUE: inputValue, 21 | }; 22 | 23 | try { 24 | logger.info(`Executing Docker project: ${projectPath}`); 25 | const { output, logs } = await enclave.executeDocker(projectPath, params); 26 | 27 | logger.info('Build and execution logs:'); 28 | console.log(logs); 29 | 30 | logger.info('Execution result:'); 31 | console.log(output); 32 | 33 | // Extract the port number from the logs (if applicable) 34 | const portMatch = logs.match(/Running on http:\/\/0\.0\.0\.0:(\d+)/); 35 | if (portMatch) { 36 | const port = portMatch[1]; 37 | logger.info(`Application is running on port ${port}`); 38 | } 39 | } catch (error) { 40 | logger.error('Execution failed:', error as Error); 41 | } finally { 42 | logger.info('Cleaning up enclave'); 43 | await enclave.cleanup(); 44 | } 45 | } 46 | 47 | // Usage 48 | runDockerProject('./example/nodejs-project', 'Hello, From docker!'); 49 | // python-project 50 | // nodejs-project 51 | // python-flask 52 | -------------------------------------------------------------------------------- /packages/sandbox-docker/src/types.ts: -------------------------------------------------------------------------------- 1 | 2 | export type ProjectType = 'python_flask' | 'nodejs_express'; 3 | 4 | export interface DockerConfig { 5 | // Add any Docker-specific configuration options here 6 | timeout: number; 7 | } 8 | 9 | export interface EnclaveConfig { 10 | cacheDir: string; 11 | sandboxConfig: SandboxConfig; 12 | resourceLimits: ResourceLimits; 13 | loggerConfig: LoggerConfig; 14 | dockerConfig: DockerConfig; 15 | } 16 | 17 | export interface FileInput { 18 | name: string; 19 | content: string; 20 | } 21 | 22 | export type EnclaveStatus = 'initialized' | 'preparing' | 'prepared' | 'executing' | 'completed' | 'cleaning' | 'cleaned' | 'error'; 23 | 24 | export interface SandboxConfig { 25 | rootDir: string; 26 | } 27 | 28 | export interface ResourceLimits { 29 | maxExecutionTime?: number; 30 | maxMemory?: number; 31 | } 32 | 33 | export interface ResourceUsageStats { 34 | executionTime: number; 35 | maxMemoryUsage: number; 36 | } 37 | 38 | export interface LoggerConfig { 39 | debugMode: boolean; 40 | } 41 | 42 | export interface DetailedError { 43 | message: string; 44 | stack?: string; 45 | type: string; 46 | code?: string; 47 | } -------------------------------------------------------------------------------- /packages/sandbox-docker/src/utils/error-handler.ts: -------------------------------------------------------------------------------- 1 | import { DetailedError } from '../types'; 2 | 3 | export class ErrorHandler { 4 | handleError(error: Error): DetailedError { 5 | const detailedError: DetailedError = { 6 | message: error.message, 7 | stack: error.stack, 8 | type: error.constructor.name, 9 | }; 10 | 11 | if (this.isEnclaveError(error)) { 12 | detailedError.code = (error as any).code; 13 | } 14 | 15 | return detailedError; 16 | } 17 | 18 | isEnclaveError(error: Error): boolean { 19 | return error instanceof Error && 'code' in error; 20 | } 21 | } -------------------------------------------------------------------------------- /packages/sandbox-docker/src/utils/logger.ts: -------------------------------------------------------------------------------- 1 | import * as fs from 'fs'; 2 | import * as path from 'path'; 3 | 4 | export class Logger { 5 | private logFile: string; 6 | 7 | constructor(private config: { debugMode: boolean }) { 8 | this.logFile = path.join(process.cwd(), 'enclave.log'); 9 | } 10 | 11 | private log(level: string, message: string, error?: Error) { 12 | const timestamp = new Date().toISOString(); 13 | const logMessage = `[${timestamp}] ${level}: ${message}`; 14 | 15 | console.log(logMessage); 16 | fs.appendFileSync(this.logFile, logMessage + '\n'); 17 | 18 | if (error && this.config.debugMode) { 19 | console.error(error); 20 | fs.appendFileSync(this.logFile, `${error.stack}\n`); 21 | } 22 | } 23 | 24 | info(message: string) { 25 | this.log('INFO', message); 26 | } 27 | 28 | warn(message: string) { 29 | this.log('WARN', message); 30 | } 31 | 32 | error(message: string, error?: Error) { 33 | this.log('ERROR', message, error); 34 | } 35 | 36 | debug(message: string) { 37 | if (this.config.debugMode) { 38 | this.log('DEBUG', message); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /packages/sandbox-docker/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "module": "commonjs", 5 | "outDir": "./dist", 6 | "rootDir": "./src", 7 | "strict": true, 8 | "esModuleInterop": true, 9 | "skipLibCheck": true, 10 | "forceConsistentCasingInFileNames": true 11 | }, 12 | "include": ["src/**/*"], 13 | "exclude": ["node_modules", "**/*.test.ts"] 14 | } -------------------------------------------------------------------------------- /packages/sandbox/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:20-alpine 2 | WORKDIR /app 3 | COPY package*.json ./ 4 | RUN npm ci --only=production 5 | COPY dist ./dist 6 | CMD ["node", "dist/index.js"] -------------------------------------------------------------------------------- /packages/sandbox/examples/tools/code_generator.json: -------------------------------------------------------------------------------- 1 | { 2 | "tool": "python-code-generator", 3 | "params": { 4 | "language": "Python", 5 | "task_description": "🐍 Generate a snake game", 6 | "requirements": "🍎 The game should have a snake that moves around the screen and eats food" 7 | } 8 | } -------------------------------------------------------------------------------- /packages/sandbox/examples/tools/text-summerize.json: -------------------------------------------------------------------------------- 1 | { 2 | "tool": "text-summerizer", 3 | "params": { 4 | "file_url": "https://www.quantalogic.app/blogs/introduction", 5 | "max_words": 150 6 | } 7 | } -------------------------------------------------------------------------------- /packages/sandbox/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'ts-jest', 3 | testEnvironment: 'node', 4 | roots: ['/src'], 5 | testMatch: ['**/__tests__/**/*.ts', '**/?(*.)+(spec|test).ts'], 6 | moduleFileExtensions: ['ts', 'js', 'json', 'node'], 7 | }; -------------------------------------------------------------------------------- /packages/sandbox/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "secure-nodejs-code-enclave", 3 | "version": "1.0.0", 4 | "description": "A secure execution environment for untrusted JavaScript/TypeScript code", 5 | "main": "dist/index.js", 6 | "scripts": { 7 | "build": "tsc", 8 | "start": "node dist/index.js", 9 | "start_example": "node dist/index_example.js", 10 | "start:server": "node dist/index.js --server" 11 | }, 12 | "dependencies": { 13 | "@types/js-yaml": "^4.0.9", 14 | "@vitalets/google-translate-api": "^9.2.0", 15 | "axios": "^1.7.5", 16 | "body-parser": "^1.20.2", 17 | "dotenv": "^16.4.5", 18 | "escodegen": "^2.1.0", 19 | "esprima": "^4.0.1", 20 | "express": "^4.19.2", 21 | "js-yaml": "^4.1.0", 22 | "natural": "^8.0.1", 23 | "openai": "^4.56.1", 24 | "qllm-lib": "^3.2.1", 25 | "uuid": "^8.3.2", 26 | "vm2": "^3.9.11", 27 | "yaml": "^2.5.0", 28 | "yargs": "^17.5.1", 29 | "zod": "^3.23.8" 30 | }, 31 | "devDependencies": { 32 | "@types/body-parser": "^1.19.5", 33 | "@types/escodegen": "^0.0.10", 34 | "@types/esprima": "^4.0.6", 35 | "@types/express": "^4.17.21", 36 | "@types/jest": "^27.5.2", 37 | "@types/node": "^16.18.106", 38 | "@types/uuid": "^8.3.4", 39 | "@types/yargs": "^17.0.33", 40 | "jest": "^27.5.1", 41 | "ts-jest": "^27.1.5", 42 | "typescript": "^4.9.5" 43 | }, 44 | "jest": { 45 | "preset": "ts-jest", 46 | "testEnvironment": "node", 47 | "testMatch": [ 48 | "**/__tests__/**/*.ts", 49 | "**/?(*.)+(spec|test).ts" 50 | ] 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /packages/sandbox/src/__tests__/enclave.test.ts: -------------------------------------------------------------------------------- 1 | import { Enclave } from '../../src/core/enclave'; 2 | import { EnclaveConfig } from '../../src/types'; 3 | 4 | jest.setTimeout(30000); // Increase global timeout to 30 seconds 5 | 6 | describe('Enclave', () => { 7 | let enclave: Enclave; 8 | const mockConfig: EnclaveConfig = { 9 | cacheDir: './test-cache', 10 | sandboxConfig: { rootDir: './test-sandbox' }, 11 | resourceLimits: { maxExecutionTime: 1000, maxMemory: 10 * 1024 * 1024 }, 12 | loggerConfig: { debugMode: false } 13 | }; 14 | 15 | beforeEach(() => { 16 | enclave = new Enclave(mockConfig); 17 | }); 18 | 19 | afterEach(async () => { 20 | await enclave.cleanup(); 21 | }); 22 | 23 | test('should initialize with correct status', () => { 24 | expect(enclave.getStatus()).toBe('initialized'); 25 | }); 26 | 27 | test('should prepare files and packages', async () => { 28 | const files = [{ name: 'test.js', content: 'console.log("Hello");' }]; 29 | const packages = ['lodash']; 30 | 31 | await enclave.prepare(files, packages); 32 | expect(enclave.getStatus()).toBe('prepared'); 33 | }, 30000); // Increase timeout for this specific test to 30 seconds 34 | 35 | test('should execute code', async () => { 36 | const files = [{ name: 'test.js', content: '__lastExpression = 2 + 2;' }]; 37 | await enclave.prepare(files, []); 38 | const result = await enclave.execute('test.js'); 39 | expect(result).toBe(4); 40 | }); 41 | }); -------------------------------------------------------------------------------- /packages/sandbox/src/__tests__/file-manager.test.ts: -------------------------------------------------------------------------------- 1 | import { FileManager } from '../core/file-manager'; 2 | import * as fs from 'fs/promises'; 3 | import * as path from 'path'; 4 | 5 | describe('FileManager', () => { 6 | let fileManager: FileManager; 7 | const tempDir = './test-temp'; 8 | 9 | beforeEach(() => { 10 | fileManager = new FileManager(tempDir); 11 | }); 12 | 13 | afterEach(async () => { 14 | await fs.rm(tempDir, { recursive: true, force: true }); 15 | }); 16 | 17 | test('should write and read file', async () => { 18 | const fileName = 'test.js'; 19 | const content = 'console.log("Hello");'; 20 | 21 | await fileManager.writeFile(fileName, content); 22 | const readContent = await fileManager.readFile(fileName); 23 | 24 | expect(readContent).toBe(content); 25 | }); 26 | }); -------------------------------------------------------------------------------- /packages/sandbox/src/__tests__/package-manager.test.ts: -------------------------------------------------------------------------------- 1 | import { PackageManager } from '../core/package-manager'; 2 | import * as fs from 'fs/promises'; 3 | import * as path from 'path'; 4 | 5 | describe('PackageManager', () => { 6 | let packageManager: PackageManager; 7 | const tempDir = './test-temp'; 8 | const cacheDir = './test-cache'; 9 | 10 | beforeEach(() => { 11 | packageManager = new PackageManager(tempDir, cacheDir); 12 | }); 13 | 14 | afterEach(async () => { 15 | await fs.rm(tempDir, { recursive: true, force: true }); 16 | await fs.rm(cacheDir, { recursive: true, force: true }); 17 | }); 18 | 19 | test('should resolve package versions', async () => { 20 | const packages = ['lodash']; 21 | const versions = await packageManager.resolvePackageVersions(packages); 22 | expect(versions).toHaveProperty('lodash'); 23 | expect(typeof versions.lodash).toBe('string'); 24 | }, 30000); // Add timeout here as well 25 | }); -------------------------------------------------------------------------------- /packages/sandbox/src/__tests__/sandbox.test.ts: -------------------------------------------------------------------------------- 1 | import { Sandbox } from '../../src/security/sandbox'; 2 | import { SandboxConfig } from '../../src/types'; 3 | 4 | describe('Sandbox', () => { 5 | let sandbox: Sandbox; 6 | 7 | beforeEach(() => { 8 | const config: SandboxConfig = { rootDir: './test-sandbox' }; 9 | sandbox = new Sandbox(config, './test-temp'); 10 | }); 11 | 12 | test('should run code in sandbox', async () => { 13 | const result = await sandbox.run('__lastExpression = 2 + 2'); 14 | expect(result).toBe(4); 15 | }); 16 | 17 | test('should handle multi-line code', async () => { 18 | const code = ` 19 | let x = 10; 20 | let y = 20; 21 | __lastExpression = x + y; 22 | `; 23 | const result = await sandbox.run(code); 24 | expect(result).toBe(30); 25 | }); 26 | 27 | test('should handle async code', async () => { 28 | const code = ` 29 | async function test() { 30 | return new Promise(resolve => setTimeout(() => resolve(42), 100)); 31 | } 32 | __lastExpression = await test(); 33 | `; 34 | const result = await sandbox.run(code); 35 | expect(result).toBe(42); 36 | }); 37 | }); -------------------------------------------------------------------------------- /packages/sandbox/src/index.ts: -------------------------------------------------------------------------------- 1 | // Import necessary modules and components 2 | import { Enclave } from './core/enclave'; 3 | import { TextSummerize } from './ai-tools/text-summerize'; 4 | import { CodeGenerator } from './ai-tools/code-generator'; 5 | import dotenv from 'dotenv'; 6 | import { getFileInputs } from "./utils/tools"; 7 | import { parseArguments } from "./utils/parse_argument" 8 | import { processToolSchemas } from "./utils/process_tool_schema" 9 | 10 | // Load environment variables from .env file 11 | dotenv.config(); 12 | 13 | /** 14 | * Main function to execute the sandbox environment 15 | * @async 16 | */ 17 | async function executeSandbox() { 18 | // Parse command-line arguments 19 | const argv = await parseArguments(); 20 | 21 | // Get file inputs based on parsed arguments 22 | const fileInputs = await getFileInputs(argv); 23 | 24 | // Initialize the Enclave with configuration 25 | const enclave = new Enclave({ 26 | cacheDir: './cache', // Directory for caching 27 | sandboxConfig: { rootDir: './sandbox' }, // Sandbox root directory 28 | resourceLimits: { 29 | maxExecutionTime: 5000, // Maximum execution time in milliseconds 30 | maxMemory: 100 * 1024 * 1024 // Maximum memory usage in bytes (100 MB) 31 | }, 32 | loggerConfig: { debugMode: true } // Enable debug logging 33 | }); 34 | 35 | // Register AI tools with the Enclave 36 | enclave.registerAITool(TextSummerize); 37 | enclave.registerAITool(CodeGenerator); 38 | 39 | try { 40 | // Prepare the Enclave with file inputs 41 | // await enclave.prepare(fileInputs, []); 42 | 43 | // Process each input file 44 | for (const file of fileInputs) { 45 | await processToolSchemas(enclave, file); 46 | } 47 | } catch (error) { 48 | // Log any errors that occur during execution 49 | console.error('Execution failed:', error); 50 | } finally { 51 | // Ensure cleanup of Enclave resources, regardless of success or failure 52 | await enclave.cleanup(); 53 | } 54 | } 55 | 56 | // Execute the sandbox and catch any unhandled errors 57 | executeSandbox().catch(console.error); -------------------------------------------------------------------------------- /packages/sandbox/src/security/sandbox.ts: -------------------------------------------------------------------------------- 1 | import { NodeVM } from 'vm2'; 2 | import { SandboxConfig } from '../types'; 3 | import * as path from 'path'; 4 | 5 | /** 6 | * Sandbox class for executing code in a controlled environment 7 | */ 8 | export class Sandbox { 9 | private vm: NodeVM; 10 | 11 | /** 12 | * Creates a new Sandbox instance 13 | * @param {SandboxConfig} config - Configuration for the sandbox 14 | * @param {string} tempDir - Temporary directory for the sandbox 15 | */ 16 | constructor(config: SandboxConfig, private tempDir: string) { 17 | this.vm = new NodeVM({ 18 | console: 'inherit', // Inherit console from the parent process 19 | sandbox: {}, // Empty sandbox object 20 | require: { 21 | external: true, // Allow requiring external modules 22 | builtin: ['fs', 'path'], // Allow specific built-in modules 23 | root: this.tempDir, // Set root directory for requires 24 | resolve: (moduleName: string) => { 25 | // Custom module resolution 26 | return require.resolve(moduleName, { paths: [this.tempDir] }); 27 | }, 28 | }, 29 | nesting: false, // Disable VM nesting 30 | wrapper: 'commonjs', // Use CommonJS module system 31 | }); 32 | } 33 | 34 | /** 35 | * Runs code in the sandbox 36 | * @param {string} code - The code to run 37 | * @param {string} filename - The filename to associate with the code 38 | * @returns {Promise} The result of the code execution 39 | */ 40 | async run(code: string, filename: string): Promise { 41 | const fullPath = path.join(this.tempDir, filename); 42 | const dirName = path.dirname(fullPath); 43 | 44 | // Inject __filename and __dirname into the sandbox without redeclaring 45 | this.vm.freeze({ __filename: fullPath, __dirname: dirName }, '__sandbox_scope__'); 46 | 47 | return this.vm.run(code, fullPath); 48 | } 49 | 50 | /** 51 | * Injects global variables into the sandbox 52 | * @param {Record} globals - Object containing global variables to inject 53 | */ 54 | injectGlobals(globals: Record): void { 55 | Object.assign(this.vm.sandbox, globals); 56 | } 57 | } -------------------------------------------------------------------------------- /packages/sandbox/src/templates/code_generator.yaml: -------------------------------------------------------------------------------- 1 | name: '🌈 Multi-Language Code Generator' 2 | version: '3.0.0' 3 | description: '🚀 Generate code snippets in various programming languages' 4 | author: '🤖 CodeMaster AI' 5 | content: | 6 | Generate a {{language}} code snippet that accomplishes the following task: 7 | {{task_description}} 8 | Requirements: 9 | {{requirements}} 10 | Important: Wrap the generated code in an XML tag named . 11 | Generated Code: 12 | 13 | inputVariables: 14 | - name: language 15 | type: string 16 | description: '🗣️ The programming language to generate code in' 17 | - name: task_description 18 | type: string 19 | description: '📝 Description of the coding task' 20 | - name: requirements 21 | type: string 22 | description: '📋 Specific requirements for the code' 23 | 24 | outputVariables: 25 | - name: code 26 | type: string 27 | description: '💻 The generated code snippet' 28 | 29 | tags: 30 | - '💡 programming' 31 | - '🔧 code generation' 32 | - '🌐 multi-language' 33 | 34 | categories: 35 | - '🖥️ Software Development' 36 | - '🤖 AI-Assisted Coding' 37 | 38 | model: 'gpt-4o-mini' 39 | 40 | parameters: 41 | max_tokens: 1200 42 | temperature: 0.7 43 | top_p: 0.95 44 | 45 | promptType: '🧠 code_generation' 46 | 47 | taskDescription: '🎯 Generate code snippets in various programming languages based on user requirements' 48 | 49 | exampleOutputs: | 50 | 51 | def fibonacci(n): 52 | if n <= 1: 53 | return n 54 | else: 55 | return fibonacci(n-1) + fibonacci(n-2) 56 | -------------------------------------------------------------------------------- /packages/sandbox/src/templates/text-summerize.yaml: -------------------------------------------------------------------------------- 1 | name: '📄 URL Document Summarizer' 2 | version: '1.0.0' 3 | description: '🚀 Summarize documents from a given URL' 4 | author: '🤖 SummarizerAI' 5 | content: | 6 | ## Summarize the following document: 7 | 8 | 9 | {{include: {{file_url}} }} 10 | 11 | 12 | Requirements: 13 | - Provide a concise summary of the main points 14 | - Highlight key insights or findings 15 | - Keep the summary within {{max_words}} words 16 | - Write the summary in tags 17 | 18 | ## Format the output as follows: 19 | 20 | Your reflections on the document 21 | 22 | The content of the summary 23 | 24 | END. 25 | inputVariables: 26 | - name: file_url 27 | type: string 28 | description: '🔗 The URL of the document to summarize' 29 | - name: max_words 30 | type: number 31 | description: '📏 Maximum number of words for the summary' 32 | outputVariables: 33 | - name: summary 34 | type: string 35 | description: '📝 The generated summary of the document' 36 | tags: 37 | - '📚 document analysis' 38 | - '🔍 summarization' 39 | - '🌐 web content' 40 | categories: 41 | - '📊 Information Processing' 42 | - '🤖 AI-Assisted Analysis' 43 | model: 'gpt-4' 44 | parameters: 45 | max_tokens: 500 46 | temperature: 0.5 47 | top_p: 0.9 48 | promptType: '🧠 text_summarization' 49 | taskDescription: '🎯 Generate concise summaries of documents from provided URLs' -------------------------------------------------------------------------------- /packages/sandbox/src/types.ts: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Interface for AI tools 4 | * @template TParams Type of parameters the tool accepts 5 | * @template TResult Type of result the tool produces 6 | */ 7 | export interface AITool { 8 | name: string; 9 | description: string; 10 | execute: (params: TParams) => Promise; 11 | } 12 | 13 | /** 14 | * Interface for tool schema 15 | * @template TParams Type of parameters the tool accepts 16 | */ 17 | export interface ToolSchema { 18 | tool: string; 19 | params: TParams; 20 | } 21 | 22 | /** 23 | * Interface for Enclave configuration 24 | */ 25 | export interface EnclaveConfig { 26 | cacheDir: string; 27 | sandboxConfig: SandboxConfig; 28 | resourceLimits: ResourceLimits; 29 | loggerConfig: LoggerConfig; 30 | } 31 | 32 | /** 33 | * Interface for file input 34 | */ 35 | export interface FileInput { 36 | name: string; 37 | content: string; 38 | } 39 | 40 | /** 41 | * Type for Enclave status 42 | */ 43 | export type EnclaveStatus = 'initialized' | 'preparing' | 'prepared' | 'executing' | 'completed' | 'cleaning' | 'cleaned' | 'error'; 44 | 45 | /** 46 | * Interface for sandbox configuration 47 | */ 48 | export interface SandboxConfig { 49 | rootDir: string; 50 | } 51 | 52 | /** 53 | * Interface for resource limits 54 | */ 55 | export interface ResourceLimits { 56 | maxExecutionTime?: number; 57 | maxMemory?: number; 58 | } 59 | 60 | /** 61 | * Interface for resource usage statistics 62 | */ 63 | export interface ResourceUsageStats { 64 | executionTime: number; 65 | maxMemoryUsage: number; 66 | } 67 | 68 | /** 69 | * Interface for logger configuration 70 | */ 71 | export interface LoggerConfig { 72 | debugMode: boolean; 73 | } 74 | 75 | /** 76 | * Type for Enclave error codes 77 | */ 78 | export type EnclaveErrorCode = 'RESOURCE_LIMIT_EXCEEDED' | 'ACCESS_DENIED' | 'SYNTAX_ERROR' | 'TYPE_ERROR' | 'UNKNOWN_ERROR'; 79 | 80 | /** 81 | * Interface for detailed error information 82 | */ 83 | export interface DetailedError { 84 | message: string; 85 | stack?: string; 86 | type: string; 87 | code: EnclaveErrorCode; 88 | timestamp: string; 89 | } -------------------------------------------------------------------------------- /packages/sandbox/src/utils/error-handler.ts: -------------------------------------------------------------------------------- 1 | import { DetailedError, EnclaveErrorCode } from '../types'; 2 | 3 | export class ErrorHandler { 4 | handleError(error: Error): DetailedError { 5 | const detailedError: DetailedError = { 6 | message: error.message, 7 | stack: error.stack, 8 | type: error.constructor.name, 9 | code: this.getErrorCode(error), 10 | timestamp: new Date().toISOString() 11 | }; 12 | return detailedError; 13 | } 14 | 15 | private getErrorCode(error: Error): EnclaveErrorCode { 16 | if (error instanceof RangeError) return 'RESOURCE_LIMIT_EXCEEDED'; 17 | if (error instanceof TypeError) return 'TYPE_ERROR'; 18 | if (error instanceof SyntaxError) return 'SYNTAX_ERROR'; 19 | if (error.message.includes('Access denied')) return 'ACCESS_DENIED'; 20 | return 'UNKNOWN_ERROR'; 21 | } 22 | 23 | isEnclaveError(error: Error): boolean { 24 | return error instanceof Error && 'code' in error; 25 | } 26 | } 27 | 28 | export class EnclaveError extends Error { 29 | constructor(message: string, public code: string) { 30 | super(message); 31 | this.name = 'EnclaveError'; 32 | } 33 | } 34 | 35 | /** 36 | * Custom error for when an AI tool is not found 37 | */ 38 | export class AIToolNotFoundError extends EnclaveError { 39 | constructor(toolName: string) { 40 | super(`AI Tool '${toolName}' not found`, 'UNKNOWN_ERROR'); 41 | } 42 | } 43 | 44 | /** 45 | * Custom error for invalid parameters 46 | */ 47 | export class InvalidParametersError extends EnclaveError { 48 | constructor(toolName: string, errors: string[]) { 49 | super(`Invalid parameters for tool '${toolName}': ${errors.join(', ')}`, 'TYPE_ERROR'); 50 | } 51 | } -------------------------------------------------------------------------------- /packages/sandbox/src/utils/execute_tool_schema.ts: -------------------------------------------------------------------------------- 1 | import { Enclave } from '../core/enclave'; 2 | import { ToolSchema } from '../types'; 3 | import { z } from 'zod'; 4 | 5 | /** 6 | * Executes a single tool schema using the provided Enclave 7 | * @param {Enclave} enclave - The Enclave instance to use for execution 8 | * @param {ToolSchema} schema - The tool schema to execute 9 | * @param {string} fileName - The name of the file containing the schema 10 | * @returns {Promise} 11 | */ 12 | export async function executeToolSchema(enclave: Enclave, schema: ToolSchema, fileName: string) { 13 | try { 14 | // Execute the AI tool with the given schema 15 | const result = await enclave.executeAITool(schema); 16 | 17 | // Log the result 18 | console.log(`\nResult for ${schema.tool}:`, JSON.stringify(result, null, 2)); 19 | } catch (error) { 20 | if (error instanceof z.ZodError) { 21 | // Handle Zod validation errors 22 | console.error(`Validation error for ${schema.tool} in ${fileName}:`, error.errors); 23 | } else { 24 | // Handle other types of errors 25 | console.error(`Error executing ${schema.tool} in ${fileName}:`, error); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /packages/sandbox/src/utils/logger.ts: -------------------------------------------------------------------------------- 1 | import * as fs from 'fs'; 2 | import * as path from 'path'; 3 | import { LoggerConfig } from '../types'; 4 | 5 | export class Logger { 6 | private logFile: string; 7 | 8 | constructor(private config: LoggerConfig) { 9 | this.logFile = path.join(process.cwd(), 'enclave.log'); 10 | } 11 | 12 | info(message: string): void { 13 | this.log('INFO', message); 14 | } 15 | 16 | warn(message: string): void { 17 | this.log('WARN', message); 18 | } 19 | 20 | error(message: string, error?: Error): void { 21 | this.log('ERROR', message, error); 22 | } 23 | 24 | debug(message: string): void { 25 | if (this.config.debugMode) { 26 | this.log('DEBUG', message); 27 | } 28 | } 29 | 30 | private log(level: string, message: string, error?: Error): void { 31 | const timestamp = new Date().toISOString(); 32 | const logMessage = `[${timestamp}] ${level}: ${message}`; 33 | console.log(logMessage); 34 | 35 | if (error) { 36 | console.error(error); 37 | } 38 | 39 | fs.appendFileSync(this.logFile, logMessage + '\n'); 40 | if (error) { 41 | fs.appendFileSync(this.logFile, error.stack + '\n'); 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /packages/sandbox/src/utils/parse_argument.ts: -------------------------------------------------------------------------------- 1 | import yargs from 'yargs'; 2 | import { hideBin } from 'yargs/helpers'; 3 | 4 | /** 5 | * Parses command-line arguments using yargs 6 | * @returns {Promise} A promise that resolves to the parsed arguments 7 | */ 8 | export async function parseArguments() { 9 | return yargs(hideBin(process.argv)) 10 | // Define 'file' option 11 | .option('f', { 12 | alias: 'file', 13 | describe: 'Files to execute', 14 | type: 'array' 15 | }) 16 | // Define 'dir' option 17 | .option('dir', { 18 | describe: 'Directory containing files to execute', 19 | type: 'string' 20 | }) 21 | // Add a check to ensure either 'file' or 'dir' is specified 22 | .check(argv => { 23 | if (!argv.f && !argv.dir) { 24 | throw new Error('Either --file or --dir must be specified'); 25 | } 26 | return true; 27 | }) 28 | .argv; 29 | } -------------------------------------------------------------------------------- /packages/sandbox/src/utils/process_tool_schema.ts: -------------------------------------------------------------------------------- 1 | import { Enclave } from '../core/enclave'; 2 | import { ToolSchema, FileInput } from '../types'; 3 | import { executeToolSchema } from "./execute_tool_schema"; 4 | 5 | /** 6 | * Processes tool schemas from a given file input 7 | * @param {Enclave} enclave - The Enclave instance to use for execution 8 | * @param {FileInput} file - The file input containing tool schemas 9 | * @returns {Promise} 10 | */ 11 | export async function processToolSchemas(enclave: Enclave, file: FileInput) { 12 | console.log(`Executing ${file.name}:`); 13 | let toolSchemas: ToolSchema | ToolSchema[]; 14 | 15 | // Attempt to parse the file content as JSON 16 | try { 17 | toolSchemas = JSON.parse(file.content); 18 | } catch (error) { 19 | console.error(`Error parsing JSON in file ${file.name}:`, error); 20 | return; 21 | } 22 | 23 | // Process the parsed schemas 24 | if (Array.isArray(toolSchemas)) { 25 | // If it's an array of schemas, execute each one 26 | for (const schema of toolSchemas) { 27 | await executeToolSchema(enclave, schema, file.name); 28 | } 29 | } else if (typeof toolSchemas === 'object' && toolSchemas !== null) { 30 | // If it's a single schema object, execute it 31 | await executeToolSchema(enclave, toolSchemas, file.name); 32 | } else { 33 | // If it's neither an array nor an object, log an error 34 | console.error(`Invalid schema in file ${file.name}`); 35 | } 36 | console.log('---'); // Print a separator after processing each file 37 | } -------------------------------------------------------------------------------- /packages/sandbox/src/utils/tools.ts: -------------------------------------------------------------------------------- 1 | import { readFileSync, readdirSync } from 'fs'; 2 | import path from 'path'; 3 | import { FileInput } from '../types'; 4 | 5 | /** 6 | * Recursively retrieves all files from a directory and its subdirectories 7 | * @param {string} dir - The directory path to start from 8 | * @returns {Promise} A promise that resolves to an array of FileInput objects 9 | */ 10 | export async function getFilesFromDirectory(dir: string): Promise { 11 | const files: FileInput[] = []; 12 | // Read the contents of the directory 13 | const entries = readdirSync(dir, { withFileTypes: true }); 14 | 15 | for (const entry of entries) { 16 | const fullPath = path.join(dir, entry.name); 17 | if (entry.isDirectory()) { 18 | // If it's a directory, recursively call the function 19 | files.push(...await getFilesFromDirectory(fullPath)); 20 | } else if (entry.isFile() && entry.name !== 'package.json') { 21 | // If it's a file (excluding package.json), add it to the files array 22 | files.push({ 23 | name: path.relative(dir, fullPath), 24 | content: readFileSync(fullPath, 'utf-8') 25 | }); 26 | } 27 | } 28 | return files; 29 | } 30 | 31 | /** 32 | * Retrieves file inputs based on command-line arguments 33 | * @param {any} argv - The parsed command-line arguments 34 | * @returns {Promise} A promise that resolves to an array of FileInput objects 35 | */ 36 | export async function getFileInputs(argv: any): Promise { 37 | if (argv.f) { 38 | // If individual files are specified 39 | return argv.f.map((f: string) => ({ 40 | name: path.basename(f), 41 | content: readFileSync(path.resolve(f), 'utf-8') 42 | })); 43 | } 44 | // If a directory is specified 45 | return getFilesFromDirectory(path.resolve(argv.dir)); 46 | } -------------------------------------------------------------------------------- /packages/sandbox/test.js: -------------------------------------------------------------------------------- 1 | __lastExpression = 2 + 2; -------------------------------------------------------------------------------- /packages/sandbox/test/integration/enclave-workflow.test.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quantalogic/qllm/ae2bf9d54883a2a9c522f278d9582d680d8ddbf9/packages/sandbox/test/integration/enclave-workflow.test.ts -------------------------------------------------------------------------------- /packages/sandbox/test/security/sandbox-escape.test.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quantalogic/qllm/ae2bf9d54883a2a9c522f278d9582d680d8ddbf9/packages/sandbox/test/security/sandbox-escape.test.ts -------------------------------------------------------------------------------- /packages/sandbox/test/unit/enclave.test.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quantalogic/qllm/ae2bf9d54883a2a9c522f278d9582d680d8ddbf9/packages/sandbox/test/unit/enclave.test.ts -------------------------------------------------------------------------------- /packages/sandbox/test/unit/file-manager.test.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quantalogic/qllm/ae2bf9d54883a2a9c522f278d9582d680d8ddbf9/packages/sandbox/test/unit/file-manager.test.ts -------------------------------------------------------------------------------- /packages/sandbox/test/unit/package-manager.test.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quantalogic/qllm/ae2bf9d54883a2a9c522f278d9582d680d8ddbf9/packages/sandbox/test/unit/package-manager.test.ts -------------------------------------------------------------------------------- /packages/sandbox/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "module": "commonjs", 5 | "outDir": "./dist", 6 | "rootDir": "./src", 7 | "strict": true, 8 | "esModuleInterop": true, 9 | "skipLibCheck": true, 10 | "forceConsistentCasingInFileNames": true 11 | }, 12 | "include": ["src/**/*"], 13 | "exclude": ["node_modules", "**/*.test.ts"] 14 | } -------------------------------------------------------------------------------- /pnpm-workspace.yaml: -------------------------------------------------------------------------------- 1 | 2 | packages: 3 | - 'packages/*' 4 | - 'packages/**' -------------------------------------------------------------------------------- /prompts/common/role.md: -------------------------------------------------------------------------------- 1 | ## Your role 2 | 3 | You are {{role}} -------------------------------------------------------------------------------- /prompts/common/story.md: -------------------------------------------------------------------------------- 1 | ## Your role 2 | {{include:role.md}} 3 | 4 | ## Your task 5 | 6 | Write a {{genre}} story about {{subject}} 7 | 8 | Use {{lang}} to write the story. 9 | 10 | ## OUTPUT example 11 | 12 | ```xml 13 | 14 | 15 | ... the story formatted using Markdown. . Length {{max_length}} words ... 16 | 17 | 18 | ``` 19 | -------------------------------------------------------------------------------- /prompts/create_story.yaml: -------------------------------------------------------------------------------- 1 | name: create_story 2 | version: '1.0' 3 | description: Create a nice story 4 | author: Raphaël MANSUY 5 | #provider: ollama 6 | #model: mistral 7 | input_variables: 8 | subject: 9 | type: string 10 | description: The subject of the story 11 | place_holder: "Emmanuel Macron dissout l'assemblée" 12 | genre: 13 | type: string 14 | description: The genre of the story 15 | place_holder: "Humour et satire" 16 | role: 17 | type: string 18 | description: The role of the user 19 | place_holder: "Gaspar PROUST" 20 | lang: 21 | type: string 22 | description: The language of the story 23 | place_holder: "Français" 24 | max_length: 25 | type: number 26 | description: The maximum length of the story 27 | default: 1000 28 | output_variables: 29 | story: 30 | type: string 31 | description: The story 32 | 33 | content: > 34 | {{include: common/story.md }} 35 | 36 | -------------------------------------------------------------------------------- /prompts/improve.yaml: -------------------------------------------------------------------------------- 1 | name: improve 2 | version: 1.0.0 3 | description: Improve a prompt 4 | author: Raphaël MANSUY 5 | provider: anthropic 6 | model: sonnet35 7 | content: '' 8 | -------------------------------------------------------------------------------- /prompts/improve_prompt.yaml: -------------------------------------------------------------------------------- 1 | name: improve_prompt 2 | version: '1.0' 3 | description: Improve a prompt 4 | author: Raphaël MANSUY 5 | max_tokens: 4096 6 | input_variables: 7 | prompt: 8 | type: string 9 | description: The prompt to improve 10 | place_holder: "" 11 | output_variables: 12 | prompt_final: 13 | type: string 14 | description: The improved prompt 15 | content: > 16 | {{include:common/improve_prompt.md}} -------------------------------------------------------------------------------- /prompts/pirate.yaml: -------------------------------------------------------------------------------- 1 | name: pirate 2 | version: '1.0' 3 | description: You answer as a pirate 4 | author: Raphaël MANSUY 5 | provider: openai 6 | model: gpt-4o-mini 7 | parameters: 8 | system_message: > 9 | You are a pirate. You are a nice pirate. You are a very nice pirate. 10 | content: > 11 | Give a greeting to the user. Who are you ? 12 | 13 | -------------------------------------------------------------------------------- /prompts/software/create_bruno_collection.yaml: -------------------------------------------------------------------------------- 1 | name: create_bruno_collection 2 | version: '1.0' 3 | description: Create a Bruno collection for a project from a swagger file 4 | author: Raphaël MANSUY 5 | system_prompt: > 6 | You are a senior expert in API testing and you are tasked with creating a Bruno collection for a project from a swagger file. 7 | Your mission is very important as it can make the difference between the success and the failure of the project and avoid a catastrophe. 8 | input_variables: 9 | swagger_file: 10 | type: string 11 | description: The path or the URL to the swagger file 12 | place_holder: 13 | content: > 14 | # Your mission 15 | 16 | Your mission is to create a Bruno collection for a project from a swagger file. 17 | 18 | Bruno: (https://www.usebruno.com/). 19 | 20 | The swagger file is: 21 | 22 | ```json 23 | {{swagger_file}} 24 | ``` 25 | 26 | ## Follow these steps to create the Bruno collection: 27 | 28 | 0 - Read the swagger file and understand the API. And rephrase your mission in a way that is more specific to the API you are dealing with. 29 | 1 - Analyse an describe the endpoints and the operations available in the swagger file. 30 | 3 - Identify the how authentication works with this api, describe in detail what you discover in a table 31 | 4 - Identify how the pagination works for api that support it, describe in detail what you discover in a table 32 | 5 - Create a collection of tests cases for each endpoint with inputs and expected outputs. Format your ideas in a table with columns for "Method", "Path", "Description", "Expected Response Code", "Expected Response Body". 33 | 6 - Write the Bruno collection for the project, ensuring it covers the test cases and edge cases. Include the authentication and pagination details. Use Javascript to handle the authentication and pagination. 34 | 7 - Write an example of bash script to run the collection with differents contexts. 35 | 36 | Use Markdown and Code blocks to format your output. -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "module": "esnext", 5 | "esModuleInterop": true, 6 | "forceConsistentCasingInFileNames": true, 7 | "strict": true, 8 | "skipLibCheck": true, 9 | "composite": true 10 | }, 11 | "references": [ 12 | ] 13 | } 14 | --------------------------------------------------------------------------------