appwrite-cli 7.0.0 → 8.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,85 +0,0 @@
1
- const fs = require('fs');
2
- const pathLib = require('path');
3
- const tar = require("tar");
4
- const ignore = require("ignore");
5
- const { promisify } = require('util');
6
- const libClient = require('../client.js');
7
- const { getAllFiles, showConsoleLink } = require('../utils.js');
8
- const { Command } = require('commander');
9
- const { sdkForProject, sdkForConsole } = require('../sdks')
10
- const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
11
- const { localConfig, globalConfig } = require("../config");
12
- const { File } = require('undici');
13
- const { ReadableStream } = require('stream/web');
14
-
15
- /**
16
- * @param {fs.ReadStream} readStream
17
- * @returns {ReadableStream}
18
- */
19
- function convertReadStreamToReadableStream(readStream) {
20
- return new ReadableStream({
21
- start(controller) {
22
- readStream.on("data", (chunk) => {
23
- controller.enqueue(chunk);
24
- });
25
- readStream.on("end", () => {
26
- controller.close();
27
- });
28
- readStream.on("error", (err) => {
29
- controller.error(err);
30
- });
31
- },
32
- cancel() {
33
- readStream.destroy();
34
- },
35
- });
36
- }
37
-
38
- const assistant = new Command("assistant").description(commandDescriptions['assistant'] ?? '').configureHelp({
39
- helpWidth: process.stdout.columns || 80
40
- })
41
-
42
- /**
43
- * @typedef {Object} AssistantChatRequestParams
44
- * @property {string} prompt Prompt. A string containing questions asked to the AI assistant.
45
- * @property {boolean} overrideForCli
46
- * @property {boolean} parseOutput
47
- * @property {libClient | undefined} sdk
48
- */
49
-
50
- /**
51
- * @param {AssistantChatRequestParams} params
52
- */
53
- const assistantChat = async ({prompt,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
54
- let client = !sdk ? await sdkForProject() :
55
- sdk;
56
- let apiPath = '/console/assistant';
57
- let payload = {};
58
- if (typeof prompt !== 'undefined') {
59
- payload['prompt'] = prompt;
60
- }
61
-
62
- let response = undefined;
63
-
64
- response = await client.call('post', apiPath, {
65
- 'content-type': 'application/json',
66
- }, payload);
67
-
68
- if (parseOutput) {
69
- parse(response)
70
- }
71
-
72
- return response;
73
-
74
- }
75
-
76
- assistant
77
- .command(`chat`)
78
- .description(`Send a prompt to the AI assistant and receive a response. This endpoint allows you to interact with Appwrite's AI assistant by sending questions or prompts and receiving helpful responses in real-time through a server-sent events stream. `)
79
- .requiredOption(`--prompt <prompt>`, `Prompt. A string containing questions asked to the AI assistant.`)
80
- .action(actionRunner(assistantChat))
81
-
82
- module.exports = {
83
- assistant,
84
- assistantChat
85
- };