Ap4b M4
Ap4b M4
DeepLearning.AI makes these slides available for educational purposes. You may not use or distribute
these slides for commercial purposes. You may make copies of these slides and use or distribute them for
educational purposes as long as you cite DeepLearning.AI as the source of the slides.
Module 4: Extending
Python with Packages
and APIs
AI Python for Everyone
import file
Lesson 2: Built-in
Packages
What is a Python package?
import pandas as pd
import matplotlib.pyplot as plt
AI Python for Everyone
Lesson 4: Installing
Packages
AI Python for Everyone
API
AI Python for Everyone
def get_llm_response(prompt):
completion = client.chat.completions.create(
model = "gpt-4o-mini", Model selection
messages = [
Tells the LLM how to respond
{
The "role": "system",
prompt to "content": "You an AI assistant.",
pass to the
},
LLM {"role": "user", "content": prompt},
], Controls randomness of the
temperature=0.0,
responses
)
response = completion.choices[0].message.content
return response Gets the LLM
response text