Spaces:
Running
Running
File size: 616 Bytes
bc3753a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import os
import google.generativeai as genai
def configure_api(api_key, proxy_url=None):
if proxy_url:
os.environ['https_proxy'] = proxy_url if proxy_url else None
os.environ['http_proxy'] = proxy_url if proxy_url else None
genai.configure(api_key=api_key)
class Gemini:
def __init__(self, model_path='gemini-pro', api_key=None, proxy_url=None):
configure_api(api_key, proxy_url)
self.model = genai.GenerativeModel(model_path)
def generate(self, question):
response = self.model.generate_content(question)
return response
|