Skip to content

Commit

Permalink
bump
Browse files Browse the repository at this point in the history
  • Loading branch information
jph00 committed Aug 4, 2024
1 parent 6514f0b commit f13c6e5
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
2 changes: 1 addition & 1 deletion claudette/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.0.6"
__version__ = "0.0.7"
from .core import *
from .toolloop import *

26 changes: 26 additions & 0 deletions claudette/_modidx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')}}}
13 changes: 6 additions & 7 deletions claudette/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -228,27 +227,27 @@ 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")
mtype = mimetypes.types_map['.'+imghdr.what(None, h=data)]
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):
Expand All @@ -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'
2 changes: 1 addition & 1 deletion settings.ini
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit f13c6e5

Please sign in to comment.