Created
January 4, 2024 04:36
-
-
Save lummm/bb7ef0aab714d74331a53de6e01c66c8 to your computer and use it in GitHub Desktop.
Plan a query with OpenAI function calls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"description": """Specifies the steps to execute to service a user's query.""", | |
"name": "plan_query_in_steps", | |
"parameters": { | |
"type": "object", | |
"required": ["steps", "computed_values"], | |
"properties": { | |
"steps": { | |
"description": "Steps to apply in order to service the query", | |
"type": "array", | |
"items": { | |
"type": "object", | |
"required": ["entity_type", "entity_fields", "description"], | |
"properties": { | |
'entity_type': { | |
'type': 'string', | |
'enum': [str(k) for k in QueryableEntityType] | |
}, | |
"description": { | |
"type": "string", | |
"description": "How the entities for this step relate to the user's query." | |
}, | |
'entity_fields': { | |
'description': 'Fields of the entity that are relevant to the query.', | |
'items': {'type': 'string'}, | |
'type': 'array' | |
}, | |
'depends_on_step': { | |
"type": "object", | |
'description': 'Description of query plan step on which this step depends.', | |
'required': ['depends_on_step_index', 'relationship_to_parent_step'], | |
'properties': { | |
'depends_on_step_index': { | |
'description': '0-based index of the step from which the entity in this step can be retrieved.', | |
'type': 'integer' | |
}, | |
'relationship_to_parent_step': { | |
'type': 'string', | |
'enum': [str(k) for k in EntityRelationship], | |
'description': "Type of relationship to entity defined in 'depends_on_step_index', if one is specified." | |
} | |
}, | |
'type': 'object' | |
}, | |
'query_keyword_match': { | |
'type': 'object', | |
'description': 'Populated only for a root query step - defines a keyword from the query with which to retrieve an entity.', | |
'required': ['keyword', 'keyword_match_type'], | |
'properties': { | |
'keyword': { | |
'type': 'string', | |
'description': 'Keyword from query with which to retrieve the entity', | |
}, | |
'keyword_match_type': { | |
'type': 'string', | |
'description': 'Method with which to retrieve the entity using the keyword', | |
'enum': [str(k) for k in KeywordLookupType], | |
}, | |
}, | |
}, | |
} | |
}, | |
}, | |
"computed_values": { | |
"description": "Useful values to the user's query computed from fetched entities", | |
"type": "array", | |
"items": { | |
"type": "object", | |
"required": ["description", "step_index", "operation"], | |
"properties": { | |
"description": { | |
"type": "string", | |
"description": "Description of what the computed value represents and why it's relevant to the user's query", | |
}, | |
"step_index": { | |
"type": "integer", | |
"description": "Index of the step results from which to compute the value", | |
}, | |
"operation": { | |
"type": "string", | |
"description": "Operation to apply to all entites fetched in the specified step", | |
"enum": ["sum", "product", "average", "max", "min", "std_dev"], | |
}, | |
}, | |
}, | |
}, | |
}, | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment