Skip to content

Commit

Permalink
Fix/peer-dependency (#57)
Browse files Browse the repository at this point in the history
* chore: Add .obsidian to .gitignore

* fix(packages/qllm-cli): improve chat functionality

The commit message should be:

fix(packages/qllm-cli): improve chat functionality

* Merge remote-tracking branch 'origin/feat/tutorial-qllm' into fix/peer-dependency
  • Loading branch information
raphaelmansuy authored Sep 4, 2024
1 parent 69c876b commit 8e4733e
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 35 deletions.
11 changes: 11 additions & 0 deletions packages/qllm-cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# qllm

## 2.8.0

### Minor Changes

- Improve the chat

### Patch Changes

- Updated dependencies
- qllm-lib@3.5.0

## 2.7.2

### Patch Changes
Expand Down
6 changes: 3 additions & 3 deletions packages/qllm-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "qllm",
"version": "2.7.2",
"version": "2.8.0",
"description": "QLLM CLI: A versatile CLI tool for interacting with multiple AI/LLM providers. Features include chat sessions, one-time queries, image handling, and conversation management. Streamlines AI development with easy provider/model switching and configuration.",
"keywords": [
"ai",
Expand Down Expand Up @@ -66,8 +66,8 @@
"typescript-eslint": "8.3.0"
},
"dependencies": {
"@aws-sdk/client-sso-oidc": "^3.614.0",
"@aws-sdk/client-sts": "3.637.0",
"@aws-sdk/client-sso-oidc": "^3.645.0",
"@aws-sdk/client-sts": "^3.645.0",
"@npmcli/fs": "^3.1.1",
"cli-table3": "^0.6.5",
"commander": "^12.1.0",
Expand Down
5 changes: 3 additions & 2 deletions packages/qllm-cli/src/chat/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export class Chat {
async initialize(): Promise<void> {
try {
await this.config.initialize();
this.configManager.setProvider(this.providerName);
this.configManager.setModel(this.modelName);
await this.configManager.setProvider(this.providerName);
await this.configManager.setModel(this.modelName);
ioManager.displaySuccess(
`Chat initialized with ${this.providerName} provider and ${this.modelName} model.`,
);
Expand All @@ -67,6 +67,7 @@ export class Chat {

private async promptUser(): Promise<void> {
try {

const input = await this.ioManager.getUserInput("You: ");

// Check if input is undefined (e.g., due to Ctrl+C)
Expand Down
26 changes: 18 additions & 8 deletions packages/qllm-cli/src/chat/commands/show-help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ const helpGroups = [
},
{
command: "/run <template>",
description: "Run a predefined prompt template <template> can be an URL or a local file",
description:
"Run a predefined prompt template <template> can be an URL or a local file",
},
{
command: "/save <file>",
description: "Write the current conversation to a file <file> can be a local file"
}
description:
"Write the current conversation to a file <file> can be a local file",
},
],
},
{
Expand Down Expand Up @@ -134,18 +136,26 @@ function showCommandHelp(
ioManager.displayInfo(
` ${ioManager.colorize(commandHelp.command, "cyan")}`,
);

// Add more detailed usage information for specific commands
if (command === "run") {
ioManager.newLine();
ioManager.displayInfo("The run command allows you to execute predefined chat templates.");
ioManager.displayInfo("Templates are predefined conversation starters or workflows.");
ioManager.displayInfo(
"The run command allows you to execute predefined chat templates.",
);
ioManager.displayInfo(
"Templates are predefined conversation starters or workflows.",
);
ioManager.displayInfo("Example:");
ioManager.displayInfo(" /run code-review");
ioManager.newLine();
ioManager.displayInfo("Available templates:");
ioManager.displayInfo(" - code-review: Start a code review session");
ioManager.displayInfo(" - brainstorm: Begin a brainstorming session");
ioManager.displayInfo(
" - code-review: Start a code review session",
);
ioManager.displayInfo(
" - brainstorm: Begin a brainstorming session",
);
ioManager.displayInfo(" - debug: Initiate a debugging session");
// Add more templates as they become available
}
Expand Down
32 changes: 24 additions & 8 deletions packages/qllm-cli/src/qllm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const ioManager = new IOManager();

export async function main() {
try {

const configManager = CliConfigManager.getInstance();

await configManager.ensureConfigFileExists();
Expand Down Expand Up @@ -56,8 +55,6 @@ export async function main() {
parseFloat,
);



// Set the run command as the default command
program
.argument("[template]", "Template name, file path, or URL")
Expand Down Expand Up @@ -122,16 +119,35 @@ export async function main() {
.command("ask")
.description("Ask a question to an LLM")
.argument("<question>", "The question to ask")
.option("-c, --context <context>", "Additional context for the question")
.option("-i, --image <path>", "Path to image file, or URL (can be used multiple times)", (value, previous) => previous.concat([value]), [] as string[])
.option(
"-c, --context <context>",
"Additional context for the question",
)
.option(
"-i, --image <path>",
"Path to image file, or URL (can be used multiple times)",
(value, previous) => previous.concat([value]),
[] as string[],
)
.option("--use-clipboard", "Use image from clipboard", false)
.option("--screenshot <display>", "Capture screenshot from specified display number", (value) => parseInt(value, 10))
.option(
"--screenshot <display>",
"Capture screenshot from specified display number",
(value) => parseInt(value, 10),
)
.option("-s, --stream", "Stream the response", false)
.option("-o, --output <file>", "Output file for the response")
.option("--system-message <message>", "System message to prepend to the conversation")
.option(
"--system-message <message>",
"System message to prepend to the conversation",
)
.action((question, options) => {
const globalOptions = program.opts();
const mergedOptions = { ...globalOptions, ...options, question };
const mergedOptions = {
...globalOptions,
...options,
question,
};
askCommandAction(question, mergedOptions);
});

Expand Down
4 changes: 2 additions & 2 deletions packages/qllm-cli/src/utils/io-manager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,8 @@ export class IOManager {

async promptYesNo(message: string): Promise<boolean> {
const response = await prompts({
type: 'confirm',
name: 'value',
type: "confirm",
name: "value",
message: message,
initial: true, // Default to 'yes'
});
Expand Down
3 changes: 1 addition & 2 deletions packages/qllm-cli/src/utils/write-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,11 @@ export async function writeToFile(
}
}


export async function fileExists(filePath: string): Promise<boolean> {
try {
await fs.access(filePath);
return true; // File exists
} catch {
return false; // File does not exist
}
}
}
6 changes: 6 additions & 0 deletions packages/qllm-lib/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# qllm-lib

## 3.5.0

### Minor Changes

- Improve the chat

## 3.4.1

### Patch Changes
Expand Down
18 changes: 9 additions & 9 deletions packages/qllm-lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "qllm-lib",
"version": "3.4.1",
"version": "3.5.0",
"description": "Core library providing robust AI engineering functionalities tailored for Large Language Model (LLM) applications, enabling developers to build, deploy, and optimize AI solutions with ease.",
"keywords": [
"ai",
Expand Down Expand Up @@ -62,10 +62,10 @@
"dependencies": {
"@anthropic-ai/bedrock-sdk": "^0.10.2",
"@anthropic-ai/sdk": "^0.27.0",
"@aws-sdk/client-bedrock": "^3.637.0",
"@aws-sdk/client-sso-oidc": "^3.637.0",
"@aws-sdk/client-sts": "^3.637.0",
"@aws-sdk/credential-providers": "^3.637.0",
"@aws-sdk/client-bedrock": "^3.645.0",
"@aws-sdk/client-sso-oidc": "^3.645.0",
"@aws-sdk/client-sts": "^3.645.0",
"@aws-sdk/credential-providers": "^3.645.0",
"@mistralai/mistralai": "1.0.4",
"axios": "^1.7.5",
"groq-sdk": "^0.5.0",
Expand All @@ -84,10 +84,10 @@
"@npmcli/move-file": "npm:@npmcli/fs@latest",
"are-we-there-yet": "latest",
"gauge": "latest",
"@aws-sdk/client-sts": "^3.637.0",
"@aws-sdk/credential-provider-node": "^3.637.0",
"@aws-sdk/credential-provider-ini": "^3.637.0",
"@aws-sdk/credential-provider-web-identity": "^3.637.0"
"@aws-sdk/client-sts": "^3.645.0",
"@aws-sdk/credential-provider-node": "^3.645.0",
"@aws-sdk/credential-provider-ini": "^3.645.0",
"@aws-sdk/credential-provider-web-identity": "^3.645.0"
},
"publishConfig": {
"access": "public"
Expand Down
7 changes: 7 additions & 0 deletions packages/qllm-samples/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# qllm-samples

## 1.0.3

### Patch Changes

- Updated dependencies
- qllm-lib@3.5.0

## 1.0.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/qllm-samples/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "qllm-samples",
"version": "1.0.2",
"version": "1.0.3",
"description": "QLLM Samples",
"keywords": [
"ai",
Expand Down

0 comments on commit 8e4733e

Please sign in to comment.