diff --git a/claudette/__init__.py b/claudette/__init__.py index 928294f..193d913 100644 --- a/claudette/__init__.py +++ b/claudette/__init__.py @@ -1,4 +1,4 @@ -__version__ = "0.0.6" +__version__ = "0.0.7" from .core import * from .toolloop import * diff --git a/claudette/_modidx.py b/claudette/_modidx.py index 3df9acc..2520afb 100644 --- a/claudette/_modidx.py +++ b/claudette/_modidx.py @@ -33,4 +33,30 @@ 'claudette.core.mk_toolres': ('core.html#mk_toolres', 'claudette/core.py'), 'claudette.core.text_msg': ('core.html#text_msg', 'claudette/core.py'), 'claudette.core.usage': ('core.html#usage', 'claudette/core.py')}, + 'claudette.core2': { 'claudette.core2.Chat': ('core.html#chat', 'claudette/core2.py'), + 'claudette.core2.Chat.__call__': ('core.html#chat.__call__', 'claudette/core2.py'), + 'claudette.core2.Chat.__init__': ('core.html#chat.__init__', 'claudette/core2.py'), + 'claudette.core2.Chat._stream': ('core.html#chat._stream', 'claudette/core2.py'), + 'claudette.core2.Chat.use': ('core.html#chat.use', 'claudette/core2.py'), + 'claudette.core2.Client': ('core.html#client', 'claudette/core2.py'), + 'claudette.core2.Client.__call__': ('core.html#client.__call__', 'claudette/core2.py'), + 'claudette.core2.Client.__init__': ('core.html#client.__init__', 'claudette/core2.py'), + 'claudette.core2.Client._r': ('core.html#client._r', 'claudette/core2.py'), + 'claudette.core2.Client._stream': ('core.html#client._stream', 'claudette/core2.py'), + 'claudette.core2.Message._repr_markdown_': ('core.html#message._repr_markdown_', 'claudette/core2.py'), + 'claudette.core2.Usage.__add__': ('core.html#usage.__add__', 'claudette/core2.py'), + 'claudette.core2.Usage.__repr__': ('core.html#usage.__repr__', 'claudette/core2.py'), + 'claudette.core2.Usage.total': ('core.html#usage.total', 'claudette/core2.py'), + 'claudette.core2._mk_content': ('core.html#_mk_content', 'claudette/core2.py'), + 'claudette.core2._mk_ns': ('core.html#_mk_ns', 'claudette/core2.py'), + 'claudette.core2.call_func': ('core.html#call_func', 'claudette/core2.py'), + 'claudette.core2.contents': ('core.html#contents', 'claudette/core2.py'), + 'claudette.core2.find_block': ('core.html#find_block', 'claudette/core2.py'), + 'claudette.core2.img_msg': ('core.html#img_msg', 'claudette/core2.py'), + 'claudette.core2.mk_msg': ('core.html#mk_msg', 'claudette/core2.py'), + 'claudette.core2.mk_msgs': ('core.html#mk_msgs', 'claudette/core2.py'), + 'claudette.core2.mk_tool_choice': ('core.html#mk_tool_choice', 'claudette/core2.py'), + 'claudette.core2.mk_toolres': ('core.html#mk_toolres', 'claudette/core2.py'), + 'claudette.core2.text_msg': ('core.html#text_msg', 'claudette/core2.py'), + 'claudette.core2.usage': ('core.html#usage', 'claudette/core2.py')}, 'claudette.toolloop': {'claudette.toolloop.Chat.toolloop': ('toolloop.html#chat.toolloop', 'claudette/toolloop.py')}}} diff --git a/claudette/core.py b/claudette/core.py index 995767c..1ae02d1 100644 --- a/claudette/core.py +++ b/claudette/core.py @@ -160,7 +160,6 @@ def mk_funcres(tuid, res): "Given tool use id and the tool result, create a tool_result response." return dict(type="tool_result", tool_use_id=tuid, content=str(res)) - # %% ../00_core.ipynb 103 def mk_toolres( r:abc.Mapping, # Tool use request response from Claude @@ -228,7 +227,7 @@ def __call__(self:Chat, self.h += mk_toolres(self.c.result, ns=self.tools, obj=self) return res -# %% ../00_core.ipynb 136 +# %% ../00_core.ipynb 142 def img_msg(data:bytes)->dict: "Convert image `data` into an encoded `dict`" img = base64.b64encode(data).decode("utf-8") @@ -236,19 +235,19 @@ def img_msg(data:bytes)->dict: r = dict(type="base64", media_type=mtype, data=img) return {"type": "image", "source": r} -# %% ../00_core.ipynb 138 +# %% ../00_core.ipynb 144 def text_msg(s:str)->dict: "Convert `s` to a text message" return {"type": "text", "text": s} -# %% ../00_core.ipynb 142 +# %% ../00_core.ipynb 148 def _mk_content(src): "Create appropriate content data structure based on type of content" if isinstance(src,str): return text_msg(src) if isinstance(src,bytes): return img_msg(src) return src -# %% ../00_core.ipynb 145 +# %% ../00_core.ipynb 151 def mk_msg(content, # A string, list, or dict containing the contents of the message role='user', # Must be 'user' or 'assistant' **kw): @@ -259,9 +258,9 @@ def mk_msg(content, # A string, list, or dict containing the contents of the mes content = [_mk_content(o) for o in content] if content else '.' return dict(role=role, content=content, **kw) -# %% ../00_core.ipynb 152 +# %% ../00_core.ipynb 158 models_aws = ('anthropic.claude-3-haiku-20240307-v1:0', 'anthropic.claude-3-sonnet-20240229-v1:0', 'anthropic.claude-3-opus-20240229-v1:0', 'anthropic.claude-3-5-sonnet-20240620-v1:0') -# %% ../00_core.ipynb 158 +# %% ../00_core.ipynb 164 models_goog = 'claude-3-haiku@20240307', 'claude-3-sonnet@20240229', 'claude-3-opus@20240229', 'claude-3-5-sonnet@20240620' diff --git a/settings.ini b/settings.ini index 0cac762..d190cfb 100644 --- a/settings.ini +++ b/settings.ini @@ -1,7 +1,7 @@ [DEFAULT] repo = claudette lib_name = claudette -version = 0.0.6 +version = 0.0.7 min_python = 3.8 license = apache2 black_formatting = False