Skip to content

Commit

Permalink
Merge branch 'main' into typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-dixon committed Oct 11, 2024
2 parents 09a59a1 + 4509ceb commit 3832981
Show file tree
Hide file tree
Showing 22 changed files with 862 additions and 74 deletions.
160 changes: 140 additions & 20 deletions docs/src/_templates/header.html
Original file line number Diff line number Diff line change
@@ -1,33 +1,131 @@
{% extends "!header.html" %}

{% block header_logo %}
<a href="{{ pathto(master_doc) }}" class="flex items-center mr-6">
{%- if logo_url %}
<img height="24" width="120" class="mr-2 dark:invert" src="{{ logo_url }}" alt="Logo" />
{%- endif -%}
{%- if theme_logo_dark and not logo_url %}
<img width="120" height="24" class="mr-2 hidden dark:block" src="{{ pathto('_static/' + theme_logo_dark, 1) }}" alt="Logo" />
{%- endif -%}
{%- if theme_logo_light and not logo_url %}
<img width="120" height="24" class="mr-2 dark:hidden" src="{{ pathto('_static/' + theme_logo_light, 1) }}" alt="Logo" />
{%- endif -%}
</a>
{% endblock header_logo %}
<style>
:root {
--color-1: 0 100% 63%;
--color-2: 270 100% 63%;
--color-3: 210 100% 63%;
--color-4: 195 100% 63%;
--color-5: 90 100% 63%;
}

@keyframes rainbow {
0% { background-position: 0%; }
100% { background-position: 200%; }
}

