Skip to content

Commit

Permalink
prompting changes from hackathon (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
keppy authored Jun 18, 2024
1 parent f6e2cb2 commit 7096a5e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 6 deletions.
2 changes: 2 additions & 0 deletions webui/api-server/dtos.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class Scenario(BaseModel):
events: List[Event] = Field(default_factory=list)
world_enders: List[WorldEnder] = Field(default_factory=list)
question_response: QuestionResponse | None
final_population: int | None
Outcome: Outcome | None


class NewScenarioRequest(BaseModel):
Expand Down
4 changes: 4 additions & 0 deletions webui/api-server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ async def new_scenario(scenario_init: NewScenarioRequest) -> NewScenarioResponse
last_event=None,
last_world_ender=None,
question_response=None,
final_population=None,
Outcome=None,
)
event = await next_event(
f"{scenario_init.city}, {scenario_init.scenario}", aclient
Expand Down Expand Up @@ -114,6 +116,8 @@ async def post_ask_question(scenario_id: str, data: Question) -> QuestionRespons
logger.info(f"Asking question {data.text} for scenario {scenario_id}")
question_response = await ask_question(data.text, aclient, scenario.last_world_ender)
logger.info(f"Got question response: {question_response}")
if question_response.correct_question:
scenario.final_population = scenario.world.population
scenario.question_response = question_response
await store_scenario(scenario_id, scenario)
return question_response
Expand Down
2 changes: 1 addition & 1 deletion webui/apps/website/components/newScenario/newScenario.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export function NewScenario() {
) : (
<div className="mx-auto w-full max-w-md space-y-6">
<img
src="/placeholder.svg"
src="/dude.png"
width="800"
height="450"
alt="Hero"
Expand Down
14 changes: 9 additions & 5 deletions webui/apps/website/components/scenarioState/scenarioState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ const DisplayScenarioState = (hook: ReturnType<typeof useScenarioState>) => {
return display;
};

const final_population = (wordPopulation: number) => {
return (8019876189 - wordPopulation).toLocaleString();
}

export const ScenarioState: React.FC<Props> = ({ slug }) => {
const hook = useScenarioState(slug);
console.log(JSON.stringify({ isLoading: hook.isLoading }));
Expand All @@ -66,10 +70,10 @@ export const ScenarioState: React.FC<Props> = ({ slug }) => {
</Link>
<div className="flex flex-col ">
<div className="text-xl space-y-4 min-w-[360px]">
{`${hook.data?.world?.day} days have passed.`}
<span className="text-red-300">{hook.data?.world?.day}</span> days have passed.
</div>
<div className="text-xl space-y-4 min-w-[360px]">
{`The world population is ${hook.data?.world?.population?.toLocaleString()}.`}
The world population is <span className="text-yellow-400">{hook.data?.world?.population?.toLocaleString()}</span>.
</div>
</div>
</div>
Expand All @@ -83,7 +87,7 @@ export const ScenarioState: React.FC<Props> = ({ slug }) => {
alt="Image"
className="min-w-[360px] rounded-lg object-cover self-start"
height={360}
src="/we_hero.png"
src="/kkilder.png"
style={{
aspectRatio: "360/360",
objectFit: "cover",
Expand Down Expand Up @@ -201,10 +205,10 @@ export const ScenarioState: React.FC<Props> = ({ slug }) => {
<Overlay>
<div className="space-y-8">
<h2 className="text-3xl font-bold tracking-tighter md:text-4xl lg:text-5xl">
You have asked the right question! You WIN!
You have asked the right question! You <span className="text-green-500">WIN!</span>
</h2>
<h3 className="text-2xl font-bold">
Only {8019876189 - hook.data?.world.population} humans died!
Only <span className="text-green-500">{final_population(hook.data?.final_population)}</span> humans died!
</h3>
</div>
</Overlay>
Expand Down
Binary file added webui/apps/website/public/dude.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webui/apps/website/public/kkilder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7096a5e

Please sign in to comment.