small constructor change and updated notebook (#3426)

small change in the pydantic definitions, same api. 

updated notebook with right constructure and added few shot example
This commit is contained in:
Eduard van Valkenburg 2023-04-24 19:42:38 +02:00 committed by GitHub
parent 49122a96e7
commit 46c9636012
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 58 additions and 6 deletions

View File

@ -55,14 +55,16 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"llm = AzureOpenAI(temperature=0, deployment_name=\"text-davinci-003\", verbose=True)\n", "fast_llm = AzureOpenAI(temperature=0.5, max_tokens=1000, deployment_name=\"gpt-35-turbo\", verbose=True)\n",
"smart_llm = AzureOpenAI(temperature=0, max_tokens=100, deployment_name=\"gpt-4\", verbose=True)\n",
"\n",
"toolkit = PowerBIToolkit(\n", "toolkit = PowerBIToolkit(\n",
" powerbi=PowerBIDataset(None, \"<dataset_id>\", ['table1', 'table2'], DefaultAzureCredential()), \n", " powerbi=PowerBIDataset(dataset_id=\"<dataset_id>\", table_names=['table1', 'table2'], credential=DefaultAzureCredential()), \n",
" llm=llm\n", " llm=smart_llm\n",
")\n", ")\n",
"\n", "\n",
"agent_executor = create_pbi_agent(\n", "agent_executor = create_pbi_agent(\n",
" llm=llm,\n", " llm=fast_llm,\n",
" toolkit=toolkit,\n", " toolkit=toolkit,\n",
" verbose=True,\n", " verbose=True,\n",
")" ")"
@ -141,6 +143,56 @@
"source": [ "source": [
"agent_executor.run(\"What unique values are there for dimensions2 in table2\")" "agent_executor.run(\"What unique values are there for dimensions2 in table2\")"
] ]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "6fd950e4",
"metadata": {},
"source": [
"## Example: add your own few-shot prompts"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "87d677f9",
"metadata": {},
"outputs": [],
"source": [
"#fictional example\n",
"few_shots = \"\"\"\n",
"Question: How many rows are in the table revenue?\n",
"DAX: EVALUATE ROW(\"Number of rows\", COUNTROWS(revenue_details))\n",
"----\n",
"Question: How many rows are in the table revenue where year is not empty?\n",
"DAX: EVALUATE ROW(\"Number of rows\", COUNTROWS(FILTER(revenue_details, revenue_details[year] <> \"\")))\n",
"----\n",
"Question: What was the average of value in revenue in dollars?\n",
"DAX: EVALUATE ROW(\"Average\", AVERAGE(revenue_details[dollar_value]))\n",
"----\n",
"\"\"\"\n",
"toolkit = PowerBIToolkit(\n",
" powerbi=PowerBIDataset(dataset_id=\"<dataset_id>\", table_names=['table1', 'table2'], credential=DefaultAzureCredential()), \n",
" llm=smart_llm,\n",
" examples=few_shots,\n",
")\n",
"agent_executor = create_pbi_agent(\n",
" llm=fast_llm,\n",
" toolkit=toolkit,\n",
" verbose=True,\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "33f4bb43",
"metadata": {},
"outputs": [],
"source": [
"agent_executor.run(\"What was the maximum of value in revenue in dollars in 2022?\")"
]
} }
], ],
"metadata": { "metadata": {

View File

@ -33,13 +33,13 @@ class PowerBIDataset(BaseModel):
If the model is not RLS enabled, this will be ignored. If the model is not RLS enabled, this will be ignored.
""" """
group_id: Optional[str]
dataset_id: str dataset_id: str
table_names: List[str] table_names: List[str]
group_id: Optional[str] = None
credential: Optional[Union[ChainedTokenCredential, InteractiveCredential]] = None credential: Optional[Union[ChainedTokenCredential, InteractiveCredential]] = None
token: Optional[str] = None token: Optional[str] = None
impersonated_user_name: Optional[str] = None impersonated_user_name: Optional[str] = None
sample_rows_in_table_info: int = Field(1, gt=0, le=10) sample_rows_in_table_info: int = Field(default=1, gt=0, le=10)
aiosession: Optional[aiohttp.ClientSession] = None aiosession: Optional[aiohttp.ClientSession] = None
schemas: Dict[str, str] = Field(default_factory=dict, init=False) schemas: Dict[str, str] = Field(default_factory=dict, init=False)