.github-star-btn {
height: 2.2rem;
padding: 0.5rem 1rem;
display: inline-flex;
align-items: center;
justify-content: center;
border-radius: 0.75rem;
font-weight: 500;
font-size: 14px;
cursor: pointer;
border: 0;
position: relative;
background-size: 200%;
background-clip: padding-box, border-box, border-box;
background-origin: border-box;
border: calc(0.08 * 1rem) solid transparent;
color: #fff;
background-image:
linear-gradient(#121213, #121213),
linear-gradient(#121213 50%, rgba(18,18,19,0.6) 80%, rgba(18,18,19,0)),
linear-gradient(90deg, hsl(var(--color-1)), hsl(var(--color-5)), hsl(var(--color-3)), hsl(var(--color-4)), hsl(var(--color-2)));
animation: rainbow 2s infinite linear;
}

.github-star-btn::before {
content: '';
position: absolute;
bottom: -20%;
left: 50%;
z-index: 0;
height: 20%;
width: 60%;
transform: translateX(-50%);
background: linear-gradient(90deg, hsl(var(--color-1)), hsl(var(--color-5)), hsl(var(--color-3)), hsl(var(--color-4)), hsl(var(--color-2)));
background-size: 200%;
filter: blur(calc(0.8 * 1rem));
animation: rainbow 2s infinite linear;
}

.dark .github-star-btn {
color: #030303;
background-image:
linear-gradient(#fff, #fff),
linear-gradient(#fff 50%, rgba(255,255,255,0.6) 80%, rgba(0,0,0,0)),
linear-gradient(90deg, hsl(var(--color-1)), hsl(var(--color-5)), hsl(var(--color-3)), hsl(var(--color-4)), hsl(var(--color-2)));
}


nav a {
white-space: nowrap;
}

.twin-btn-container {
display: flex;
gap: 1rem;
align-items: center;
flex-direction: row-reverse;
width: 100%;
}

@media (min-width: 768px) {
.twin-btn-container {
flex-direction: row;
justify-content: flex-end;
}
}


@media (max-width: 640px) {
.github-star-btn {
font-size: 12px;
padding: 0.4rem 0.8rem;
}
}



</style>


<a href="{{ pathto(master_doc) }}" class="flex items-center mr-6">
{%- if logo_url %}
<img height="24" width="120" class="mr-2 dark:invert" src="{{ logo_url }}" alt="Logo" style="min-width: 120px; max-width: 120px;" />
{%- endif -%}
{%- if theme_logo_dark and not logo_url %}
<img width="120" height="24" class="mr-2 hidden dark:block" src="{{ pathto('_static/' + theme_logo_dark, 1) }}" alt="Logo" style="min-width: 120px; max-width: 120px;" />
{%- endif -%}
{%- if theme_logo_light and not logo_url %}
<img width="120" height="24" class="mr-2 dark:hidden" src="{{ pathto('_static/' + theme_logo_light, 1) }}" alt="Logo" style="min-width: 120px; max-width: 120px;" />
{%- endif -%}
</a>
{% endblock header_logo %}

{%- block header_right %}
<div class="flex items-center justify-between flex-1 space-x-2 sm:space-x-4 md:justify-end">
<div class="flex flex-wrap items-center justify-between flex-1 space-x-2 sm:space-x-4 md:justify-end">
{%- if docsearch or hasdoc('search') %}
<div class="ml-4">
<a href="https://github.com/madcowd/ell" target="_blank" rel="noopener noreferrer" class="github-star-btn flex items-center px-3 py-2 rounded-md transition-colors rounded-md border border-gray-500 px-4" >
<svg class="w-5 h-5 mr-2" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true">
<div class="twin-btn-container">
<div class="github-star-btn-container md:w-auto mb-2 md:mb-0">
<a href="https://github.com/madcowd/ell" target="_blank" rel="noopener noreferrer" class="github-star-btn whitespace-nowrap">
<svg class="w-5 h-5 mr-2 hidden sm:inline-block" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true">
<path fill-rule="evenodd" d="M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z" clip-rule="evenodd" />
</svg>
<span class="font-medium">Star on GitHub</span>
<svg class="star-icon w-4 h-4 ml-2" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path d="M12 2L15.09 8.26L22 9.27L17 14.14L18.18 21.02L12 17.77L5.82 21.02L7 14.14L2 9.27L8.91 8.26L12 2Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<animate attributeName="opacity" values="1;0.7;1" dur="2s" repeatCount="indefinite" />
</path>
</svg>
<span class="ml-2 star-count" data-stars="0" style="min-width: 3ch; text-align: center;">0</span>
</a>
</div>

<script>
document.addEventListener('DOMContentLoaded', function() {
const starBtn = document.querySelector('.github-star-btn');
Expand Down Expand Up @@ -58,18 +156,40 @@

</script>

<div class="flex-1 w-full md:w-auto md:flex-none">
<div class="searchbox-container w-full md:w-auto md:flex-none">
{%- include "searchbox.html" %}
</div>

<script>
document.addEventListener('DOMContentLoaded', function() {
const searchInput = document.querySelector('.searchbox-container input');
const starBtnContainer = document.querySelector('.github-star-btn-container');

if (searchInput && starBtnContainer) {
const isMobile = window.innerWidth < 768; // Adjust this breakpoint as needed

if (isMobile) {
searchInput.addEventListener('focus', function() {
starBtnContainer.style.display = 'none';
});

searchInput.addEventListener('blur', function() {
starBtnContainer.style.display = 'block';
});
}
}
});
</script>
</div>
{%- endif %}

{%- block extra_header_link_icons %}
<nav class="flex items-center space-x-1">
<nav class="flex items-center space-x-1 mt-2 md:mt-0">
{%- if theme_extra_header_link_icons|tobool %}
{%- for text,url in theme_extra_header_link_icons.items() %}
{%- if url is mapping %}
<a href="{{ url.link }}" title="Visit {{ text }}" rel="noopener nofollow">
<div
<div
class="inline-flex items-center justify-center px-0 text-sm font-medium transition-colors rounded-md disabled:opacity-50 disabled:pointer-events-none hover:bg-accent hover:text-accent-foreground h-9 w-9">
{{ url.icon }}
</div>
Expand Down
4 changes: 0 additions & 4 deletions docs/src/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@
"AI Jobs Board": "https://jobs.ell.so",
},
"extra_header_link_icons": {
"GitHub": {
"link": "https://github.com/MadcowD/ell",
"icon": """<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" height="18" fill="currentColor"><path d="M12 0C5.373 0 0 5.373 0 12c0 5.302 3.438 9.8 8.205 11.387.6.111.82-.261.82-.577 0-.285-.01-1.04-.015-2.04-3.338.726-4.042-1.61-4.042-1.61-.546-1.387-1.333-1.757-1.333-1.757-1.09-.745.083-.729.083-.729 1.205.084 1.84 1.238 1.84 1.238 1.07 1.835 2.807 1.305 3.492.998.108-.775.418-1.305.76-1.605-2.665-.305-5.466-1.332-5.466-5.93 0-1.31.467-2.38 1.235-3.22-.125-.303-.535-1.523.115-3.176 0 0 1.005-.322 3.3 1.23.955-.265 1.98-.398 3-.403 1.02.005 2.045.138 3 .403 2.28-1.552 3.285-1.23 3.285-1.23.655 1.653.245 2.873.12 3.176.77.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.62-5.475 5.92.43.37.81 1.1.81 2.22 0 1.605-.015 2.895-.015 3.285 0 .32.215.694.825.575C20.565 21.795 24 17.3 24 12c0-6.627-5.373-12-12-12z"/></svg>""",
},
"Discord": {
"link": "https://discord.gg/vWntgU52Xb",
"icon": """<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512" height="18" fill="currentColor"><!--!Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M524.5 69.8a1.5 1.5 0 0 0 -.8-.7A485.1 485.1 0 0 0 404.1 32a1.8 1.8 0 0 0 -1.9 .9 337.5 337.5 0 0 0 -14.9 30.6 447.8 447.8 0 0 0 -134.4 0 309.5 309.5 0 0 0 -15.1-30.6 1.9 1.9 0 0 0 -1.9-.9A483.7 483.7 0 0 0 116.1 69.1a1.7 1.7 0 0 0 -.8 .7C39.1 183.7 18.2 294.7 28.4 404.4a2 2 0 0 0 .8 1.4A487.7 487.7 0 0 0 176 479.9a1.9 1.9 0 0 0 2.1-.7A348.2 348.2 0 0 0 208.1 430.4a1.9 1.9 0 0 0 -1-2.6 321.2 321.2 0 0 1 -45.9-21.9 1.9 1.9 0 0 1 -.2-3.1c3.1-2.3 6.2-4.7 9.1-7.1a1.8 1.8 0 0 1 1.9-.3c96.2 43.9 200.4 43.9 295.5 0a1.8 1.8 0 0 1 1.9 .2c2.9 2.4 6 4.9 9.1 7.2a1.9 1.9 0 0 1 -.2 3.1 301.4 301.4 0 0 1 -45.9 21.8 1.9 1.9 0 0 0 -1 2.6 391.1 391.1 0 0 0 30 48.8 1.9 1.9 0 0 0 2.1 .7A486 486 0 0 0 610.7 405.7a1.9 1.9 0 0 0 .8-1.4C623.7 277.6 590.9 167.5 524.5 69.8zM222.5 337.6c-29 0-52.8-26.6-52.8-59.2S193.1 219.1 222.5 219.1c29.7 0 53.3 26.8 52.8 59.2C275.3 311 251.9 337.6 222.5 337.6zm195.4 0c-29 0-52.8-26.6-52.8-59.2S388.4 219.1 417.9 219.1c29.7 0 53.3 26.8 52.8 59.2C470.7 311 447.5 337.6 417.9 337.6z"/></svg>""",
Expand Down
2 changes: 1 addition & 1 deletion docs/src/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Installing ell

.. code-block:: bash
pip install -U ell-ai[anthropic]
pip install -U 'ell-ai[anthropic]'
2. Verify installation:

Expand Down
Binary file modified ell-studio/public/favicon.ico
Binary file not shown.
22 changes: 13 additions & 9 deletions ell-studio/src/pages/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,23 @@ print(greeting)`}
<ScrollArea className="h-screen">
<div className="space-y-4 p-4">
{lmps.map((lmp) => (
<Card
key={lmp.name}
className="cursor-pointer hover:bg-accent/50 transition-colors duration-200"
onClick={(e) => toggleExpand(lmp.name, e)}
<Link
to={`/lmp/${lmp.name}`}
className="flex cursor-pointer hover:bg-accent/50 transition-colors duration-200"
onClick={(e) => e.stopPropagation()}
>
<Card
key={lmp.name}
className="cursor-pointer hover:bg-accent/50 rounded transition-colors duration-200"
onClick={(e) => toggleExpand(lmp.name, e)}
>
<CardHeader>
<div className="flex flex-col space-y-2">
<Link
to={`/lmp/${lmp.name}`}
className="text-xl font-semibold text-foreground hover:text-primary break-words"
onClick={(e) => e.stopPropagation()}
<div
className="text-xl font-semibold text-foreground hover:text-primary break-words cursor-pointer"
>
{lmp.name}
</Link>
</div>
<div className="flex space-x-2">
<span className="text-xs px-2 py-1 rounded-full bg-muted text-muted-foreground">
ID: {truncateId(lmp.lmp_id)}
Expand All @@ -150,6 +153,7 @@ print(greeting)`}
</div>
</CardContent>
</Card>
</Link>
))}
</div>
</ScrollArea>
Expand Down
2 changes: 1 addition & 1 deletion src/ell/lmp/_track.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def _write_invocation(func, invocation_id, latency_ms, prompt_tokens, completion
# Write to the blob store
blob_id = config.store.blob_store.store_blob(
json.dumps(invocation_contents.model_dump(
), default=str).encode('utf-8'),
), default=str, ensure_ascii=False).encode('utf-8'),
invocation_id
)
invocation_contents = InvocationContents(
Expand Down
2 changes: 1 addition & 1 deletion src/ell/lmp/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def wrapper(
elif isinstance(result, list) and all(isinstance(c, ContentBlock) for c in result):
content_results = result
else:
content_results = [ContentBlock(text=_lstr(json.dumps(result),origin_trace=_invocation_origin))]
content_results = [ContentBlock(text=_lstr(json.dumps(result, ensure_ascii=False),origin_trace=_invocation_origin))]
except TypeError as e:
raise TypeError(f"Failed to convert tool use result to ContentBlock: {e}. Tools must return json serializable objects. or a list of ContentBlocks.")
# XXX: Need to support images and other content types somehow. We should look for images inside of the the result and then go from there.
Expand Down
2 changes: 1 addition & 1 deletion src/ell/providers/anthropic.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def _content_block_to_anthropic_format(content_block: ContentBlock):
if (image := content_block.image): return serialize_image_for_anthropic(image)
elif ((text := content_block.text) is not None): return dict(type="text", text=text)
elif (parsed := content_block.parsed):
return dict(type="text", text=json.dumps(parsed.model_dump()))
return dict(type="text", text=json.dumps(parsed.model_dump(), ensure_ascii=False))
elif (tool_call := content_block.tool_call):
return dict(
type="tool_use",
Expand Down
2 changes: 1 addition & 1 deletion src/ell/providers/bedrock.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def content_block_to_bedrock_format(content_block: ContentBlock) -> Dict[str, An
elif content_block.parsed:
return {
"type": "text",
"text": json.dumps(content_block.parsed.model_dump())
"text": json.dumps(content_block.parsed.model_dump(), ensure_ascii=False)
}
elif content_block.tool_call:
return {
Expand Down
4 changes: 2 additions & 2 deletions src/ell/providers/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def translate_to_provider(self, ell_call : EllCallParams) -> Dict[str, Any]:
final_call_params.pop("stream_options", None)
if ell_call.tools:
final_call_params.update(
tool_choice="auto",
tool_choice=final_call_params.get("tool_choice", "auto"),
tools=[
dict(
type="function",
Expand All @@ -64,7 +64,7 @@ def translate_to_provider(self, ell_call : EllCallParams) -> Dict[str, Any]:
type="function",
function=dict(
name=tool_call.tool.__name__,
arguments=json.dumps(tool_call.params.model_dump())
arguments=json.dumps(tool_call.params.model_dump(), ensure_ascii=False)
)
) for tool_call in tool_calls ],
role="assistant",
Expand Down
2 changes: 1 addition & 1 deletion src/ell/stores/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class SQLStore(ell.store.Store):
def __init__(self, db_uri: str, blob_store: Optional[ell.store.BlobStore] = None):
self.engine = create_engine(db_uri,
json_serializer=lambda obj: json.dumps(pydantic_ltype_aware_cattr.unstructure(obj),
sort_keys=True, default=repr))
sort_keys=True, default=repr, ensure_ascii=False))

SQLModel.metadata.create_all(self.engine)
self.open_files: Dict[str, Dict[str, Any]] = {}
Expand Down
4 changes: 3 additions & 1 deletion src/ell/types/studio.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ def should_externalize(self) -> bool:
]

total_size = sum(
len(json.dumps(field, default=(lambda x: json.dumps(x.model_dump(), default=str) if isinstance(x, BaseModel) else str(x))).encode('utf-8')) for field in json_fields if field is not None
len(json.dumps(field, default=(lambda x: json.dumps(x.model_dump(), default=str, ensure_ascii=False)
if isinstance(x, BaseModel) else str(x)), ensure_ascii=False).encode('utf-8'))
for field in json_fields if field is not None
)
# print("total_size", total_size)

Expand Down
6 changes: 3 additions & 3 deletions src/ell/util/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ def handle_complex_types(obj):


def compute_state_cache_key(ipstr, fn_closure):
_global_free_vars_str = f"{json.dumps(get_immutable_vars(fn_closure[2]), sort_keys=True, default=repr)}"
_free_vars_str = f"{json.dumps(get_immutable_vars(fn_closure[3]), sort_keys=True, default=repr)}"
_global_free_vars_str = f"{json.dumps(get_immutable_vars(fn_closure[2]), sort_keys=True, default=repr, ensure_ascii=False)}"
_free_vars_str = f"{json.dumps(get_immutable_vars(fn_closure[3]), sort_keys=True, default=repr, ensure_ascii=False)}"
state_cache_key = hashlib.sha256(f"{ipstr}{_global_free_vars_str}{_free_vars_str}".encode('utf-8')).hexdigest()
return state_cache_key

Expand All @@ -103,7 +103,7 @@ def prepare_invocation_params(params):
cleaned_invocation_params = pydantic_ltype_aware_cattr.unstructure(invocation_params)

# Thisis because we wneed the caching to work on the hash of a cleaned and serialized object.
jstr = json.dumps(cleaned_invocation_params, sort_keys=True, default=repr)
jstr = json.dumps(cleaned_invocation_params, sort_keys=True, default=repr, ensure_ascii=False)

consumes = set()
import re
Expand Down
2 changes: 1 addition & 1 deletion x/openai_realtime/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
reference/
reference/
Loading

0 comments on commit 3832981

Please sign in to comment.