Skip to content

Commit 11ff31d

Browse files
author
Solveit
committed
type annotations
1 parent 9b6fbc3 commit 11ff31d

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

nbs/00_core.ipynb

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,6 +2009,17 @@
20092009
"from fastcore.meta import delegates"
20102010
]
20112011
},
2012+
{
2013+
"cell_type": "code",
2014+
"execution_count": null,
2015+
"id": "162a5ba9",
2016+
"metadata": {},
2017+
"outputs": [],
2018+
"source": [
2019+
"#| export\n",
2020+
"from typing import Callable"
2021+
]
2022+
},
20122023
{
20132024
"cell_type": "code",
20142025
"execution_count": null,
@@ -2019,17 +2030,15 @@
20192030
"#| export\n",
20202031
"@delegates(completion)\n",
20212032
"def structured(\n",
2022-
" m, # The LiteLLM model string\n",
2023-
" msgs:list, # A list of messages \n",
2024-
" tool, # The tool to be used for creating the structured output. Can also be a class, dataclass or Pydantic model \n",
2033+
" m:str, # The LiteLLM model string\n",
2034+
" msgs:list, # A list of messages \n",
2035+
" tool:Callable, # The tool to be used for creating the structured output. Can also be a class, dataclass or Pydantic model \n",
20252036
" **kwargs):\n",
20262037
" \"Return the value of the tool call (generally used for structured outputs)\"\n",
2038+
"\n",
20272039
" t = lite_mk_func(tool)\n",
2028-
" \n",
20292040
" r = completion(m, msgs, tools=[t], tool_choice=t, **kwargs)\n",
2030-
"\n",
20312041
" args = json.loads(r.choices[0].message.tool_calls[0].function.arguments)\n",
2032-
"\n",
20332042
" return tool(**args)"
20342043
]
20352044
},
@@ -2065,7 +2074,7 @@
20652074
{
20662075
"data": {
20672076
"text/plain": [
2068-
"President(first='Thomas', last='Jefferson', spouse='Martha Jefferson Randolph', years_in_office='1801-1809', birthplace='Shadwell, Virginia', birth_year=1743)"
2077+
"President(first='Thomas', last='Jefferson', spouse='Martha Wayles Skelton', years_in_office='1801-1809', birthplace='Shadwell, Virginia, British America', birth_year=1743)"
20692078
]
20702079
},
20712080
"execution_count": null,

0 commit comments

Comments
 (0)