Dates
date_range_search
date_range_search(search_term, content, metadata=None, image_url=None, max_characters=8000, api_key=None, azure_endpoint=None, api_version=None, model=None, max_retries=5)
Searches a document to find a date range matching the input query. Returns date ranges formatted as "DD-MMM-YYYY to DD-MMM-YYYY".
This function uses Azure OpenAI to search through document content for date ranges that match the provided search term. The response is validated to ensure it follows the expected date range format before being returned.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
search_term
|
str
|
The search query to find date ranges in the document |
required |
content
|
str
|
The main body text of the document to search through |
required |
metadata
|
dict
|
Optional additional information describing the content context |
None
|
image_url
|
str
|
Optional signed or public URL where an image can be found for analysis |
None
|
max_characters
|
int
|
Maximum number of text characters (excluding images) from |
8000
|
api_key
|
str
|
Access key for the Azure OpenAI resource |
None
|
azure_endpoint
|
str
|
Your Azure endpoint URL, including the resource
(e.g. https://example-resource.azure.openai.com/). If not provided,
defaults to environment variable |
None
|
api_version
|
str
|
API version for the Azure OpenAI resource |
None
|
model
|
str
|
Model deployment name within the Azure resource. If not provided,
defaults to environment variable |
None
|
max_retries
|
int
|
Maximum number of unsuccessful call attempts to the OpenAI service before returning an error. |
5
|
Returns:
Type | Description |
---|---|
str
|
Date range matching the query formatted as "DD-MMM-YYYY to DD-MMM-YYYY", or empty string if no valid date range is found. Supports partial formats like "05-Dec to 12-Dec" when full dates aren't available. |
Examples:
>>> date_range_search("project timeline", "The project runs from 15-Jan-2024 to 28-Feb-2024")
"15-Jan-2024 to 28-Feb-2024"
>>> date_range_search("vacation dates", "I'll be away from 5-Jul to 12-Jul")
"05-Jul to 12-Jul"
date_search
date_search(search_term, content, metadata=None, image_url=None, max_characters=8000, api_key=None, azure_endpoint=None, api_version=None, model=None, max_retries=5)
Searches a document to find a date matching the input query. Returns dates formatted as "DD-MMM-YYYY".
Parameters:
Name | Type | Description | Default |
---|---|---|---|
search_term
|
str
|
The search query |
required |
content
|
str
|
The main-body of the prompt |
required |
metadata
|
dict
|
Any additional information describing the content |
None
|
image_url
|
str
|
A signed or public URL where an image can be found |
None
|
max_characters
|
int
|
Maximum number of text characters (excluding images) from |
8000
|
api_key
|
str
|
Access key for the Azure OpenAI resource |
None
|
azure_endpoint
|
str
|
Your Azure endpoint, including the resource, e.g. https://example-resource.azure.openai.com/. if not provided will default to environment variable |
None
|
api_version
|
str
|
API version for Azure resource. |
None
|
model
|
str
|
Model deployment name within the Azure resource. If not provided will default to environment variable |
None
|
max_retries
|
int
|
Maximum number of unsuccessful call attempts to the OpenAI service before returning an error. |
5
|
Returns:
Type | Description |
---|---|
str
|
Date matching the query, or empty string if no date found. Dates are formatted as DD-MMM-YYYY |