MCPcopy Create free account
hub / github.com/CL-lau/SQL-GPT / SerpAPI

Class SerpAPI

gpt/check_api_key.py:43–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41
42
43class SerpAPI(ApiKey):
44 @classmethod
45 def is_valid(cls) -> str:
46 if not st.session_state['serpapi_api_key']:
47 st.warning('⚠️ You have not pass SerpAPI key. (You cannot ask current events.)')
48 return
49 from langchain import SerpAPIWrapper
50
51 os.environ['SERPAPI_API_KEY'] = os.getenv('SERPAPI_API_KEY')
52 try:
53 search = SerpAPIWrapper()
54 response = search.run(cls.query)
55 return response
56 except Exception as e:
57 st.error(
58 '🚨 :red[Your SerpAPI key has a problem.] '
59 '[Check your usage](https://serpapi.com/dashboard)'
60 )
61 print(f'Test error\n{e}')

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected