Skip to content

Commit

Permalink
AttrDict
Browse files Browse the repository at this point in the history
  • Loading branch information
jph00 committed Sep 27, 2024
1 parent 5c33028 commit c654464
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions 00_core.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2696,7 +2696,7 @@
"source": [
"#| exports\n",
"def _str_if_needed(o):\n",
" if isinstance(o, (list,tuple,abc.Mapping)) or hasattr(o, '__pydantic_serializer__'): return o\n",
" if isinstance(o, (list,tuple,abc.Mapping,L)) or hasattr(o, '__pydantic_serializer__'): return o\n",
" return str(o)"
]
},
Expand Down Expand Up @@ -2762,7 +2762,7 @@
" if isinstance(content, abc.Mapping): content=content.get('content', content)\n",
" if not isinstance(content, list): content=[content]\n",
" content = [_mk_content(o, cache if islast else False) for islast,o in loop_last(content)] if content else '.'\n",
" return dict(role=role, content=content, **kw)"
" return AttrDict(dict(role=role, content=content, **kw))"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions claudette/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def text_msg(s:str, cache=False)->dict:

# %% ../00_core.ipynb
def _str_if_needed(o):
if isinstance(o, (list,tuple,abc.Mapping)) or hasattr(o, '__pydantic_serializer__'): return o
if isinstance(o, (list,tuple,abc.Mapping,L)) or hasattr(o, '__pydantic_serializer__'): return o
return str(o)

# %% ../00_core.ipynb
Expand All @@ -311,7 +311,7 @@ def mk_msg(content, # A string, list, or dict containing the contents of the mes
if isinstance(content, abc.Mapping): content=content.get('content', content)
if not isinstance(content, list): content=[content]
content = [_mk_content(o, cache if islast else False) for islast,o in loop_last(content)] if content else '.'
return dict(role=role, content=content, **kw)
return AttrDict(dict(role=role, content=content, **kw))

# %% ../00_core.ipynb
models_aws = ('anthropic.claude-3-haiku-20240307-v1:0', 'anthropic.claude-3-sonnet-20240229-v1:0',
Expand Down

0 comments on commit c654464

Please sign in to comment.