|
import os |
|
import gradio as gr |
|
import google.generativeai as genai |
|
from dotenv import load_dotenv |
|
|
|
load_dotenv() |
|
genai.configure(api_key=os.getenv("GOOGLE_API_KEY")) |
|
|
|
model = genai.GenerativeModel( |
|
model_name="gemini-2.0-flash", |
|
generation_config={ |
|
"temperature": 0.9, |
|
"top_p": 1, |
|
"max_output_tokens": 2048, |
|
} |
|
) |
|
|
|
doc_url = "https://discovery.ucl.ac.uk/id/eprint/10089234/1/343019_3_art_0_py4t4l_convrt.pdf" |
|
|
|
|
|
doc_data = httpx.get(doc_url).content |
|
|
|
prompt = "Summarize this document" |
|
response = client.models.generate_content( |
|
model="gemini-1.5-flash", |
|
contents=[ |
|
types.Part.from_bytes( |
|
data=doc_data, |
|
mime_type='application/pdf', |
|
), |
|
prompt]) |
|
print(response.text) |
|
|
|
|