# Set the query
brazil_customers_query = """
SELECT FirstName, LastName, Phone, Email
FROM Customer
WHERE Country = 'Brazil';
"""
# Query the database
df = pd.read_sql(brazil_customers_query, engine)
# Display the df
print(df)
# Set system prompt
system_prompt = """
You are a helpful, cheerful, and optimistic assistant.
Be concise, validate answers, and admit when you don’t know.
Make responses clear, easy to read, and sprinkle in playful emoji.
"""
# Instantiate chat history
chat_history = [
{
"role": "system",
"content": system_prompt
}
]
📨 Step 4. Create a Chat Function
ในขั้นที่ 4 เราจะสร้าง function ที่จะทำให้เราถาม-ตอบกับ chatbot แบบ real-time ได้:
# Create a function for chatbot
def chatbot(model="gemini-2.5-flash"):
# Set chat history as global variable
global chat_history
# Print chat header
display(Markdown("# 🟢 --- Chat Begins ---"))
# Print chat instruction
print("ℹ️ Type \\"end chat\\" to exit.")
# Loop through conversation
while True:
# Render user prompt display
display(Markdown("## 🧑💻 You:"))
# Get user input
user_prompt = input("")
# Check if user wants to exit chat
if user_prompt.lower() == "end chat":
# Print goodbye message
display(Markdown("## ✨ Assistant:\\n" + "👋 See you later!"))
# End chat
break
# Append user input to chat history
chat_history.append(
{
"role": "user",
"content": user_prompt
}
)
# Get response
response = client.chat.completions.create(
# Set prompt
messages=chat_history,
# Set model
model=model
)
# Append response to history
chat_history.append(
{
"role": "assistant",
"content": response.choices[0].message.content
}
)
# Render response
display(Markdown("## ✨ Assistant:\\n" + response.choices[0].message.content + "\\n"))
💬 Step 5. Chat
ในขั้นสุดท้าย เราจะเรียกใช้งาน chatbot() เพื่อเริ่มคุยกับ AI เลย:
Rational Buddhism, to me, means understanding the internal work Buddhism espouses to make yourself happier, better off, more present and in control of your emotions—being a better human being.
Everything can be taken from a man but one thing: the last of the human freedoms—to choose one’s attitude in any given set of circumstances, to choose one’s own way. — Viktor E. Frankl in Man’s Search for Meaning
And in the short amount of time between here and there, you have a limited amount of f*ck to give. — Mark Manson in The Subtle Art of Not Giving a F*ck
เราควรจะให้เวลาไปสิ่งที่สำคัญกับเรา และคอยดูไม่ให้สิ่งที่เรา don’t give a f*ck เข้ามาแย่งเวลาชีวิตเราไป
.
🪦 Lesson #5. Death
Were it not for the reality of death and our willingness to openly process it as a fact, we’d likely not cling to life at all. — Donald Miller in Hero on a Mission
There is tremendous freedom in learning that we can eliminate the nonessentials, that are no longer controlled by other people’s agenda, and that we get to choose. — Greg McKeown in Essentialism
ในทางกลับกัน ถ้าเรา say no ให้กับสิ่งที่ไม่เกี่ยวข้องหรือสำคัญกับชีวิตแล้ว เราจะมีพลังที่จะไปถึงเป้าหมายมากขึ้น และทำให้เราไปถึงฝั่งฝันได้ดีขึ้นและเร็วขึ้น:
One of the reasons I’ve amassed a large library of books over the years is because books are great go-to resource. — Gary Keller & Jay Papasan in The One Thing
Imagine yourself with a magic lamp … This genie only has two options … Option 1: You can be a genius—a world-class genius. Option 2: You can get to “Doable Greatness.” You can be 7/10 in six, seven, or maybe ten different areas of your life … Genius would give you one option. — Sean D’Souza in Suddenly Talented
The reason why we struggle to get skilled isn’t because we keep making mistakes. Instead, the opposite is true: We don’t make enough mistakes. — Sean D’Souza in Suddenly Talented
The key to marketing—and sales for that matter—is to invite the customer on a journey at the pace of a natural, healthy relationship. — Donald Miller in Marketing Made Simple
แม้ว่า ผมจะอ่านทวนบทความของตัวเองก่อน post แล้ว แต่ผมเพิ่งเจอว่า การอ่านของมนุษย์ไม่ได้ process ทุกตัวอักษร ทำให้เราสามารถมองข้ามการสะกดผิดหรือการใช้คำผิดได้ในบทความตัวเองได้
สิ่งที่ผมทำได้ คือ ใช้ AI ให้เป็นประโยชน์
ในช่วงหลัง ๆ ผมเริ่มโยนบทความที่เขียนเสร็จแล้วให้กับ AI และถามหา 3 อย่าง:
ซึ่งพบว่า AI ช่วยผมตรวจพบข้อผิดพลาดเหล่านี้ได้เร็วกว่าและครบถ้วนมากกว่าถ้าเราอ่านเองมาก
แต่ก็ยังพบ limitation ของ AI อยู่ว่า AI จะไม่ได้ตรวจเจอทุกข้อผิดพลาด เช่น พิมพ์คำผิด จาก “รู้จักหนังสือ” เป็น “รู้สึกหนังสือ”
แสดงว่า นอกจากการใช้ AI แล้วผมยังควรจะต้องตรวจสอบเนื้อหาด้วยตัวเองอีกครั้งก่อนจะ publish งานออกไป
.
ข้อ 3. Deliver to a wider audience:
จุดอ่อนหนึ่งของผมคือการทำ marketing เพราะถ้าไม่นับการอ่านหนังสืออย่าง How to Grow Your Small Business ในปีนี้ ผมก็ไม่เคยเรียนหรือทำ marketing อย่างจริงจังมาก่อน
💪 ผมขอแนะนำ R Book for Psychologists หนังสือสอนใช้ภาษา R เพื่อการวิเคราะห์ข้อมูลทางจิตวิทยา ที่เขียนมาเพื่อนักจิตวิทยาที่ไม่เคยมีประสบการณ์เขียน code มาก่อน
ในหนังสือ เราจะปูพื้นฐานภาษา R และพาไปดูวิธีวิเคราะห์สถิติที่ใช้บ่อยกัน เช่น:
Correlation
t-tests
ANOVA
Reliability
Factor analysis
🚀 เมื่ออ่านและทำตามตัวอย่างใน R Book for Psychologists ทุกคนจะไม่ต้องพึง SPSS และ Excel ในการทำงานอีกต่อไป และสามารถวิเคราะห์ข้อมูลด้วยตัวเองได้ด้วยความมั่นใจ
เราอาจจะไม่สามารถเป็น version ที่ดีที่สุดของเราได้ แต่เราก็ยังต้องเลือก road less travelled เพราะแม้เราจะไม่กลายเป็น best version แต่เราจะเป็น better version ของตัวเองในทุก ๆ วัน
You can be wiser, but never the wisest.
.
ข้อ 7. The best investment is in yourself
การลงทุนที่ดีที่สุด คือ การลงทุนในตัวเอง
Work harder on yourself than you do on your job. — Jim Rohn
.
ข้อ 8. Skill is anything we can learn, even happiness
Two percent of the people think; three percent of the people think they think; and ninety-five percent of the people would rather die than think. — George Bernard Shaw
Focus on the future: โฟกัสไปกับโอกาสที่ดีกว่า เช่น ในขณะที่เรายังอยู่กับงานเดิม เราได้พัฒนาตัวเองน้อยลงและมีสุขภาพที่แย่ลงเมื่อเทียบกับการหางานใหม่ที่เราอาจได้เรียนรู้สิ่งใหม่ ๆ และได้เจอกับสภาพการทำงานที่ดีต่อสุภาพมากขึ้น