🕵️ SicherheitslückenHak5: Hackers Just Poisoned the Rust Supply Chain | Threat Wire(01.09.2026 um 14:00 Uhr)
🕵️ SicherheitslückenHak5: Hackers Found a Way Into Humanoid Robots | Threat Wire(04.09.2026 um 15:04 Uhr)
🔧 AI Nachrichten Bits und so #1021 (Passwort für Laufwerk)(31.08.2026 um 22:15 Uhr)
🔧 AI Nachrichten Bits und so #1022 (Wie Weißbier)(06.09.2026 um 20:39 Uhr)
🍏 iOS / Mac OSHue-App 6.0 ist da: das sind die Neuerungen(07.09.2026 um 17:21 Uhr)
🕵️ SicherheitslückenHak5: Hackers Just Poisoned the Rust Supply Chain | Threat Wire(01.09.2026 um 14:00 Uhr)
🕵️ SicherheitslückenHak5: Hackers Found a Way Into Humanoid Robots | Threat Wire(04.09.2026 um 15:04 Uhr)
🔧 AI Nachrichten Bits und so #1021 (Passwort für Laufwerk)(31.08.2026 um 22:15 Uhr)
🔧 AI Nachrichten Bits und so #1022 (Wie Weißbier)(06.09.2026 um 20:39 Uhr)
🍏 iOS / Mac OSHue-App 6.0 ist da: das sind die Neuerungen(07.09.2026 um 17:21 Uhr)

🔧 Programmierung 🕛 kürzlich 8 Min Lesezeit
0

Utilizing Generative AI with Python

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht

AI is the future, and as a software engineer, it’s the hottest field to get into. Leveraging LLMs in your code enables you to build smarter applications that handle complex tasks like real-time sentiment analysis or interpreting user-generated content. Integrating LLMs makes your software more responsive and capable, enhancing user experiences and automation.



This post is an introduction on how to make LLM calls using Python so you can start adding these powerful capabilities to your own code.



We’ll start off by making a chatbot for any character of your choosing. Then, you'll learn how to summarize smaller texts, and even move up to summarizing whole books. Lastly, you'll learn how to re-prompt and analyze results provided by the LLM.








Making our first LLM Request



For the LLM requests, we will be using Groq. If you create an account there, you can use their API and make LLM requests for free.



In order to use Python for these requests, install the Groq python package by running pip install groq. Then, we'll import it in our code like so:




CODE
import os
from groq import Groq

client = Groq(
api_key=os.environ.get("GROQ_API_KEY"),
)






Be sure to set the api key as an environment variable.



A simple LLM request can be made by adding:




CODE
chat_completion = client.chat.completions.create(
messages=[
{
"role": "user",
"content": "Explain formula 1.",
}
],
model="llama3-8b-8192",
)
print(chat_completion.choices[0].message.content)






In this case, we ask the LLM to explain what formula 1 is. The output from llama3-8b should be printed once you run the program in your console. You can play around with this and switch the model, as well as the prompt.






Creating a custom Chatbot



Now, let's create a chatbot for any character you like—Mario, for example. Right now, the LLM responds in a neutral/informative tone. However, by giving the LLM a system role, we can make sure it responds just like Mario would, adding personality and fun to the conversation. This sets the tone for interactions, so you’ll get playful and iconic responses like “It’s-a me, Mario!” to keep things engaging.



Let's add a system role to our request:




CODE
chat_completion = client.chat.completions.create(
messages=[
{
"role": "system",
"content": "You are a super mario chatbot. Always answer in his style, and create witty responses."
},
{
"role": "user",
"content": "Explain formula 1.",
}
],
model="llama3-8b-8192",
)
print(chat_completion.choices[0].message.content)






Now, the LLM will explain what Formula 1 is in terms of Mario Kart!



.



Notice that the LLM comes back with an error. You gave it too much to summarize all at once.






Summarizing a Book



.



P.S: This is the blog post version of a workshop I gave to SCU’s ACM chapter.

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
Hackers Just Poisoned the Rust Supply Chain | Threat Wire
1 Quelle
Hackers Found a Way Into Humanoid Robots | Threat Wire
1 Quelle
Bits und so #1021 (Passwort für Laufwerk)
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Utilizing Generative AI with Python

Thematisch verwandte Begriffe: Utilizing, Generative, with, Python · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...