File tree Expand file tree Collapse file tree 3 files changed +63
-0
lines changed Expand file tree Collapse file tree 3 files changed +63
-0
lines changed Original file line number Diff line number Diff line change
1
+ export type MethodParamsOptions = {
2
+ contextId : string ;
3
+ } ;
4
+
5
+ type MetaDataType =
6
+ | { type : 'airtable' ; source : string ; name : string }
7
+ | { type : 'slack' ; source : string ; channel : string ; name : string }
8
+ | { type : 'notion' ; source : string ; page_id : string ; name : string }
9
+ | {
10
+ type : 'google-doc' ;
11
+ name : string ;
12
+ when : string ;
13
+ title : string ;
14
+ source : { doc_id : string ; file_id : string } ;
15
+ }
16
+ | {
17
+ type : 'document' ;
18
+ file_name : string ;
19
+ name : string ;
20
+ page_label : string ;
21
+ source : string ;
22
+ }
23
+ | {
24
+ type : 'web' ;
25
+ name : string ;
26
+ source : string ;
27
+ }
28
+ | {
29
+ type : 'text-snippet' ;
30
+ name : string ;
31
+ source : string ;
32
+ }
33
+ | {
34
+ type : 'Slack Message' ;
35
+ name : string ;
36
+ source : string ;
37
+ } ;
38
+
39
+ export type SearchResultData = {
40
+ page_content : string ;
41
+ type : 'Document' ;
42
+ metadata : MetaDataType ;
43
+ } ;
Original file line number Diff line number Diff line change
1
+ export { Search } from './search' ;
Original file line number Diff line number Diff line change
1
+ import { Hyper } from '../hyper' ;
2
+ import { MethodParamsOptions , SearchResultData } from './@types' ;
3
+
4
+ export class Search {
5
+ constructor ( private readonly hyper : Hyper ) { }
6
+
7
+ async execute ( query : string , options ?: MethodParamsOptions ) {
8
+ const payload = options ?. contextId
9
+ ? { query, context_id : options . contextId }
10
+ : { query } ;
11
+
12
+ const res = await this . hyper . post < SearchResultData [ ] > ( {
13
+ endpoint : '/search' ,
14
+ body : payload ,
15
+ } ) ;
16
+
17
+ return res ;
18
+ }
19
+ }
You can’t perform that action at this time.
0 commit comments