3
3
import signal
4
4
import sys
5
5
import warnings
6
+
7
+ import openai
6
8
from openai .validators import (
7
- write_out_file ,
8
9
apply_necessary_remediation ,
9
10
apply_optional_remediation ,
10
- read_any_format ,
11
11
get_validators ,
12
+ read_any_format ,
13
+ write_out_file ,
12
14
)
13
15
14
- import openai
15
-
16
16
17
17
class bcolors :
18
18
HEADER = "\033 [95m"
@@ -102,7 +102,6 @@ def generate(cls, args):
102
102
103
103
@classmethod
104
104
def search (cls , args ):
105
- # Will soon be deprecated and replaced by a Search.create
106
105
params = {
107
106
"query" : args .query ,
108
107
"max_rerank" : args .max_rerank ,
@@ -113,6 +112,9 @@ def search(cls, args):
113
112
if args .file :
114
113
params ["file" ] = args .file
115
114
115
+ if args .version :
116
+ params ["version" ] = args .version
117
+
116
118
resp = openai .Engine (id = args .id ).search (** params )
117
119
scores = [
118
120
(search_result ["score" ], search_result ["document" ])
@@ -221,6 +223,17 @@ def list(cls, args):
221
223
print (file )
222
224
223
225
226
+ class Search :
227
+ @classmethod
228
+ def create_alpha (cls , args ):
229
+ resp = openai .Search .create_alpha (
230
+ query = [args .query ],
231
+ max_documents = args .max_documents ,
232
+ file_id = args .file ,
233
+ )
234
+ print (resp )
235
+
236
+
224
237
class FineTune :
225
238
@classmethod
226
239
def list (cls , args ):
@@ -589,6 +602,11 @@ def help(args):
589
602
type = bool ,
590
603
default = False ,
591
604
)
605
+ sub .add_argument (
606
+ "--version" ,
607
+ help = "The version of the search routing to use" ,
608
+ )
609
+
592
610
sub .add_argument ("-q" , "--query" , required = True , help = "Search query" )
593
611
sub .set_defaults (func = Engine .search )
594
612
@@ -688,6 +706,30 @@ def help(args):
688
706
sub = subparsers .add_parser ("files.list" )
689
707
sub .set_defaults (func = File .list )
690
708
709
+ # Search
710
+ sub = subparsers .add_parser ("search.create_alpha" )
711
+
712
+ sub .add_argument (
713
+ "-f" ,
714
+ "--file" ,
715
+ required = True ,
716
+ help = "ID for previously uploaded file that contains the documents you want to search" ,
717
+ )
718
+ sub .add_argument (
719
+ "-m" ,
720
+ "--max_documents" ,
721
+ help = "The maximum number of documents to return" ,
722
+ type = int ,
723
+ default = 200 ,
724
+ )
725
+ sub .add_argument (
726
+ "-q" ,
727
+ "--query" ,
728
+ required = True ,
729
+ help = "Search query" ,
730
+ )
731
+ sub .set_defaults (func = Search .create_alpha )
732
+
691
733
# Finetune
692
734
sub = subparsers .add_parser ("fine_tunes.list" )
693
735
sub .set_defaults (func = FineTune .list )
0 commit comments