@miso.ai/doggoganger 0.9.0-beta.6 → 0.9.0-beta.8

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@miso.ai/doggoganger",
3
- "version": "0.9.0-beta.6",
3
+ "version": "0.9.0-beta.8",
4
4
  "description": "A dummy miso endpoint for demo and testing",
5
5
  "type": "module",
6
6
  "bin": {
@@ -10,17 +10,17 @@ const STAGES = [
10
10
  {
11
11
  name: 'fetch',
12
12
  duration: 1.5,
13
- text: `Checking the question and fetching results...`,
13
+ text: `Checking the question and fetching results... `,
14
14
  },
15
15
  {
16
16
  name: 'verify',
17
17
  duration: 1.5,
18
- text: `Verifying results...`,
18
+ text: `Verifying results... `,
19
19
  },
20
20
  {
21
21
  name: 'generate',
22
22
  duration: 1.5,
23
- text: `Generating answer...`,
23
+ text: `Generating answer... `,
24
24
  },
25
25
  ];
26
26
 
@@ -47,7 +47,7 @@ const answers = new Map();
47
47
 
48
48
  class Answer {
49
49
 
50
- constructor(question, previous_question_id, { answerFormat = 'plaintext' } = {}) {
50
+ constructor(question, previous_question_id, { answerFormat = 'markdown' } = {}) {
51
51
  this.question_id = uuid();
52
52
  this.question = question;
53
53
  this.previous_answer_id = previous_question_id;
@@ -62,18 +62,22 @@ class Answer {
62
62
  answers.set(this.question_id, this);
63
63
  }
64
64
 
65
+ get id() {
66
+ return this.question_id;
67
+ }
68
+
65
69
  get() {
66
70
  const now = Date.now();
67
71
  const elapsed = (now - this.timestamp) / 1000;
68
- const [stage, answer, finished] = this._answer(elapsed);
72
+ const [answer_stage, answer, finished] = this._answer(elapsed);
69
73
  const sources = this._sources(elapsed);
70
74
  const related_resources = this._relatedResources(elapsed);
71
75
  const { question_id, question, datetime, previous_question_id } = this;
72
76
 
73
77
  return {
74
78
  affiliation: undefined,
75
- stage,
76
79
  answer,
80
+ answer_stage,
77
81
  datetime,
78
82
  finished,
79
83
  previous_question_id,
@@ -118,10 +122,12 @@ export default function({ answerFormat }) {
118
122
  const router = new Router();
119
123
 
120
124
  router.post('/questions', (ctx) => {
121
- const { q: question, previous_answer_id } = JSON.parse(ctx.request.body);
125
+ const { question, previous_answer_id } = JSON.parse(ctx.request.body);
122
126
  const answerFormat = ctx.get('x-answer-format') || options.answerFormat;
123
127
  const answer = new Answer(question, previous_answer_id, { answerFormat });
124
- const data = answer.get();
128
+ const data = {
129
+ question_id: answer.id,
130
+ };
125
131
  ctx.body = JSON.stringify({ data });
126
132
  });
127
133
 
package/src/api/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import Router from '@koa/router';
2
- import _answers from './answers.js';
2
+ import ask from './ask.js';
3
3
  import recommendation from './recommendation.js';
4
4
  import search from './search.js';
5
5
  import interactions from './interactions.js';
@@ -11,7 +11,7 @@ function use(router, path, middleware) {
11
11
  export default function(options) {
12
12
  const router = new Router();
13
13
 
14
- use(router, '/answers', _answers(options));
14
+ use(router, '/ask', ask(options));
15
15
  use(router, '/recommendation', recommendation);
16
16
  use(router, '/search', search);
17
17
  use(router, '/interactions', interactions);
@@ -126,6 +126,7 @@ const INLINE_FEATURES = {
126
126
  'emphasis-1': () => multiply(_emphasisAdfix(1), 2),
127
127
  'emphasis-2': () => multiply(_emphasisAdfix(2), 2),
128
128
  'emphasis-3': () => multiply(_emphasisAdfix(3), 2),
129
+ 'strikethrough': () => ['~', '~'],
129
130
  'link': ({ url = 'https://miso.ai' } = {}) => [`[`, `](${url})`],
130
131
  };
131
132