Skip to content

Commit

Permalink
QLLM SPLIT LOCAL TO REMOT MASTER BRANCH (#18)
Browse files Browse the repository at this point in the history
* refactoring separation cli / providers

* update

* update

* update

* update

* incomplete major refactoring

* fix configuration

* Fix

* update

* update

* Feat/qllm split phase 2 (#11)

* refactoring process...

* refactoring process...

* refactoring process...

* refactoring process...

---------

Co-authored-by: yatchiya <yarab@gmail.com>

* push new features

---------

Co-authored-by: Raphael MANSUY <raphael.mansuy.partner@decathlon.com>
Co-authored-by: yatchiya <yarab@gmail.com>
  • Loading branch information
3 people authored Aug 16, 2024
1 parent e910db5 commit 422835d
Show file tree
Hide file tree
Showing 114 changed files with 17,139 additions and 5,523 deletions.
15 changes: 15 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
parser: '@typescript-eslint/parser',
extends: [
'plugin:@typescript-eslint/recommended',
'prettier/@typescript-eslint',
'plugin:prettier/recommended',
],
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
},
rules: {
// Add any custom rules here
},
};
11 changes: 11 additions & 0 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ jobs:
- name: Check if release version
id: check_version
run: node scripts/check_version.js
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
- run: npm ci
- run: npm run lint
- run: npm run format:check
# - name: Publish to npm
# if: steps.check_version.outputs.is_release == 'true'
# uses: actions/setup-node@v3
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
node_modules/
*/node_modules/
*/*/node_modules/
dist/
.env
*.log
.DS_Store
tasks/
package-lock.json
.qllmrc.yaml
.qllmrc.yaml*
.qllmrc.yaml*
dist
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
dist
build
coverage
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 100,
"tabWidth": 2
}
79 changes: 75 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,8 @@ This makes the `qllm` command available system-wide.

```bash
qllm ask "Write a 100-word story about a time traveler" --max-tokens 150

or :

npm run dev-cli ask "Write a 100-word story about a time traveler" --max-tokens 150
# Or when running from the project directory:
npm run dev-ask "What is the capital of France?"
```

2. Start an interactive chat session:
Expand Down Expand Up @@ -100,6 +98,56 @@ npm run dev-cli -- config --option
qllm template create
qllm template execute my-template
```

6. Generate embeddings for an image:

```bash
#qllm embed --link https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg --provider openai --model gpt-4-vision-preview

# Or when running from the project directory:
npm run dev-cli embed -- --link https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg --provider openai --model gpt-4-vision-preview

```

7. Generate embeddings for text:

```bash
qllm embed --text "Hello, world" --provider openai --model text-embedding-ada-002

# Or when running from the project directory:
npm run dev-cli embed -- --text "Hello, world" --provider openai --model text-embedding-ada-002
```

8. Use function calling with tools:

```bash
qllm ask "What's the weather like?" --tools '[{"type":"function","function":{"name":"get_weather","description":"Get the current weather","parameters":{"type":"object","properties":{"location":{"type":"string"}}}}}]' --provider openai --model gpt-4

# Or when running from the project directory:
npm run dev-ask "What's the weather like?" -- --tools '[{"type":"function","function":{"name":"get_weather","description":"Get the current weather","parameters":{"type":"object","properties":{"location":{"type":"string"}}}}}]' --provider openai --model gpt-4
```

9. Generate embeddings for text:

```bash
qllm embed --text "Hello, world" --provider openai --model text-embedding-ada-002

# Or when running from the project directory:
npm run dev-cli embed -- --text "Hello, world" --provider openai --model text-embedding-ada-002
```

10. multimodal chat (ask command ):

```bash
qllm ask "describe the following image" -- --image "/home/youcef/Bureau/f1.jpg" --provider openai --model gpt-4o-mini

# Or when running from the project directory:
npm run dev-ask "describe the following image" -- --image "/home/youcef/Bureau/f1.jpg" --provider openai --model gpt-4o-mini
```




## Configuration

QLLM uses a configuration file to manage various settings. The default configuration file is named `.qllmrc.yaml` and is located in the user's home directory.
Expand Down Expand Up @@ -337,6 +385,29 @@ Execute the template:
qllm template execute product-description -v:product_name="Eco-friendly Water Bottle" -v:key_features="Insulated, BPA-free, 24oz capacity"
```

### Env variables
AWS_PROFILE=
AWS_REGION=us-east-2

#### Default LLM Provider
#### Options: anthropic, openai, ollama
DEFAULT_PROVIDER=
#### Model Configuration
#### Use either MODEL_ALIAS or MODEL_ID, not both
MODEL_ALIAS=
MODEL_ID=
#### OpenAI Configuration (required when using OpenAI provider)
OPENAI_API_KEY=sk-
GROQ_API_KEY=""
PERPLEXITY_API_KEY=""
MISTRAL_API_KEY=""
JINA_API_KEY=""
OPENROUTER_API_KEY=""
OPENROUTER_TITLE=""
PROMPT_DIRECTORY=
#### Logging
LOG_LEVEL=info

### Multi-step Analysis with Templates

Create a template for analyzing financial data:
Expand Down
4 changes: 2 additions & 2 deletions __tests__/basic.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ProviderFactory } from '../src/providers/provider_factory';
import { configManager } from '../src/utils/configuration_manager';
import { ProviderFactory } from '../src/core/providers/provider_factory';
import { configManager } from '../src/common/utils/configuration_manager';

describe('ProviderFactory', () => {
it('should be defined', () => {
Expand Down
32 changes: 32 additions & 0 deletions docs/api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
**QLLM API Documentation****Docs**

***

# QLLM API Documentation

## Classes

- [ConfigurationManager](classes/ConfigurationManager.md)
- [ProviderFactory](classes/ProviderFactory.md)

## Interfaces

- [LLMProviderOptions](interfaces/LLMProviderOptions.md)
- [LLMResponse](interfaces/LLMResponse.md)
- [Message](interfaces/Message.md)
- [ProviderConfig](interfaces/ProviderConfig.md)

## Type Aliases

- [MessageRole](type-aliases/MessageRole.md)
- [OutputFormat](type-aliases/OutputFormat.md)

## Variables

- [configManager](variables/configManager.md)

## Functions

- [getAllProviders](functions/getAllProviders.md)
- [getModelsForProvider](functions/getModelsForProvider.md)
- [getProviderConfig](functions/getProviderConfig.md)
107 changes: 107 additions & 0 deletions docs/api/classes/ConfigurationManager.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
[**QLLM API Documentation**](../README.md)**Docs**

***

[QLLM API Documentation](../README.md) / ConfigurationManager

# Class: ConfigurationManager

## Extends

- `EventEmitter`

## Methods

### getConfig()

> **getConfig**(): `AppConfig`
#### Returns

`AppConfig`

#### Defined in

[config/configuration\_manager.ts:41](https://github.com/YatchiYa/qllm/blob/c17ead74a8e7150bea6cf408fa2b104235926e7e/packages/qllm-lib/src/config/configuration_manager.ts#L41)

***

### loadConfig()

> **loadConfig**(`configPath`?): `Promise`\<`void`\>
#### Parameters

**configPath?**: `string`

#### Returns

`Promise`\<`void`\>

#### Defined in

[config/configuration\_manager.ts:28](https://github.com/YatchiYa/qllm/blob/c17ead74a8e7150bea6cf408fa2b104235926e7e/packages/qllm-lib/src/config/configuration_manager.ts#L28)

***

### updateAndSaveConfig()

> **updateAndSaveConfig**(`updates`): `Promise`\<`void`\>
#### Parameters

**updates**: `Partial`\<`AppConfig`\>

#### Returns

`Promise`\<`void`\>

#### Defined in

[config/configuration\_manager.ts:45](https://github.com/YatchiYa/qllm/blob/c17ead74a8e7150bea6cf408fa2b104235926e7e/packages/qllm-lib/src/config/configuration_manager.ts#L45)

***

### updateConfig()

> **updateConfig**(`updates`): `void`
#### Parameters

**updates**: `Partial`\<`AppConfig`\>

#### Returns

`void`

#### Defined in

[config/configuration\_manager.ts:50](https://github.com/YatchiYa/qllm/blob/c17ead74a8e7150bea6cf408fa2b104235926e7e/packages/qllm-lib/src/config/configuration_manager.ts#L50)

***

### validateConfig()

> **validateConfig**(): `boolean`
#### Returns

`boolean`

#### Defined in

[config/configuration\_manager.ts:71](https://github.com/YatchiYa/qllm/blob/c17ead74a8e7150bea6cf408fa2b104235926e7e/packages/qllm-lib/src/config/configuration_manager.ts#L71)

***

### getInstance()

> `static` **getInstance**(): [`ConfigurationManager`](ConfigurationManager.md)
#### Returns

[`ConfigurationManager`](ConfigurationManager.md)

#### Defined in

[config/configuration\_manager.ts:21](https://github.com/YatchiYa/qllm/blob/c17ead74a8e7150bea6cf408fa2b104235926e7e/packages/qllm-lib/src/config/configuration_manager.ts#L21)
55 changes: 55 additions & 0 deletions docs/api/classes/ProviderFactory.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
[**QLLM API Documentation**](../README.md)**Docs**

***

[QLLM API Documentation](../README.md) / ProviderFactory

# Class: ProviderFactory

## Constructors

### new ProviderFactory()

> **new ProviderFactory**(): [`ProviderFactory`](ProviderFactory.md)
#### Returns

[`ProviderFactory`](ProviderFactory.md)

## Methods

### getProvider()

> `static` **getProvider**(`providerName`): `Promise`\<`LLMProvider`\>
#### Parameters

**providerName**: `ProviderName`

#### Returns

`Promise`\<`LLMProvider`\>

#### Defined in

[core/providers/provider\_factory.ts:14](https://github.com/YatchiYa/qllm/blob/c17ead74a8e7150bea6cf408fa2b104235926e7e/packages/qllm-lib/src/core/providers/provider_factory.ts#L14)

***

### registerProviderPlugin()

> `static` **registerProviderPlugin**(`name`, `initFunction`): `void`
#### Parameters

**name**: `string`

**initFunction**

#### Returns

`void`

#### Defined in

[core/providers/provider\_factory.ts:38](https://github.com/YatchiYa/qllm/blob/c17ead74a8e7150bea6cf408fa2b104235926e7e/packages/qllm-lib/src/core/providers/provider_factory.ts#L38)
17 changes: 17 additions & 0 deletions docs/api/functions/getAllProviders.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[**QLLM API Documentation**](../README.md)**Docs**

***

[QLLM API Documentation](../README.md) / getAllProviders

# Function: getAllProviders()

> **getAllProviders**(): `ProviderName`[]
## Returns

`ProviderName`[]

## Defined in

[config/provider\_config.ts:79](https://github.com/YatchiYa/qllm/blob/c17ead74a8e7150bea6cf408fa2b104235926e7e/packages/qllm-lib/src/config/provider_config.ts#L79)
Loading

0 comments on commit 422835d

Please sign in to comment.