This repository has been archived by the owner on Aug 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cole/def 5751 allow multiple textoutputs to render multiple text bloc…
…ks (#74)
- Loading branch information
1 parent
027b3e0
commit f005814
Showing
10 changed files
with
242 additions
and
232 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
examples/fast-api-server/library/piedpiper/spend_all_product.yaml
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,29 @@ | ||
display_name: Spend all products | ||
description: | | ||
Show the spend for all products (top 5) | ||
sample_questions: | ||
- show spend for all products | ||
parameters: | ||
json_schema: | ||
type: object | ||
properties: {} | ||
required: [] | ||
type: DuckDBQueryFunction | ||
dataset: 'dummy-data/' | ||
sqls: | ||
- | | ||
SELECT purchases.product, SUM(purchases.amount) as amount, | ||
FROM "purchases.csv" | ||
GROUP BY purchases.product | ||
ORDER BY amount DESC | ||
LIMIT 5 | ||
visualizations: | ||
- | | ||
def create_chart_config(dataframes): | ||
df = dataframes[0] | ||
data = [{'x': df.iloc[:, 0].tolist(), 'y': df.iloc[:, 1].tolist(), 'type': 'bar'}] | ||
layout = {'title': 'Spend per Product', 'xaxis': {'title': 'Product'}, 'yaxis': {'title': 'Total Spend'}} | ||
result = {'data': data, 'layout': layout} | ||
return result | ||
summarization: 'Describe the spend per product' |
29 changes: 0 additions & 29 deletions
29
examples/fast-api-server/library/piedpiper/spend_per_product.yaml
This file was deleted.
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
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
59 changes: 59 additions & 0 deletions
59
packages/openassistants-react/src/components/chat-content.tsx
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,59 @@ | ||
import React from 'react'; | ||
import { MemoizedReactMarkdown } from './markdown'; | ||
import remarkGfm from 'remark-gfm'; | ||
import { CodeBlock } from './ui'; | ||
|
||
export interface ChatContentProps { | ||
content: string; | ||
} | ||
|
||
export const ChatContent = ({ content }: ChatContentProps) => { | ||
return ( | ||
<div> | ||
<MemoizedReactMarkdown | ||
className={`prose break-words prose-p:leading-relaxed prose-pre:p-0`} | ||
remarkPlugins={[remarkGfm]} | ||
components={{ | ||
p({ children }) { | ||
return <p className="mb-2 last:mb-0">{children}</p>; | ||
}, | ||
code({ node, inline, className, children, ...props }) { | ||
if (children.length) { | ||
if (children[0] == '▍') { | ||
return ( | ||
<span className="mt-1 animate-pulse cursor-default">▍</span> | ||
); | ||
} | ||
|
||
children[0] = (children[0] as string).replace('`▍`', '▍'); | ||
} | ||
|
||
const match = /language-(\w+)/.exec(className || ''); | ||
|
||
if (inline) { | ||
return ( | ||
<code className={className} {...props}> | ||
{children} | ||
</code> | ||
); | ||
} | ||
return ( | ||
<div> | ||
{ | ||
<CodeBlock | ||
key={Math.random()} | ||
language={(match && match[1]) || ''} | ||
value={String(children).replace(/\n$/, '')} | ||
{...props} | ||
/> | ||
} | ||
</div> | ||
); | ||
}, | ||
}} | ||
> | ||
{content} | ||
</MemoizedReactMarkdown> | ||
</div> | ||
); | ||
}; |
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
Oops, something went wrong.