Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
CNSeniorious000 committed Aug 23, 2024
1 parent c873c50 commit 19de62a
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 5 deletions.
2 changes: 1 addition & 1 deletion reasonify-headless/reasonify/core/loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def reply(*messages: str):

@tool
def end_of_turn():
"""end this round of conversation and pass the microphone to the user"""
"""end this round of conversation and pass the microphone to the user. NEVER use this until you've seen your response is as your expected"""
c["end"] = True


Expand Down
6 changes: 4 additions & 2 deletions reasonify-headless/reasonify/examples/async.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
print(i)
reply("Do you want to know more about async generators?")
end_of_turn()
-
- source: end_of_turn()

- Yes! How can I `yield from` an async generator?

Expand All @@ -46,4 +47,5 @@
await g()
reply("This will print 1, 2, 3.")
end_of_turn()
-
- source: end_of_turn()
3 changes: 2 additions & 1 deletion reasonify-headless/reasonify/examples/file.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
- source: |
reply(f"I can these files/dirs: {", ".join(map(str, paths))}")
end_of_turn()
-
- source: end_of_turn()

- I just uploaded a PNG file, can you find it?

Expand Down
2 changes: 2 additions & 0 deletions reasonify-headless/reasonify/templates/main.j2
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,6 @@ Some hints on how to write best code:
15. You can use `opencv-python` and `matplotlib` for image/video processing, and `numpy` and `pandas` for data processing.
16. When asked about programming-related questions, first consider searching GitHub / PyPI

永远不要把 read_page 的内容直接 reply 给用户!

{% chat -%}
27 changes: 27 additions & 0 deletions src/lib/components/Chat.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
import { type Chain, initChain } from "../py";
import { clearApiCache, getApi } from "../py/api";
import Highlight from "./Highlight.svelte";
import Intro from "./Intro.svelte";
import Markdown from "./Markdown.svelte";
import { dev } from "$app/environment";
import { addFiles, mount } from "$lib/py/fs";
import { pyodideReady, reasonifyReady, startIconAnimation, stopIconAnimation } from "$lib/stores";
import { toast } from "svelte-sonner";
import { fly } from "svelte/transition";
export let chain: Chain;
Expand Down Expand Up @@ -45,8 +47,33 @@
$: running ? startIconAnimation() : stopIconAnimation();
function startWith(prompt: string) {
content = prompt;
start();
}
</script>

{#if !messages.length}
<Intro title="👋 Hi from Reasonify.">
<button in:fly|global={{ duration: 500, x: -5, delay: 100 }} on:click={() => startWith("阅读这个页面 https://mp.weixin.qq.com/s/voKXMpv8OiJUOzOqK4FSSg 然后告诉我,AI#DEA 这个比赛是谁举办的")}>
<div class="i-tabler-inner-shadow-bottom-right text-lg text-rose" />
AI#DEA 是谁举办的
</button>
<button in:fly|global={{ duration: 500, x: 5, delay: 150 }} on:click={() => startWith("搜索Google,计算《黑神话·悟空》自发售到现在,平均每小时增加多少用户量。")}>
<div class="i-tabler-building-lighthouse text-lg text-yellow" />
黑神话·悟空 每小时涨多少用户
</button>
<button in:fly|global={{ duration: 500, x: -5, delay: 300 }} on:click={() => startWith("用 matplotlib 给我画个华丽的爱心,四周有多个四角星。请确保不要画错成别的图形了!记得先安装!")}>
<div class="i-fluent-emoji-heart-with-ribbon text-lg text-blue" />
画个爱心
</button>
<button in:fly|global={{ duration: 500, x: 5, delay: 500 }} on:click={() => startWith("用 sklearn 的数据集,训练一个聚类模型,并可视化其结果")}>
<div class="i-tabler-brand-python text-lg text-blue" />
表演一个聚类算法
</button>
</Intro>
{/if}

<main class="mb-35 w-screen flex flex-col justify-between -mt-1px md:(mb-50 mt-10 w-[min(70rem,calc(100vw-5rem))])">
<div class="group w-full flex flex-col-reverse text-sm">
{#each context?.snapshots ?? [] as ctx, i}
Expand Down
18 changes: 18 additions & 0 deletions src/lib/components/Intro.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<script lang="ts">
import { fly } from "svelte/transition";
export let title: string;
</script>

<div class="fixed inset-0 z--1 grid place-items-center -translate-y-15">
<div class="flex flex-col gap-4 [&>button]:(w-fit flex flex-row items-center gap-2 b-2 b-neutral-8 rounded-lg px-3 py-2 text-sm transition) -translate-y-5 [&>button:hover]:bg-neutral-8">
<h1 class="mb-3 w-full gap-1 text-xl font-bold tracking-wide font-fira">
{#each title.split(" ") as char, i}
{#if i} <span> </span> {/if}
{@const t = Math.random() * (i + 1)}
<span class="inline-block" in:fly|global={{ delay: t * 50, duration: t * 40 + 300, y: Math.random() * 5 }}>{char}</span>
{/each}
</h1>
<slot />
</div>
</div>
2 changes: 1 addition & 1 deletion src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
import "@unocss/reset/tailwind-compat.css";
import "@unocss/reset/tailwind.css";
import "@fontsource-variable/jetbrains-mono";
import "@fontsource-variable/fira-code";
import "uno.css";
Expand Down
1 change: 1 addition & 0 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@
<ol class="flex flex-col gap-2.5 whitespace-nowrap">
<li><LoadingItem loading={!$pyodideReady} text="Loading pyodide v{pyodideVersion}" /></li>
<li class:op-30={!$pyodideReady}><LoadingItem loading={!$reasonifyReady} text="Loading reasonify v{reasonifyVersion}" /></li>
<h2 class="text-xs op-30">首次加载可能需要几秒钟</h2>
</ol>
</Modal>

0 comments on commit 19de62a

Please sign in to comment.