Skip to content

Commit

Permalink
fixes #16
Browse files Browse the repository at this point in the history
  • Loading branch information
jph00 committed Oct 27, 2024
1 parent 5e1acf1 commit 705ad09
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 63 deletions.
90 changes: 30 additions & 60 deletions 00_xml.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
{
"data": {
"text/plain": [
"doctype(source='\\nb8898fab\\n', content='\\nThis is a sample\\n')"
"doctype(source='\\n47e19350\\n', content='\\nThis is a \"sample\"\\n')"
]
},
"execution_count": null,
Expand All @@ -234,7 +234,7 @@
}
],
"source": [
"doc = 'This is a sample'\n",
"doc = 'This is a \"sample\"'\n",
"mk_doctype(doc)"
]
},
Expand All @@ -253,8 +253,8 @@
" ) -> tuple:\n",
" \"Create an `ft` format tuple for a single doc in Anthropic's recommended format\"\n",
" dt = mk_doctype(content, source)\n",
" content = Document_content(dt.content)\n",
" source = Source(dt.source)\n",
" content = Document_content(NotStr(dt.content))\n",
" source = Source(NotStr(dt.source))\n",
" return Document(source, content, index=index, **kwargs)"
]
},
Expand All @@ -276,19 +276,15 @@
"data": {
"text/markdown": [
"```html\n",
"<document index=\"1\" title=\"test\">\n",
" <source>\n",
"b8898fab\n",
"\n",
" <document-content>\n",
"This is a sample\n",
"</document-content>\n",
"</document>\n",
"\n",
"<document index=\"1\" title=\"test\"><source>\n",
"47e19350\n",
"<document-content>\n",
"This is a \"sample\"\n",
"</document-content></document>\n",
"```"
],
"text/plain": [
"document((source(('\\nb8898fab\\n',),{}), document-content(('\\nThis is a sample\\n',),{})),{'index': 1, 'title': 'test'})"
"document((source(('\\n47e19350\\n',),{}), document-content(('\\nThis is a \"sample\"\\n',),{})),{'index': 1, 'title': 'test'})"
]
},
"execution_count": null,
Expand Down Expand Up @@ -341,25 +337,15 @@
"text": [
"Here are some documents for you to reference for your task:\n",
"\n",
"<documents>\n",
" <document index=\"1\">\n",
" <source>\n",
"b8898fab\n",
"\n",
" <document-content>\n",
"This is a sample\n",
"</document-content>\n",
" </document>\n",
" <document index=\"2\">\n",
" <source>\n",
"<documents><document index=\"1\"><source>\n",
"47e19350\n",
"<document-content>\n",
"This is a \"sample\"\n",
"</document-content></document><document index=\"2\"><source>\n",
"doc.txt\n",
"\n",
" <document-content>\n",
"<document-content>\n",
"And another one\n",
"</document-content>\n",
" </document>\n",
"</documents>\n",
"\n"
"</document-content></document></documents>\n"
]
}
],
Expand Down Expand Up @@ -430,29 +416,19 @@
"```xml\n",
"Here are some documents for you to reference for your task:\n",
"\n",
"<documents>\n",
" <document index=\"1\">\n",
" <source>\n",
"<documents><document index=\"1\"><source>\n",
"samples/sample_core.py\n",
"\n",
" <document-content>\n",
"<document-content>\n",
"import inspect\n",
"empty = inspect.Parameter.empty\n",
"models = &#x27;claude-3-opus-20240229&#x27;,&#x27;claude-3-sonnet-20240229&#x27;,&#x27;claude-3-haiku-20240307&#x27;\n",
"</document-content>\n",
" </document>\n",
" <document index=\"2\">\n",
" <source>\n",
"models = 'claude-3-opus-20240229','claude-3-sonnet-20240229','claude-3-haiku-20240307'\n",
"</document-content></document><document index=\"2\"><source>\n",
"samples/sample_styles.css\n",
"\n",
" <document-content>\n",
"<document-content>\n",
".cell { margin-bottom: 1rem; }\n",
".cell &gt; .sourceCode { margin-bottom: 0; }\n",
".cell-output &gt; pre { margin-bottom: 0; }\n",
"</document-content>\n",
" </document>\n",
"</documents>\n",
"\n",
".cell > .sourceCode { margin-bottom: 0; }\n",
".cell-output > pre { margin-bottom: 0; }\n",
"</document-content></document></documents>\n",
"```"
],
"text/plain": [
Expand Down Expand Up @@ -505,19 +481,13 @@
"name": "stdout",
"output_type": "stream",
"text": [
"<documents>\n",
" <document index=\"1\">\n",
" <source>\n",
"<documents><document index=\"1\"><source>\n",
"samples/sample_core.py\n",
"\n",
" <document-content>\n",
"<document-content>\n",
"import inspect\n",
"empty = inspect.Parameter.empty\n",
"models = &#x27;claude-3-opus-20240229&#x27;,&#x27;claude-3-sonnet-20240229&#x27;,&#x27;claude-3-haiku-20240307&#x27;\n",
"</document-content>\n",
" </document>\n",
"</documents>\n",
"\n"
"models = 'claude-3-opus-20240229','claude-3-sonnet-20240229','claude-3-haiku-20240307'\n",
"</document-content></document></documents>\n"
]
}
],
Expand All @@ -540,7 +510,7 @@
" folder:str, # Folder name containing files to add to context\n",
" **kwargs # Passed to `folder2ctx`\n",
")->str: # XML for Claude context\n",
" return folder2ctx(folder, **kwargs)"
" print(folder2ctx(folder, **kwargs))"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions toolslm/xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def mk_doc(index:int, # The document index
) -> tuple:
"Create an `ft` format tuple for a single doc in Anthropic's recommended format"
dt = mk_doctype(content, source)
content = Document_content(dt.content)
source = Source(dt.source)
content = Document_content(NotStr(dt.content))
source = Source(NotStr(dt.source))
return Document(source, content, index=index, **kwargs)

# %% ../00_xml.ipynb 19
Expand Down Expand Up @@ -101,4 +101,4 @@ def folder2ctx_cli(
folder:str, # Folder name containing files to add to context
**kwargs # Passed to `folder2ctx`
)->str: # XML for Claude context
return folder2ctx(folder, **kwargs)
print(folder2ctx(folder, **kwargs))

0 comments on commit 705ad09

Please # to comment.