This project demonstrates how to use LangExtract with OpenAI models to extract structured information such as person names, countries, and skill sets from unstructured text.
- Define extraction examples (
EXAMPLES) and a prompt (PROMPT) for guidance. - Pass input text to the
extract_resultfunction. - Extracted entities (person_name, country, skill-set) are returned with attributes and character intervals.
person_name Amir {'country': 'Egypt'}
country Cairo {'person_name': 'Amir'}
skill-set sketching intricate blueprints {'person_name': 'Amir'}
pip install -r requirements.txt- Python 3.8+
- LangExtract
- OpenAI API key set as environment variable:
export OPENAI_API_KEY="your_api_key_here"