Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Http error handling #128

Closed
wants to merge 55 commits into from
Closed
Changes from 9 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
8ce2c43
Tracing (#60)
VVoruganti Aug 22, 2023
d0570d6
0.3.0 Long Term Memory (#62)
VVoruganti Aug 28, 2023
b8843c0
fix: update link to more recent blog post
vintrocode Sep 1, 2023
2628753
Sanitize thoughts before sending them in the thought's channel (#65)
jacobvm04 Sep 1, 2023
88c81d1
LayeredLRU Cache (#69)
VVoruganti Sep 2, 2023
17caa80
Stateless bug (#70)
VVoruganti Sep 5, 2023
7fc94e9
Merge branch 'main' into staging
VVoruganti Sep 8, 2023
174a9fa
Fix merge errors
VVoruganti Sep 8, 2023
05b2de2
Fix merge errors 2
VVoruganti Sep 8, 2023
b7e2bb7
fix: top_p 0.5 to address gibberish
vintrocode Sep 8, 2023
312ff22
Merge branch 'main' into staging
VVoruganti Sep 8, 2023
30e08f6
Custom Web UI (#76)
VVoruganti Sep 10, 2023
c248dae
Fix Github Action Workflow
VVoruganti Sep 10, 2023
638c78a
Fix Github Action Workflow
VVoruganti Sep 10, 2023
c912212
add user prediction function
vintrocode Sep 11, 2023
0596350
Honcho Changes (#77)
VVoruganti Sep 11, 2023
cc1b745
Social Graph Changes
VVoruganti Sep 11, 2023
e226639
Authentication Form Styling
VVoruganti Sep 12, 2023
f1b02b9
Working Auth
VVoruganti Sep 12, 2023
9a31a8c
Stylistic changes
VVoruganti Sep 12, 2023
676be29
Address all linting errors
VVoruganti Sep 13, 2023
e5a8ff0
Naive Route Protection
VVoruganti Sep 13, 2023
63a693a
Fly minimum machines
VVoruganti Sep 13, 2023
9c96ecc
Open Graph Image Changes
VVoruganti Sep 13, 2023
dbce17e
Merge pull request #78 from plastic-labs/ui-tweaks
vintrocode Sep 13, 2023
dda6f0f
Remove anonymous honcho usage, fix opengraph (#80)
VVoruganti Sep 13, 2023
2378e3d
UI tweaks (#81)
VVoruganti Sep 13, 2023
0841901
UI tweaks (#82)
VVoruganti Sep 13, 2023
39a9559
Open Graph Fix
VVoruganti Sep 13, 2023
025320a
Merge branch 'staging' into bloom-a
VVoruganti Sep 13, 2023
933dda5
Remove Streamlit
VVoruganti Sep 13, 2023
5f72fad
Merge pull request #83 from plastic-labs/bloom-a
vintrocode Sep 14, 2023
53ef59d
UI tweaks (#84)
VVoruganti Sep 14, 2023
7a1f3de
Merge branch 'main' into staging
VVoruganti Sep 14, 2023
46930fc
Web fixes (#89)
hyusap Sep 18, 2023
f633583
Optimization (#96)
VVoruganti Sep 19, 2023
0ed850d
Optimization (#98)
VVoruganti Sep 19, 2023
99bf58a
Merge branch 'main' into staging
VVoruganti Sep 19, 2023
3b95cfb
add latex support and incentive it (#104)
hyusap Oct 5, 2023
6dc3528
prevent unallowed messages (#111)
hyusap Oct 5, 2023
53430b1
implement autoscroll (#112)
hyusap Nov 8, 2023
9a4576d
✨ add multiline support (#118)
hyusap Nov 16, 2023
5ebe31c
♻️ refactor all of the api stuff (#119)
hyusap Nov 29, 2023
0035fed
✨ implement dark mode (#120)
hyusap Nov 29, 2023
a89527a
Documentation (#121)
VVoruganti Dec 8, 2023
986473f
Force redirect for unauthenticated and add posthog events (#122)
VVoruganti Dec 8, 2023
9c4445c
Main merge conflict
VVoruganti Dec 8, 2023
940dd2a
Update version
VVoruganti Dec 8, 2023
2d885c0
Static banner
VVoruganti Dec 8, 2023
6cb407a
upgrade openai and langchain
hyusap Dec 11, 2023
51cabfb
extend supabase timeout
hyusap Dec 11, 2023
751be69
Handle moderation errors + other streaming errors explicitly
jacobvm04 Dec 11, 2023
43b0f53
Streaming error handling
jacobvm04 Dec 11, 2023
722ca16
✨ caching and skeletons (#127)
hyusap Dec 12, 2023
3a5ba7a
Revert "✨ caching and skeletons (#127)"
VVoruganti Dec 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions api/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
import requests
from requests.exceptions import ChunkedEncodingError

from common import init
from agent.chain import BloomChain
@@ -128,10 +129,22 @@ async def stream(inp: ConversationInput):
}, stream=True)

def generator():
for chunk in response.iter_content(chunk_size=1024):
if chunk:
yield chunk

try:
for chunk in response.iter_content(chunk_size=8192):
print(f"Received chunk: {chunk}")
if chunk:
yield chunk
except ChunkedEncodingError as e:
print(f"Chunked encoding error occurred: {e}")
print(response)
print(response.headers)
# Optionally yield an error message to the client
yield b"An error occurred while streaming the response."
except Exception as e:
print(f"An unexpected error occurred: {e}")
# Optionally yield an error message to the client
yield b"An unexpected error occurred."

print("A/B Confirmed")
return StreamingResponse(generator())
if conversation is None:
2 changes: 1 addition & 1 deletion fly.toml
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ api = "python -m uvicorn api.main:app --host 0.0.0.0 --port 8000"
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
min_machines_running = 1
processes = ["api"]
[http_service.concurrency]
type = "requests"
5 changes: 4 additions & 1 deletion www/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "next/core-web-vitals"
"extends": "next/core-web-vitals",
"rules": {
"react/no-children-prop": "off"
}
}
Binary file added www/app/auth/opengraph-image.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
145 changes: 70 additions & 75 deletions www/app/auth/page.tsx
Original file line number Diff line number Diff line change
@@ -1,91 +1,86 @@
'use client'
import { createClient } from "@supabase/supabase-js"
import { createClientComponentClient } from '@supabase/auth-helpers-nextjs'
import { useState } from "react";
import { useEffect, useState } from "react";
import { useRouter } from "next/navigation";

import Image from "next/image";

import icon from "@/public/bloomicon.jpg";

import SignUp from '@/components/signUp';
import SignIn from '@/components/signIn';
import Forgot from '@/components/forgot'
import Reset from '@/components/reset'

export default function Auth() {
const [formType, setFormType] = useState('signIn');
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const router = useRouter();
const [formType, setFormType] = useState('LOGIN');
const supabase = createClientComponentClient()
const router = useRouter()

const switchForm = () => {
if (formType === 'signIn') {
setFormType('signUp');
} else if (formType === 'signUp') {
setFormType('forgot');
} else {
setFormType('signIn');
}
};
useEffect(() => {

const handleSignIn = async (e: any) => {
e.preventDefault();
const { error } = await supabase.auth.signInWithPassword({ email, password });
if (error) {
console.error(error);
console.log(email)
console.log(password)
throw error;
}
router.push("/")
};
supabase.auth.getSession().then(({ data: { session } }) => {
if (session) { // Can't access this page if you're logged in
router.push('/')
}
})

const handleSignUp = async (e: any) => {
e.preventDefault();
const { error } = await supabase.auth.signUp({ email, password });
if (error) {
console.error(error);
} else {
alert("Please check your email and verify")
}
};
const { data: subscription } = supabase.auth.onAuthStateChange(async (event, session) => {
if (event != "INITIAL_SESSION") {
console.log(event)
}
if (event == "PASSWORD_RECOVERY") {
router.push("/auth/reset")
}

const handleForgotPassword = async (e: any) => {
e.preventDefault();
const { error } = await supabase.auth.resetPasswordForEmail(email);
if (error) console.error(error);
}
})
}, [router, supabase])

return (
<div className="h-[100dvh] flex flex-col justify-center items-center">
<div className="p-4 bg-white rounded shadow-md">
<h3 className="text-lg font-semibold mb-4">Welcome to Bloom 🌸</h3>
{formType === 'signIn' && (
<form>
<input className="border p-2 mb-4 w-full" type="text" placeholder="Email" value={email} onChange={(e) => setEmail(e.target.value)} />
<input className="border p-2 mb-4 w-full" type="password" placeholder="Password" value={password} onChange={(e) => setPassword(e.target.value)} />
<button className="bg-neon-green text-black p-2 w-full rounded" onClick={handleSignIn}>Sign In</button>
</form>
)}
{formType === 'signUp' && (
<form>
<input className="border p-2 mb-4 w-full" type="text" placeholder="Email" value={email} onChange={(e) => setEmail(e.target.value)} />
<input className="border p-2 mb-4 w-full" type="password" placeholder="Password" value={password} onChange={(e) => setPassword(e.target.value)} />
<button className="bg-neon-green text-black p-2 w-full rounded" onClick={handleSignUp}>Sign Up</button>
</form>
)}
{formType === 'forgot' && (
<form>
<input className="border p-2 mb-4 w-full" type="text" placeholder="Email" value={email} onChange={(e) => setEmail(e.target.value)} />
<button className="bg-neon-green text-black p-2 w-full rounded" onClick={handleForgotPassword}>Reset Password</button>
</form>
)}
<div className="flex flex-col pt-5 items-center">
{formType !== 'signIn' && (
<span className="text-blue-500 cursor-pointer mb-2" onClick={() => setFormType('signIn')}>Sign In</span>
)}
{formType !== 'signUp' && (
<span className="text-blue-500 cursor-pointer mb-2" onClick={() => setFormType('signUp')}>Sign Up</span>
)}
{formType !== 'forgot' && (
<span className="text-blue-500 cursor-pointer mb-2" onClick={() => setFormType('forgot')}>Forgot Password</span>
)}
</div>
<section className="bg-white">
<div className="lg:grid lg:min-h-screen lg:grid-cols-12">
<aside
className="relative block h-16 lg:order-last lg:col-span-5 lg:h-full xl:col-span-6"
>
<Image
alt="Pattern"
src="/auth_banner.jpg"
className="absolute inset-0 h-full w-full object-cover"
fill={true}
/>
</aside>

<main
className="flex items-center justify-center px-8 py-8 sm:px-12 lg:col-span-7 lg:px-16 lg:py-12 xl:col-span-6"
>
<div className="max-w-xl lg:max-w-3xl">
<a className="block text-blue-600" href="/">
<span className="sr-only">Home</span>
<Image src={icon} alt="banner" className="h-10 sm:h-10 w-auto rounded-full" />
</a>

<h1
className="mt-6 text-2xl font-bold text-gray-900 sm:text-3xl md:text-4xl"
>
Welcome to Bloom 🌸
</h1>

<p className="mt-4 leading-relaxed text-gray-500">
Your Aristotelian learning companion — here to help you follow your curiosity in whatever direction you like.
</p>
{formType === 'LOGIN' && (
<SignIn stateSync={setFormType} />
)}
{formType === 'SIGNUP' && (
<SignUp stateSync={setFormType} />
)}
{formType === 'FORGOT' && (
<Forgot stateSync={setFormType} />
)}

</div>
</main>
</div>
</div>
</section>
)
}
48 changes: 48 additions & 0 deletions www/app/auth/reset/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
'use client'

import Image from "next/image";
import icon from "@/public/bloomicon.jpg";
import Reset from '@/components/reset'

export default function ResetPage() {

return (
<section className="bg-white">
<div className="lg:grid lg:min-h-screen lg:grid-cols-12">
<aside
className="relative block h-16 lg:order-last lg:col-span-5 lg:h-full xl:col-span-6"
>
<Image
alt="Pattern"
src="/auth_banner.jpg"
className="absolute inset-0 h-full w-full object-cover"
fill={true}
/>
</aside>

<main
className="flex items-center justify-center px-8 py-8 sm:px-12 lg:col-span-7 lg:px-16 lg:py-12 xl:col-span-6"
>
<div className="max-w-xl lg:max-w-3xl">
<a className="block text-blue-600" href="/">
<span className="sr-only">Home</span>
<Image src={icon} alt="banner" className="h-10 sm:h-10 w-auto rounded-full" />
</a>

<h1
className="mt-6 text-2xl font-bold text-gray-900 sm:text-3xl md:text-4xl"
>
Welcome to Bloom 🌸
</h1>

<p className="mt-4 leading-relaxed text-gray-500">
Your Aristotelian learning companion — here to help you follow your curiosity in whatever direction you like.
</p>
<Reset />

</div>
</main>
</div>
</section>
)
}
Binary file removed www/app/favicon.ico
Binary file not shown.
33 changes: 30 additions & 3 deletions www/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -6,16 +6,43 @@ const spacegrotesk = Space_Grotesk({ subsets: ["latin"] });

export const metadata: Metadata = {
title: "Bloombot - Learning. Reimagined.",
description: "Generated by create next app",
metadataBase: new URL(process.env.NEXT_PUBLIC_URL || "http://localhost:3000"),
description: "Bloom is your always-on, always-engaged learning companion. You can chat with Bloom about any topic, whenever you want. It’s designed to help you build critical skills and follow your curiosity.",
authors: [{ name: "Plastic Labs", url: "https://plasticlabs.ai" }],
openGraph: {
title: "Bloombot",
description: "Bloom is your always-on, always-engaged learning companion. You can chat with Bloom about any topic, whenever you want. It’s designed to help you build critical skills and follow your curiosity.",
siteName: "Bloombot",
type: "website",
url: "https://bloombot.ai",
url: "/",
// images: [
// {
// url: '@/small_preview.jpg',
// width: 800,
// height: 600,
// },
// {
// url: '@/large_preview.jpg',
// width: 1800,
// height: 1600,
// alt: 'Bloombot Preview',
// },
// ],
locale: "en_US",
}
},
robots: {
index: false,
follow: true,
nocache: true,
googleBot: {
index: true,
follow: false,
noimageindex: true,
'max-video-preview': -1,
'max-image-preview': 'large',
'max-snippet': -1,
},
},
};

export default function RootLayout({
Binary file added www/app/opengraph-image.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading