Talking with AI
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.env
|
||||||
20
main.py
20
main.py
@@ -1,6 +1,26 @@
|
|||||||
|
import os
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
from google import genai
|
||||||
|
|
||||||
|
load_dotenv()
|
||||||
|
api_key = os.environ.get("GEMINI_API_KEY")
|
||||||
|
|
||||||
|
client = genai.Client(api_key=api_key)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
print("Hello from boot-dev-ai-agent!")
|
print("Hello from boot-dev-ai-agent!")
|
||||||
|
|
||||||
|
response = client.models.generate_content(
|
||||||
|
model="gemini-2.0-flash-001",
|
||||||
|
contents="Why is Boot.dev such a great place to learn backend development? Use one paragraph maximum."
|
||||||
|
)
|
||||||
|
|
||||||
|
print(response.text)
|
||||||
|
|
||||||
|
print(f"Prompt tokens: {response.usage_metadata.prompt_token_count}")
|
||||||
|
print(f"Response tokens: {response.usage_metadata.candidates_token_count}")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user