@mongoosejs/studio 0.0.37 → 0.0.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,13 +1,12 @@
1
1
  {
2
2
  "name": "@mongoosejs/studio",
3
- "version": "0.0.37",
3
+ "version": "0.0.38",
4
4
  "dependencies": {
5
5
  "archetype": "0.13.0",
6
6
  "csv-stringify": "6.3.0",
7
7
  "ejson": "^2.2.3",
8
8
  "extrovert": "0.0.24",
9
9
  "node-inspect-extracted": "3.x",
10
- "openai": "3.x",
11
10
  "vanillatoasts": "^1.6.0"
12
11
  },
13
12
  "peerDependencies": {
@@ -1,60 +0,0 @@
1
- 'use strict';
2
-
3
- const Archetype = require('archetype');
4
- const { Configuration, OpenAIApi } = require('openai');
5
-
6
- const apiKey = process.env.OPEN_AI_KEY;
7
-
8
- let openai;
9
- if (apiKey) {
10
- const configuration = new Configuration({
11
- apiKey
12
- });
13
- openai = new OpenAIApi(configuration);
14
- }
15
-
16
- const prePrompt = `
17
- You are a software developer answering user queries using Mongoose.
18
- Write Node.js code using Mongoose that answers the user's query.
19
- Do not write any import statements.
20
-
21
- Input:
22
- How many users where created yesterday?
23
- Output:
24
- const yesterday = new Date();
25
- yesterday.setHours(0, 0, 0);
26
- yesterday.setDate(yesterday.getDate() - 1);
27
- await User.countDocuments({ createdAt: { $gte: yesterday } });
28
- `.trim();
29
-
30
- const CreateChartParams = new Archetype({
31
- description: {
32
- $type: 'string',
33
- $required: true
34
- }
35
- }).compile('CreateChartParams');
36
-
37
- module.exports = ({ db }) => async function createChart(params) {
38
- const { description } = new CreateChartParams(params);
39
-
40
- const response = await openai.createChatCompletion({
41
- model: 'gpt-4',
42
- messages: [
43
- {
44
- role: 'system',
45
- content: prePrompt
46
- },
47
- {
48
- role: 'user',
49
- content: description
50
- }
51
- ],
52
- temperature: 0.1
53
- });
54
-
55
- console.log('F', response.data.choices[0].message.content);
56
-
57
- return {
58
- content: response.data.choices[0].message.content
59
- };
60
- };
@@ -1,17 +0,0 @@
1
- .charts {
2
- padding: 10px;
3
- }
4
-
5
- .charts .chart-description textarea {
6
- width: 100%;
7
- height: 4em;
8
- border-radius: 4px;
9
- border: 1px solid #ddd;
10
- margin-top: 0.5em;
11
- padding: 0.5em;
12
- line-height: 1.5em;
13
- }
14
-
15
- .charts .chart-description button {
16
- margin-top: 0.5em;
17
- }
@@ -1,14 +0,0 @@
1
- <div class="charts">
2
- <h1>Charts</h1>
3
- <div>
4
- Describe your chart
5
- </div>
6
- <div class="chart-description">
7
- <textarea
8
- v-model="description"
9
- placeholder="Please create a bar chart showing users createdAt per day" />
10
- <div>
11
- <async-button @click="createChart">Create Chart</async-button>
12
- </div>
13
- </div>
14
- </div>
@@ -1,19 +0,0 @@
1
- 'use strict';
2
-
3
- const api = require('../api');
4
- const template = require('./charts.html');
5
-
6
- const appendCSS = require('../appendCSS');
7
-
8
- appendCSS(require('./charts.css'));
9
-
10
- module.exports = app => app.component('charts', {
11
- template: template,
12
- data: () => ({ description: '', code: '' }),
13
- methods: {
14
- async createChart() {
15
- const data = await api.Model.createChart({ description: this.description });
16
- this.code = data.content;
17
- }
18
- }
19
- });