هذا الالتزام موجود في:
2025-09-26 08:21:26 +03:00
التزام 8d02e35b5f
7 ملفات معدلة مع 294 إضافات و0 حذوفات

68
ai.py Normal file
عرض الملف

@@ -0,0 +1,68 @@
# To run this code you need to install the following dependencies:
# pip install google-genai
import base64
import os
from google import genai
from google.genai import types
def generate(description, instruction):
client = genai.Client(
api_key=""
)
model = "gemini-2.5-flash"
contents = [
types.Content(
role="user",
parts=[
types.Part.from_text(text=description),
],
),
]
generate_content_config = types.GenerateContentConfig(
thinking_config=types.ThinkingConfig(
thinking_budget=0,
),
response_mime_type="application/json",
response_schema=genai.types.Schema(
type=genai.types.Type.OBJECT,
required=[
"percentage",
"why I'm I a good fit",
"what I'm I missing",
],
properties={
"percentage": genai.types.Schema(
type=genai.types.Type.INTEGER,
),
"why I'm I a good fit": genai.types.Schema(
type=genai.types.Type.STRING,
),
"what I'm I missing": genai.types.Schema(
type=genai.types.Type.STRING,
),
},
),
system_instruction=[
types.Part.from_text(text=instruction),
],
)
# for chunk in client.models.generate_content_stream(
# model=model,
# contents=contents,
# config=generate_content_config,
# ):
# print(chunk.text, end="")
response = client.models.generate_content(
model=model,
contents=contents,
config=generate_content_config,
)
return response.text
if __name__ == "__main__":
generate()