# 提供示例来引导模型 examples = [ lx.data.ExampleData( text="ROMEO. But soft! What light through yonder window breaks? It is the east, and Juliet is the sun.", extractions=[ lx.data.Extraction( extraction_class="character", extraction_text="ROMEO", attributes={"emotional_state": "wonder"} ), lx.data.Extraction( extraction_class="emotion", extraction_text="But soft!", attributes={"feeling": "gentle awe"} ), lx.data.Extraction( extraction_class="relationship", extraction_text="Juliet is the sun", attributes={"type": "metaphor"} ), ] ) ]
运行提取:
将你的输入文本和提示词材料传递给lx.extract函数。
1 2 3 4 5 6 7 8 9 10
# 你要处理的输入文本 input_text = "Lady Juliet gazed longingly at the stars, her heart aching for Romeo" # 运行提取 result = lx.extract( text_or_documents=input_text, prompt_description=prompt, examples=examples, model_id="gemini-2.5-flash", # 推荐的默认模型 )