返回提交历史
Modified
phind/__init__.py
+10
-3
XFEstudio/gpt4free
added error checking to the remaining methods
all the methods within Phind should now raise a value error if cf_clearance is missing
592bbaab
代码差异
1 个文件
+10
-3
@@ -53,8 +53,10 @@ class PhindResponse:
53
53
54
54
class Search:
55
55
def create(prompt: str, actualSearch: bool = True, language: str = 'en') -> dict: # None = no search
56
if user_agent == '' or cf_clearance == '':
57
raise ValueError('user_agent and cf_clearance must be set, refer to documentation')
56
if user_agent == '':
57
raise ValueError('user_agent must be set, refer to documentation')
58
if cf_clearance == '' :
59
raise ValueError('cf_clearance must be set, refer to documentation')
58
60
59
61
if not actualSearch:
60
62
return {
@@ -106,8 +108,11 @@ class Completion:
106
108
codeContext: str = '',
107
109
language: str = 'en') -> PhindResponse:
108
110
109
if user_agent == '':
111
if user_agent == '' :
110
112
raise ValueError('user_agent must be set, refer to documentation')
113
114
if cf_clearance == '' :
115
raise ValueError('cf_clearance must be set, refer to documentation')
111
116
112
117
if results is None:
113
118
results = Search.create(prompt, actualSearch = True)
@@ -235,6 +240,8 @@ class StreamingCompletion:
235
240
236
241
if user_agent == '':
237
242
raise ValueError('user_agent must be set, refer to documentation')
243
if cf_clearance == '' :
244
raise ValueError('cf_clearance must be set, refer to documentation')
238
245
239
246
if results is None:
240
247
results = Search.create(prompt, actualSearch = True)