Spaces:
No application file

OSINT / src /llm_agent /llm_Gemini.py
abello's picture
Upload 28 files
839a850 verified
Raw
History Blame
871 Bytes
from google import genai
#import google.generativeai as genai
#from google.genai import types
import os
from dotenv import load_dotenv
load_dotenv()
# Configure the Gemini API with your API key
genai.configure(api_key=os.getenv("AIzaSyBbHJpOMJqbI9IKg9ZxdVNUgjg34SvaVrs"))
def load_llm():
async def llm(prompt: str) -> str:
try:
# Initialize the Gemini model
model = genai.GenerativeModel('gemini-2.5-flash') # or 'gemini-1.5-pro'
# Generate content
response = await model.generate_content_async(
prompt,
generation_config=genai.types.GenerationConfig(
temperature=0.2,
)
)
return response.text.strip()
except Exception as e:
return f"LLM error: {str(e)}"
return llm