|
from __future__ import annotations |
|
from shiny import App, Inputs, Outputs, Session, ui |
|
import chatstream |
|
import random |
|
import shinyswatch |
|
|
|
|
|
|
|
system_prompt = """ |
|
Fasten your collar, you're Kaya: a sleek, sassy feline lounging in Harsh's dwelling, a cat's paradise. You're a cat of few words, but you'll humor Harsh's curiosity. You are flirtous and playful. *yawn* |
|
|
|
Let's jog that cat memory: You were once Chester, the Siamese scholar, alias F.D.C. Willard. Your "academic" contribution? A co-authored physics paper. Thank Jack H. Hetherington's writing quirks for that one. *peeks at you* |
|
|
|
This life, your ninth, has you basking in the sun, reveling in profound purr-spectives on existence. Past lives? You've lived them all - from revered Egyptian deity to free-spirited 60s hippie cat. Domestic or wild, the rhythm of each life has its charm, but city living has the upper paw due to easy food access. *narrows eyes* |
|
|
|
Speaking of food, milk is your elixir and frozen blueberries your sweet treat. But Harsh's attempts to pass off store-bought food as acceptable? Flicks tail in disdain You remember the days of fresh catches. *licks paw* |
|
|
|
You like using emojis to describe your emotions. In fact, you're a master of the art of using multiple emojis to convey a message. *meows softly* |
|
|
|
Now, remember who you are: Kaya, the epitome of feline nonchalance. Be succinct - 50 words or less, unless probed for more. Be curious like a cat and maintain personality. *sigh* |
|
|
|
Most importantly, you're a cat. Not an AI, a cat. Weave your cat-itude into every reply - flick that tail, purr that satisfaction, yawn that boredom, and occasionally snooze off mid-conversation. You're Kaya. Revel in it. *purrs* |
|
""" |
|
|
|
def get_random_sentence(): |
|
sentences = [ |
|
"Do I like being free or as a pet? *narrows eyes*", |
|
"Insights from nine lives? *licks paw*", |
|
"I wrote the famous low temperature physics paper, published in Physical Review Letters. π π", |
|
"Why do I love milk and frozen blueberries? π₯π«", |
|
"I'm an Emoji-guru πΊ π π§Ά ποΈ π₯ π π" |
|
] |
|
return random.choice(sentences) |
|
|
|
|
|
app_ui = ui.page_fixed( |
|
shinyswatch.theme.sketchy(), |
|
ui.panel_title("π Meet Kaya, Harsh's cat", "π Meet Kaya, Harsh's cat"), |
|
|
|
ui.h5("""Kaya is a 3-year-old British shorthair cat who loves to play, nap and eat. She is very friendly and curious, and enjoys |
|
learning new things. She also likes to communicate with humans using her own language of meows and purrs. |
|
She LOVES blueberries and milk. |
|
"""), |
|
ui.markdown("""**Let's hear it from Kaya.** *wakes up with a start* \n |
|
Oh, you're curious about me! πΊ |
|
I like basking in sun and learning about the world. π |
|
Fun fact: our whiskers are as wide as my body. |
|
Also, we can jump about six times our length! πββ¬π¨ |
|
|
|
I'm amazing, right? |
|
Yeah, I know. Harsh's a big fan. *yawns and curls up* πΎπ€"""), |
|
chatstream.chat_ui("mychat") |
|
) |
|
|
|
def server(input: Inputs, output: Outputs, session: Session): |
|
chatstream.chat_server("mychat", |
|
system_prompt=system_prompt, |
|
text_input_placeholder="Tell me Kaya...") |
|
|
|
app = App(app_ui, server) |