Extras
Create tasks from meeting transcription
Basics
- Basic use
- Basic use via mixin
- Handling errors with `Maybe` helper class
- Modes
- Making some fields optional
- Private vs public object field
- Automatic correction based on validation results
- Using attributes
- Using LLM API connections from config file
- Validation
- Custom validation using Symfony Validator
- Validation across multiple fields
Advanced
- Context caching
- Context caching
- Customize parameters of OpenAI client
- Custom prompts
- Using structured data as an input
- Extracting arguments of function or method
- Streaming partial updates during inference
- Providing example inputs and outputs
- Extracting scalar values
- Extracting sequences of objects
- Streaming
- Structures
Troubleshooting
LLM API Support
Extras
- Extraction of complex objects
- Extraction of complex objects (Anthropic)
- Extraction of complex objects (Cohere)
- Extraction of complex objects (Gemini)
- Embeddings
- Image processing - car damage detection
- Image to data (OpenAI)
- Image to data (Anthropic)
- Image to data (Gemini)
- Working directly with LLMs
- Working directly with LLMs and JSON - JSON mode
- Working directly with LLMs and JSON - JSON Schema mode
- Working directly with LLMs and JSON - MdJSON mode
- Working directly with LLMs and JSON - Tools mode
- Prompts
- Generating JSON Schema from PHP classes
- Generating JSON Schema dynamically
- Simple content summary
- Inference and tool use
- Create tasks from meeting transcription
- Translating UI text fields
- Web page to PHP objects
Extras
Create tasks from meeting transcription
Overview
This example demonstrates how you can create task assignments based on a transcription of meeting recording.
Example
<?php
$loader = require 'vendor/autoload.php';
$loader->add('Cognesy\\Instructor\\', __DIR__ . '../../src/');
use Cognesy\Instructor\Enums\Mode;
use Cognesy\Instructor\Instructor;
// Step 1: Define a class that represents the structure and semantics
// of the data you want to extract
enum TaskStatus : string {
case Pending = 'pending';
case Completed = 'completed';
}
enum Role : string {
case PM = 'pm';
case Dev = 'dev';
}
class Task {
public string $title;
public string $description;
public DateTimeImmutable $dueDate;
public Role $owner;
public TaskStatus $status;
}
class Tasks {
public DateTime $meetingDate;
/** @var Task[] */
public array $tasks;
}
// Step 2: Get the text (or chat messages) you want to extract data from
$text = <<<TEXT
Transcription of meeting from 2024-01-15, 16:00
---
PM: Hey, how's progress on the video transcription engine?
Dev: I've got basic functionality working, but accuracy isn't great yet. Might need to switch to a different API.
PM: So the plan is to research alternatives and provide a comparison? Is it possible by Jan 20th?
Dev: Sure, I'll make it available before the meeting.
PM: The one at 12?
Dev: Yes, at 12. By the way, are we still planning to support real-time transcription?
PM: Yes, it's a key feature. Speaking of which, I need to update the product roadmap. I'll have that ready by Jan 18th.
Dev: Got it. I'll keep that in mind while evaluating APIs. Oh, and the UI for the summary view is ready for review.
PM: Great, I'll take a look tomorrow by 10.
TEXT;
print("Input text:\n");
print($text . "\n\n");
// Step 3: Extract structured data using default language model API (OpenAI)
print("Extracting structured data using LLM...\n\n");
$tasks = (new Instructor)->respond(
messages: $text,
responseModel: Tasks::class,
model: 'gpt-4o',
mode: Mode::Json,
);
// Step 4: Now you can use the extracted data in your application
print("Extracted data:\n");
dump($tasks);
assert($tasks->meetingDate->format('Y-m-d') === '2024-01-15');
assert(count($tasks->tasks) == 3);
assert($tasks->tasks[0]->dueDate->format('Y-m-d') === '2024-01-20');
assert($tasks->tasks[0]->status === TaskStatus::Pending);
assert($tasks->tasks[0]->owner === Role::Dev);
assert($tasks->tasks[1]->dueDate->format('Y-m-d') === '2024-01-18');
assert($tasks->tasks[1]->status === TaskStatus::Pending);
assert($tasks->tasks[1]->owner === Role::PM);
assert($tasks->tasks[2]->dueDate->format('Y-m-d') === '2024-01-16');
assert($tasks->tasks[2]->status === TaskStatus::Pending);
assert($tasks->tasks[2]->owner === Role::PM);
?>