Johannes commited on
Commit
592bbaa
1 Parent(s): 89cbaf7

added error checking to the remaining methods

Browse files

all the methods within Phind should now raise a value error if
cf_clearance is missing

Files changed (1) hide show
  1. phind/__init__.py +10 -3
phind/__init__.py CHANGED
@@ -53,8 +53,10 @@ class PhindResponse:
53
 
54
  class Search:
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')
 
 
58
 
59
  if not actualSearch:
60
  return {
@@ -106,8 +108,11 @@ class Completion:
106
  codeContext: str = '',
107
  language: str = 'en') -> PhindResponse:
108
 
109
- if user_agent == '':
110
  raise ValueError('user_agent must be set, refer to documentation')
 
 
 
111
 
112
  if results is None:
113
  results = Search.create(prompt, actualSearch = True)
@@ -235,6 +240,8 @@ class StreamingCompletion:
235
 
236
  if user_agent == '':
237
  raise ValueError('user_agent must be set, refer to documentation')
 
 
238
 
239
  if results is None:
240
  results = Search.create(prompt, actualSearch = True)
 
53
 
54
  class Search:
55
  def create(prompt: str, actualSearch: bool = True, language: str = 'en') -> dict: # None = no search
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')
60
 
61
  if not actualSearch:
62
  return {
 
108
  codeContext: str = '',
109
  language: str = 'en') -> PhindResponse:
110
 
111
+ if user_agent == '' :
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')
116
 
117
  if results is None:
118
  results = Search.create(prompt, actualSearch = True)
 
240
 
241
  if user_agent == '':
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')
245
 
246
  if results is None:
247
  results = Search.create(prompt, actualSearch = True)