mirror of
https://github.com/xtekky/gpt4free.git
synced 2024-09-12 08:29:30 -04:00
added error checking to the remaining methods
all the methods within Phind should now raise a value error if cf_clearance is missing
This commit is contained in:
parent
89cbaf7b61
commit
592bbaab86
@ -53,8 +53,10 @@ class PhindResponse:
|
|||||||
|
|
||||||
class Search:
|
class Search:
|
||||||
def create(prompt: str, actualSearch: bool = True, language: str = 'en') -> dict: # None = no search
|
def create(prompt: str, actualSearch: bool = True, language: str = 'en') -> dict: # None = no search
|
||||||
if user_agent == '' or cf_clearance == '':
|
if user_agent == '':
|
||||||
raise ValueError('user_agent and cf_clearance must be set, refer to documentation')
|
raise ValueError('user_agent must be set, refer to documentation')
|
||||||
|
if cf_clearance == '' :
|
||||||
|
raise ValueError('cf_clearance must be set, refer to documentation')
|
||||||
|
|
||||||
if not actualSearch:
|
if not actualSearch:
|
||||||
return {
|
return {
|
||||||
@ -106,8 +108,11 @@ class Completion:
|
|||||||
codeContext: str = '',
|
codeContext: str = '',
|
||||||
language: str = 'en') -> PhindResponse:
|
language: str = 'en') -> PhindResponse:
|
||||||
|
|
||||||
if user_agent == '':
|
if user_agent == '' :
|
||||||
raise ValueError('user_agent must be set, refer to documentation')
|
raise ValueError('user_agent must be set, refer to documentation')
|
||||||
|
|
||||||
|
if cf_clearance == '' :
|
||||||
|
raise ValueError('cf_clearance must be set, refer to documentation')
|
||||||
|
|
||||||
if results is None:
|
if results is None:
|
||||||
results = Search.create(prompt, actualSearch = True)
|
results = Search.create(prompt, actualSearch = True)
|
||||||
@ -235,6 +240,8 @@ class StreamingCompletion:
|
|||||||
|
|
||||||
if user_agent == '':
|
if user_agent == '':
|
||||||
raise ValueError('user_agent must be set, refer to documentation')
|
raise ValueError('user_agent must be set, refer to documentation')
|
||||||
|
if cf_clearance == '' :
|
||||||
|
raise ValueError('cf_clearance must be set, refer to documentation')
|
||||||
|
|
||||||
if results is None:
|
if results is None:
|
||||||
results = Search.create(prompt, actualSearch = True)
|
results = Search.create(prompt, actualSearch = True)
|
||||||
|
Loading…
Reference in New Issue
Block a user