-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 92bd901
Showing
23 changed files
with
6,479 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Sitemap: https://AnswerDotAI.github.io/claudia/sitemap.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
[ | ||
{ | ||
"objectID": "index.html", | ||
"href": "index.html", | ||
"title": "claudia", | ||
"section": "", | ||
"text": "This file will become your README and also the index of your documentation.", | ||
"crumbs": [ | ||
"claudia" | ||
] | ||
}, | ||
{ | ||
"objectID": "index.html#install", | ||
"href": "index.html#install", | ||
"title": "claudia", | ||
"section": "Install", | ||
"text": "Install\npip install claudia", | ||
"crumbs": [ | ||
"claudia" | ||
] | ||
}, | ||
{ | ||
"objectID": "index.html#how-to-use", | ||
"href": "index.html#how-to-use", | ||
"title": "claudia", | ||
"section": "How to use", | ||
"text": "How to use\nFill me in please! Don’t forget code examples:\n\n1+1\n\n2", | ||
"crumbs": [ | ||
"claudia" | ||
] | ||
}, | ||
{ | ||
"objectID": "core.html", | ||
"href": "core.html", | ||
"title": "Claudia", | ||
"section": "", | ||
"text": "basic and streaming chat\nimages\ntool use\n\n\nimport os\n# os.environ['ANTHROPIC_LOG'] = 'debug'\n\n\nmodel = models[1]", | ||
"crumbs": [ | ||
"Claudia" | ||
] | ||
}, | ||
{ | ||
"objectID": "core.html#setup", | ||
"href": "core.html#setup", | ||
"title": "Claudia", | ||
"section": "", | ||
"text": "basic and streaming chat\nimages\ntool use\n\n\nimport os\n# os.environ['ANTHROPIC_LOG'] = 'debug'\n\n\nmodel = models[1]", | ||
"crumbs": [ | ||
"Claudia" | ||
] | ||
}, | ||
{ | ||
"objectID": "core.html#client", | ||
"href": "core.html#client", | ||
"title": "Claudia", | ||
"section": "Client", | ||
"text": "Client\n\nsource\n\nmk_msg\n\n mk_msg (content, role='user', **kw)\n\nHelper to create a dict appropriate for a Claude message\n\nsource\n\n\nmk_msgs\n\n mk_msgs (msgs, **kw)\n\nHelper to set ‘assistant’ role on alternate messages\n\nsource\n\n\ncontents\n\n contents (r)\n\nHelp to get the contents from Claude response r\n\ncli = Anthropic()\n\n\nsource\n\n\nUsage.total\n\n Usage.total ()\n\n\nsource\n\n\nClient\n\n Client (model, cli=None)\n\nBasic Anthropic messages client\n\nc = Client(models[-1])\n\n\nfor o in c.stream('Hi'): print(o, end='')\n\nHello! How can I assist you today?\n\n\n\nc('Hi')\n\nToolsBetaMessage(id='msg_016a7tAmwNzGF7bMoySs2pDk', content=[TextBlock(text='Hello! How can I assist you today?', type='text')], model='claude-3-haiku-20240307', role='assistant', stop_reason='end_turn', stop_sequence=None, type='message', usage=In: 8; Out: 12; Total: 20)\n\n\n\nc.use\n\nIn: 16; Out: 24; Total: 40", | ||
"crumbs": [ | ||
"Claudia" | ||
] | ||
}, | ||
{ | ||
"objectID": "core.html#tool-use", | ||
"href": "core.html#tool-use", | ||
"title": "Claudia", | ||
"section": "Tool use", | ||
"text": "Tool use\n\nsource\n\nget_schema\n\n get_schema (f)\n\n\ndef silly_sum(\n # First thing to sum\n a:int,\n # Second thing to sum\n b:int=1,\n # A pointless argument\n c:list[int]=None,\n# The sum of the inputs\n) -> int:\n \"Adds a + b\"\n return a + b\n\n\nget_schema(silly_sum)\n\n{'name': 'silly_sum',\n 'description': 'Adds a + b',\n 'input_schema': {'type': 'object',\n 'properties': {'a': {'type': 'integer', 'description': 'First thing to sum'},\n 'b': {'type': 'integer',\n 'description': 'Second thing to sum',\n 'default': 1},\n 'c': {'type': 'array',\n 'description': 'A pointless argument',\n 'items': {'type': 'integer'},\n 'default': None}},\n 'required': ['a']}}\n\n\n\ndef sums(\n # First thing to sum\n a:int,\n # Second thing to sum\n b:int=1\n# The sum of the inputs\n) -> int:\n \"Adds a + b\"\n return a + b\n\n\npr = \"What is 6+3?\"\nsp = \"You must use the `sums` function instead of adding yourself, but don't mention what tools you use.\"\ntools=[get_schema(sums)]\n\n\nmsgs = mk_msgs(pr)\n\n\nr = c(msgs, sp=sp, tools=tools)\n\n\ndef call_func(c):\n fc = c.content[0]\n f = globals()[fc.name]\n return f(**fc.input)\n\n\nres = call_func(r)\nres\n\n9\n\n\n\nmsgs.append(mk_msg(r.content, role=r.role))\n\n\nmsgs.append(mk_msg([dict(type=\"tool_result\", tool_use_id=r.content[0].id, content=str(res))]))\n\n\nres = c(msgs, sp=sp, tools=tools)\n\n\ncontents(res)\n\n'The sum of 6 and 3 is 9.'", | ||
"crumbs": [ | ||
"Claudia" | ||
] | ||
}, | ||
{ | ||
"objectID": "core.html#xml-helpers", | ||
"href": "core.html#xml-helpers", | ||
"title": "Claudia", | ||
"section": "XML helpers", | ||
"text": "XML helpers\n\nsource\n\nhl_md\n\n hl_md (s, lang='xml')\n\nSyntax highlight s using lang\n\nsource\n\n\nto_xml\n\n to_xml (node, hl=False)\n\nConvert node to an XML string\n\nsource\n\n\nxt\n\n xt (tag, c=None, **kw)\n\nHelper to create appropriate data structure for to_xml\n\na = html([\n p('This is a paragraph'),\n hr(),\n xt('x-custom', foo='bar'),\n img(src='http://example.prg'),\n div([\n h1('This is a header'),\n h2('This is a sub-header', style='k:v'),\n ], _class='foo')\n])\n\n\nto_xml(a, True)\n\n<html>\n <p>This is a paragraph</p>\n <hr />\n <x-custom foo=\"bar\" />\n <img src=\"http://example.prg\" />\n <div class=\"foo\">\n <h1>This is a header</h1>\n <h2 style=\"k:v\">This is a sub-header</h2>\n </div>\n</html>\n\n\n\nsource\n\n\njson_to_xml\n\n json_to_xml (d:dict, rnm:str)\n\nConvert d to XML with root name rnm\n\na = dict(surname='Howard', firstnames=['Jeremy','Peter'],\n address=dict(state='Queensland',country='Australia'))\nprint(json_to_xml(a, 'person'))\n\n<person>\n <surname>Howard</surname>\n <firstnames>\n <item>Jeremy</item>\n <item>Peter</item>\n </firstnames>\n <address>\n <state>Queensland</state>\n <country>Australia</country>\n </address>\n</person>", | ||
"crumbs": [ | ||
"Claudia" | ||
] | ||
} | ||
] |
Oops, something went wrong.