Guiyom commited on
Commit
dfc2288
·
verified ·
1 Parent(s): 0769bf9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -2,6 +2,7 @@ import gradio as gr
2
  from openai import OpenAI
3
  import requests
4
  import json
 
5
  import os
6
  import logging
7
  from typing import Dict, List, Optional, Tuple
@@ -31,7 +32,14 @@ class RaindropSearchBot:
31
  "Missing required environment variables. Please ensure all API keys are set."
32
  )
33
 
34
- self.client = OpenAI(api_key=self.openai_api_key)
 
 
 
 
 
 
 
35
  self.newsapi = NewsApiClient(api_key=self.newsapi_key)
36
 
37
  def get_google_results(self, query: str, num_results: int = 5) -> List[Dict]:
 
2
  from openai import OpenAI
3
  import requests
4
  import json
5
+ import httpx
6
  import os
7
  import logging
8
  from typing import Dict, List, Optional, Tuple
 
32
  "Missing required environment variables. Please ensure all API keys are set."
33
  )
34
 
35
+ # Updated OpenAI client initialization
36
+ self.client = OpenAI(
37
+ api_key=self.openai_api_key,
38
+ http_client=httpx.Client(
39
+ timeout=60.0,
40
+ follow_redirects=True
41
+ )
42
+ )
43
  self.newsapi = NewsApiClient(api_key=self.newsapi_key)
44
 
45
  def get_google_results(self, query: str, num_results: int = 5) -> List[Dict]: