การดึงข้อมูลเชิงโครงสร้างจากข้อความ

การพัฒนาระบบ AI ด้วย OpenAI API

Francesca Donadoni

Curriculum Manager, DataCamp

การใช้งาน function calling

 

"ขณะนี้เรากำลังมองหา Data Scientist ที่มีทักษะสูงมาร่วมทีมที่สำนักงานใหญ่ของบริษัทในซานฟรานซิสโก รัฐแคลิฟอร์เนีย ในบทบาทนี้ คุณจะได้ทำงานกับโปรเจกต์วิเคราะห์ข้อมูลและสร้างโมเดลที่ซับซ้อน ซึ่งช่วยขับเคลื่อนการตัดสินใจเชิงกลยุทธ์ของเรา คุณสมบัติ: ประสบการณ์ด้าน data science กับ Python และ AWS, Azure หรือ GCP อย่างน้อย 3 ปี"

 

from openai import OpenAI

client = OpenAI(api_key="ENTER YOUR KEY 
                HERE")

response= client.chat.completions.create(
    model="gpt-4o-mini",
    messages=messages,

tools=function_definition,
)
การพัฒนาระบบ AI ด้วย OpenAI API

การตั้งค่า function calling

 

function_definition = [{

'type': 'function',
'function': {
'name': 'extract_job_info', 'description': 'Get the job information from the body of the input text', 'parameters': { ...
}
}]
การพัฒนาระบบ AI ด้วย OpenAI API

การตั้งค่า function calling

function_definition = [{
        'type': 'function',
        'function': {
          'name': 'extract_job_info',
          'description': 'Get the job information from the body of the input text',

'parameters': {'type': 'object', 'properties': 'job': {'type': 'string', 'description': 'Job title'}, 'location': {'type': 'string', 'description': 'Office location'}, ... }
}]
การพัฒนาระบบ AI ด้วย OpenAI API

ผลลัพธ์

 

response= client.chat.completions.create(
    model="gpt-4o-mini",
    messages=messages,
    tools=function_definition
)

print(response.choices[0].message.tool_calls[0].function.arguments)
{"job":"Data Scientist","location":"San Francisco, CA"}
การพัฒนาระบบ AI ด้วย OpenAI API

มาฝึกกันเถอะ!

การพัฒนาระบบ AI ด้วย OpenAI API

Preparing Video For Download...