Repository navigation
Replies: 2 comments
|
Hello,
This is how I fixed it: and then in infer: |
|
Nice work on the custom provider! The issue is that Azure's response format differs slightly from OpenAI's - the resolver expects Quick fix: def _is_resolver(self, sr: str):
extractions = []
extraction_text = str(sr).strip()
extraction_data = json.loads(extraction_text)
# Handle both dict and list responses
if isinstance(extraction_data, list):
for item in extraction_data:
extractions.append(all)
elif isinstance(extraction_data, dict):
# Your existing dict handling
extractions.append(all)
return extractionsBetter approach: output_str += f"Return a JSON object (not array) with 'extractions' key"This ensures Azure returns |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi everyone,
first of all, thanks a lot for your great work and for providing this library. I am fascinated by its few-shot capabilities.
Now to my question: I am using a custom provider like this for using AzureOpenAI models:
This works. However, I am using a special output_format which looks like this:
class BPMNAnnotation(BaseModel):
extraction_class: str = Field(..., description="Entity/type label")
extraction_text: str = Field(..., description="Exact text from source")
attributes: Optional[Dict[str, Union[str, int, float, bool, None]]] = Field(
None, description="Key-value attributes"
)
class BPMNExtractions(BaseModel):
extractions: List[BPMNAnnotation]
I am calling it like this:
result = lx.extract(
text_or_documents=process_summary,
prompt_description=instructions,
examples=examples,
model_id="azure-openai",
batch_length=1,
max_workers=1,
max_char_buffer=100000,
prompt_validation_level=pv.PromptValidationLevel.OFF,
fence_output=False,
language_model_params={
"api_version": self.llm_config.AZURE_OPENAI_API_VERSION,
"temperature": self.llm_config.AZURE_OPENAI_TEMPERATURE,
"top_p": self.llm_config.AZURE_OPENAI_TOP_P,
"deployment_name": self.llm_config.AZURE_OPENAI_DEPLOYMENT_NAME,
"max_tokens": self.llm_config.AZURE_OPENAI_MAX_TOKENS,
"response_format": self.output_model,
},
)
My problem is that the resolver tries to align everything and not just the value of extraction_text. How can i specify what field the resolver should align or not align? Your help would be much appreciated. Thanks a lot in advance.
All reactions