Skip to content

Commit

Permalink
0.5.1 (#132)
Browse files Browse the repository at this point in the history
* Tracing (#60)

* Tracing to separate conversations

* Basic Postgres Connection via Supabase

* MVP Postgres Backed Chat Message History

* Full binary install or psycopg3

* Use Supabase directly to avoid issues with postgres connections

* .env.template update

* 0.3.0 Long Term Memory (#62)

* Add reply to discord and limit chat history to 10 messages

* reverse returned messages and cleanup comments

* Update changelog

* increase cache limit

* Switch to Azure OpenAI

* Changelog

* fix: update link to more recent blog post

* Sanitize thoughts before sending them in the thought's channel (#65)

* LayeredLRU Cache (#69)

* Make BloomChain a static class

* MVP Layered LRU Cache using Postgres

* Remove testing variables

* Async Mutex Lock on Cache

* Stateless bug (#70)

* Dynamic model switching

* Fix hardcoding and add recovery logic for conversation tables

* Add support for multiple conversations

* Fix merge errors

* Fix merge errors 2

* fix: top_p 0.5 to address gibberish

* Custom Web UI (#76)

* init nextjs

* fast api init

* styling and thoughts

* streaming updates

* connect to api

* Add thoughts to the web UI

* Refactor input to be a form for UX (e.g. pressing enter sends)

* typing and thoughts

* Refactor input to be a form for UX (e.g. pressing enter sends)

* Revert "Merge remote-tracking branch 'origin/custom-web' into custom-web"

This reverts commit 1eae747.

* Skeleton Multiple Chat Window UI

* MVP Layout

* Tested Discord and Skeleton FastAPI

* Add, Delete, and Set Conversations

* Get and send messages

* Edit message names

* Local serving from FastAPI via static export

* Deployment strategy for static files

* Separate out apps

* Vercel Deployment with Action

* Re-add discord to fly.toml

---------

Co-authored-by: hyusap <[email protected]>
Co-authored-by: Jacob Van Meter <[email protected]>

* Fix Github Action Workflow

* Fix Github Action Workflow

* add user prediction function

* Honcho Changes (#77)

* init nextjs

* fast api init

* styling and thoughts

* streaming updates

* connect to api

* Add thoughts to the web UI

* Refactor input to be a form for UX (e.g. pressing enter sends)

* typing and thoughts

* Refactor input to be a form for UX (e.g. pressing enter sends)

* Revert "Merge remote-tracking branch 'origin/custom-web' into custom-web"

This reverts commit 1eae747.

* Skeleton Multiple Chat Window UI

* MVP Layout

* Tested Discord and Skeleton FastAPI

* Add, Delete, and Set Conversations

* Get and send messages

* Edit message names

* Local serving from FastAPI via static export

* Deployment strategy for static files

* Separate out apps

* Vercel Deployment with Action

* Re-add discord to fly.toml

* Honcho Stream

* Honcho Stream

---------

Co-authored-by: hyusap <[email protected]>
Co-authored-by: Jacob Van Meter <[email protected]>

* Social Graph Changes

* Authentication Form Styling

* Working Auth

* Stylistic changes

* Address all linting errors

* Naive Route Protection

* Fly minimum machines

* Open Graph Image Changes

* Remove anonymous honcho usage, fix opengraph (#80)

* Remove anonymous honcho usage, fix opengraph

* Remove extra excess logging and comment

* UI tweaks (#81)

* Remove anonymous honcho usage, fix opengraph

* Remove extra excess logging and comment

* I hate typescript

* UI tweaks (#82)

* Remove anonymous honcho usage, fix opengraph

* Remove extra excess logging and comment

* I hate typescript

* Open Graph, Block chat, delete convo

* Sign Up UI

* Sign Up UI 2

* Change open graph image

* Open Graph Fix

* Remove Streamlit

* UI tweaks (#84)

* Remove anonymous honcho usage, fix opengraph

* Remove extra excess logging and comment

* I hate typescript

* Open Graph, Block chat, delete convo

* Sign Up UI

* Sign Up UI 2

* Change open graph image

* Remove native prompts for sweetalert

* Changelog

* Remove Honcho for discord

* Web fixes (#89)

* seperation between sidebar and window + formatting

* make app pwa downloadable

* move to new chat on button press

* remove router

* feat: Refactor code to use MarkdownWrapper component

- Refactored the code in the `Home` component to replace usages of `ReactMarkdown` and `SyntaxHighlighter` with the new `MarkdownWrapper` component.
- Updated the `Home` component to pass the `text` prop to the `MarkdownWrapper` component for each message.
- Added a new component `MarkdownWrapper` to handle rendering markdown text with syntax highlighting.
- Removed unused imports from the `page.tsx` file, including `ReactMarkdown`, `SyntaxHighlighter`, and `dark` styles.
- Also removed unused imports from the `sidebar.tsx` file, including `useState` import.

* Optimization (#96)

* Usable without honcho and move metadata to creation points

* Remove unused psycopg code

* Add Sentry instrumentation

* Sentry to python

* Update env

* Optimization (#98)

* Usable without honcho and move metadata to creation points

* Remove unused psycopg code

* Add Sentry instrumentation

* Sentry to python

* Update env

* Sentry & Posthog integration on web

* Linting Errors

* add latex support and incentive it (#104)

* prevent unallowed messages (#111)

* implement autoscroll (#112)

* implement autoscroll
Refactored imports in "page.tsx" to improve readability and maintainability. Updated the type of the "input" ref to be more specific. Added a new state and ref to track the scroll position of the message container. Set up an event listener to update the state when the scroll position changes. Made adjustments to the scroll position in certain event handlers.

* update scroll

---------

Co-authored-by: Vineeth Voruganti <[email protected]>

* ✨ add multiline support (#118)

* ♻️ refactor all of the api stuff (#119)

* ♻️ refactor all of the api stuff

a redo of the old refactor branch, but cleaner.
moved all api calls to api.ts and supabase.ts

* Minor Bug Fixes

- Add `build-essential` to dockerfile
- Fix signin button size
- Add await for signout
- Force re-render on conversation name change

---------

Co-authored-by: Vineeth Voruganti <[email protected]>

* ✨ implement dark mode (#120)

automatically check for system mode
manual control via animated thingy

Co-authored-by: Vineeth Voruganti <[email protected]>

* Documentation (#121)

* README update and start of supabase plus making next buildable

* Supabase Local Setup and README additions

* Update web .env template and note on supabase local auth

* Force redirect for unauthenticated and add posthog events (#122)

* Update version

* Static banner

* ✨ caching and skeletons (#127)

* Revert "✨ caching and skeletons (#127)"

This reverts commit 15e649e.

* Http error handling (#129)

* upgrade openai and langchain

Co-authored-by: Jacob Vanmeter <[email protected]>

* extend supabase timeout

* Handle moderation errors + other streaming errors explicitly

* Streaming error handling

* ✨ caching and skeletons (#127)

* Revert "✨ caching and skeletons (#127)"

This reverts commit 15e649e.

---------

Co-authored-by: hyusap <[email protected]>
Co-authored-by: Vineeth Voruganti <[email protected]>

* ✨ caching and skeletons 2 (#130)

* ✨ caching and skeletons

* 🐛 fix the swr revalidation errors

* 💄 fix dark mode typing indicator

* Changelogs (#131)

* Tutor-GPT 0.5.0 (#124)

* Tracing (#60)

* Tracing to separate conversations

* Basic Postgres Connection via Supabase

* MVP Postgres Backed Chat Message History

* Full binary install or psycopg3

* Use Supabase directly to avoid issues with postgres connections

* .env.template update

* 0.3.0 Long Term Memory (#62)

* Add reply to discord and limit chat history to 10 messages

* reverse returned messages and cleanup comments

* Update changelog

* increase cache limit

* Switch to Azure OpenAI

* Changelog

* fix: update link to more recent blog post

* Sanitize thoughts before sending them in the thought's channel (#65)

* LayeredLRU Cache (#69)

* Make BloomChain a static class

* MVP Layered LRU Cache using Postgres

* Remove testing variables

* Async Mutex Lock on Cache

* Stateless bug (#70)

* Dynamic model switching

* Fix hardcoding and add recovery logic for conversation tables

* Add support for multiple conversations

* Fix merge errors

* Fix merge errors 2

* fix: top_p 0.5 to address gibberish

* Custom Web UI (#76)

* init nextjs

* fast api init

* styling and thoughts

* streaming updates

* connect to api

* Add thoughts to the web UI

* Refactor input to be a form for UX (e.g. pressing enter sends)

* typing and thoughts

* Refactor input to be a form for UX (e.g. pressing enter sends)

* Revert "Merge remote-tracking branch 'origin/custom-web' into custom-web"

This reverts commit 1eae747.

* Skeleton Multiple Chat Window UI

* MVP Layout

* Tested Discord and Skeleton FastAPI

* Add, Delete, and Set Conversations

* Get and send messages

* Edit message names

* Local serving from FastAPI via static export

* Deployment strategy for static files

* Separate out apps

* Vercel Deployment with Action

* Re-add discord to fly.toml

---------

Co-authored-by: hyusap <[email protected]>
Co-authored-by: Jacob Van Meter <[email protected]>

* Fix Github Action Workflow

* Fix Github Action Workflow

* add user prediction function

* Honcho Changes (#77)

* init nextjs

* fast api init

* styling and thoughts

* streaming updates

* connect to api

* Add thoughts to the web UI

* Refactor input to be a form for UX (e.g. pressing enter sends)

* typing and thoughts

* Refactor input to be a form for UX (e.g. pressing enter sends)

* Revert "Merge remote-tracking branch 'origin/custom-web' into custom-web"

This reverts commit 1eae747.

* Skeleton Multiple Chat Window UI

* MVP Layout

* Tested Discord and Skeleton FastAPI

* Add, Delete, and Set Conversations

* Get and send messages

* Edit message names

* Local serving from FastAPI via static export

* Deployment strategy for static files

* Separate out apps

* Vercel Deployment with Action

* Re-add discord to fly.toml

* Honcho Stream

* Honcho Stream

---------

Co-authored-by: hyusap <[email protected]>
Co-authored-by: Jacob Van Meter <[email protected]>

* Social Graph Changes

* Authentication Form Styling

* Working Auth

* Stylistic changes

* Address all linting errors

* Naive Route Protection

* Fly minimum machines

* Open Graph Image Changes

* Remove anonymous honcho usage, fix opengraph (#80)

* Remove anonymous honcho usage, fix opengraph

* Remove extra excess logging and comment

* UI tweaks (#81)

* Remove anonymous honcho usage, fix opengraph

* Remove extra excess logging and comment

* I hate typescript

* UI tweaks (#82)

* Remove anonymous honcho usage, fix opengraph

* Remove extra excess logging and comment

* I hate typescript

* Open Graph, Block chat, delete convo

* Sign Up UI

* Sign Up UI 2

* Change open graph image

* Open Graph Fix

* Remove Streamlit

* UI tweaks (#84)

* Remove anonymous honcho usage, fix opengraph

* Remove extra excess logging and comment

* I hate typescript

* Open Graph, Block chat, delete convo

* Sign Up UI

* Sign Up UI 2

* Change open graph image

* Remove native prompts for sweetalert

* Changelog

* Remove Honcho for discord

* Web fixes (#89)

* seperation between sidebar and window + formatting

* make app pwa downloadable

* move to new chat on button press

* remove router

* feat: Refactor code to use MarkdownWrapper component

- Refactored the code in the `Home` component to replace usages of `ReactMarkdown` and `SyntaxHighlighter` with the new `MarkdownWrapper` component.
- Updated the `Home` component to pass the `text` prop to the `MarkdownWrapper` component for each message.
- Added a new component `MarkdownWrapper` to handle rendering markdown text with syntax highlighting.
- Removed unused imports from the `page.tsx` file, including `ReactMarkdown`, `SyntaxHighlighter`, and `dark` styles.
- Also removed unused imports from the `sidebar.tsx` file, including `useState` import.

* Optimization (#96)

* Usable without honcho and move metadata to creation points

* Remove unused psycopg code

* Add Sentry instrumentation

* Sentry to python

* Update env

* Optimization (#98)

* Usable without honcho and move metadata to creation points

* Remove unused psycopg code

* Add Sentry instrumentation

* Sentry to python

* Update env

* Sentry & Posthog integration on web

* Linting Errors

* add latex support and incentive it (#104)

* prevent unallowed messages (#111)

* implement autoscroll (#112)

* implement autoscroll
Refactored imports in "page.tsx" to improve readability and maintainability. Updated the type of the "input" ref to be more specific. Added a new state and ref to track the scroll position of the message container. Set up an event listener to update the state when the scroll position changes. Made adjustments to the scroll position in certain event handlers.

* update scroll

---------

Co-authored-by: Vineeth Voruganti <[email protected]>

* ✨ add multiline support (#118)

* ♻️ refactor all of the api stuff (#119)

* ♻️ refactor all of the api stuff

a redo of the old refactor branch, but cleaner.
moved all api calls to api.ts and supabase.ts

* Minor Bug Fixes

- Add `build-essential` to dockerfile
- Fix signin button size
- Add await for signout
- Force re-render on conversation name change

---------

Co-authored-by: Vineeth Voruganti <[email protected]>

* ✨ implement dark mode (#120)

automatically check for system mode
manual control via animated thingy

Co-authored-by: Vineeth Voruganti <[email protected]>

* Documentation (#121)

* README update and start of supabase plus making next buildable

* Supabase Local Setup and README additions

* Update web .env template and note on supabase local auth

* Force redirect for unauthenticated and add posthog events (#122)

* Update version

* Static banner

---------

Co-authored-by: vintro <[email protected]>
Co-authored-by: Jacob Vanmeter <[email protected]>
Co-authored-by: hyusap <[email protected]>
Co-authored-by: vintro <[email protected]>

* Changelogs

---------

Co-authored-by: vintro <[email protected]>
Co-authored-by: Jacob Vanmeter <[email protected]>
Co-authored-by: hyusap <[email protected]>
Co-authored-by: vintro <[email protected]>

---------

Co-authored-by: vintro <[email protected]>
Co-authored-by: Jacob Vanmeter <[email protected]>
Co-authored-by: hyusap <[email protected]>
Co-authored-by: vintro <[email protected]>
  • Loading branch information
5 people committed Dec 12, 2023
1 parent d4792da commit ecfa537
Show file tree
Hide file tree
Showing 16 changed files with 502 additions and 367 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [0.5.1] - 2023-12-12

### Added

- Dark mode
- Web Caching
- LateX Support
- Multiline support for chat textbox

### Changed

- Required Sign In
- No A/B for Honcho
- Error handling for content filter

### Security

- Update Langchain version to ^0.0.348
- Update OpenAI Package to ^1.3.8


## [0.4.1] – 2023-09-14

### Added
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# tutor-gpt
![Static Badge](https://img.shields.io/badge/Version-0.4.0-blue)
![Static Badge](https://img.shields.io/badge/Version-0.5.1-blue)
[![Discord](https://img.shields.io/discord/1076192451997474938?logo=discord&logoColor=%23ffffff&label=Bloom&labelColor=%235865F2)](https://discord.gg/bloombotai)
![GitHub License](https://img.shields.io/github/license/plastic-labs/tutor-gpt)
![GitHub Repo stars](https://img.shields.io/github/stars/plastic-labs/tutor-gpt)
Expand Down
43 changes: 31 additions & 12 deletions agent/chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
)
from langchain.prompts import load_prompt, ChatPromptTemplate
from langchain.schema import AIMessage, HumanMessage, BaseMessage

from openai import BadRequestError

from dotenv import load_dotenv

from collections.abc import AsyncIterator
Expand Down Expand Up @@ -54,12 +57,11 @@ def think(cls, cache: Conversation, input: str):
])
chain = thought_prompt | cls.llm

cache.add_message("thought", HumanMessage(content=input))
def save_new_messages(ai_response):
cache.add_message("response", HumanMessage(content=input))
cache.add_message("response", AIMessage(content=ai_response))

return Streamable(
chain.astream({}, {"tags": ["thought"], "metadata": {"conversation_id": cache.conversation_id, "user_id": cache.user_id}}),
lambda thought: cache.add_message("thought", AIMessage(content=thought))
)
return Streamable(chain.astream({}, {"tags": ["thought"], "metadata": {"conversation_id": cache.conversation_id, "user_id": cache.user_id}}), save_new_messages)

@classmethod
@sentry_sdk.trace
Expand All @@ -72,13 +74,12 @@ def respond(cls, cache: Conversation, thought: str, input: str):
])
chain = response_prompt | cls.llm

cache.add_message("response", HumanMessage(content=input))
def save_new_messages(ai_response):
cache.add_message("response", HumanMessage(content=input))
cache.add_message("response", AIMessage(content=ai_response))

return Streamable(chain.astream({ "thought": thought }, {"tags": ["response"], "metadata": {"conversation_id": cache.conversation_id, "user_id": cache.user_id}}), save_new_messages)

return Streamable(
chain.astream({ "thought": thought }, {"tags": ["response"], "metadata": {"conversation_id": cache.conversation_id, "user_id": cache.user_id}}),
lambda response: cache.add_message("response", AIMessage(content=response))
)

@classmethod
@sentry_sdk.trace
async def think_user_prediction(cls, cache: Conversation):
Expand Down Expand Up @@ -114,27 +115,45 @@ async def chat(cls, cache: Conversation, inp: str ) -> tuple[str, str]:
return thought, response



class Streamable:
"A async iterator wrapper for langchain streams that saves on completion via callback"

def __init__(self, iterator: AsyncIterator[BaseMessage], callback):
self.iterator = iterator
self.callback = callback
self.content = ""
self.stream_error = False

def __aiter__(self):
return self

async def __anext__(self):
try:
if self.stream_error:
raise StopAsyncIteration

data = await self.iterator.__anext__()
self.content += data.content
return data.content
except StopAsyncIteration as e:
self.callback(self.content)
raise StopAsyncIteration
except BadRequestError as e:
if e.code == "content_filter":
self.stream_error = True
self.message = "Sorry, your message was flagged as inappropriate. Please try again."

return self.message
else:
raise Exception(e)
except Exception as e:
raise e
sentry_sdk.capture_exception(e)

self.stream_error = True
self.message = "Sorry, an error occurred while streaming the response. Please try again."

return self.message

async def __call__(self):
async for _ in self:
Expand Down
6 changes: 5 additions & 1 deletion agent/mediator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
from dotenv import load_dotenv
# Supabase for Postgres Management
from supabase.client import create_client, Client
from supabase.lib.client_options import ClientOptions
from typing import List, Tuple, Dict
load_dotenv()

class SupabaseMediator:
@sentry_sdk.trace
def __init__(self):
self.supabase: Client = create_client(os.environ['SUPABASE_URL'], os.environ['SUPABASE_KEY'])
# Change the network db timeout to 60 seconds since the default is only 5 seconds
timeout_client_options = ClientOptions(postgrest_client_timeout=60)
self.supabase: Client = create_client(os.environ['SUPABASE_URL'], os.environ['SUPABASE_KEY'], timeout_client_options)

self.memory_table = os.environ["MEMORY_TABLE"]
self.conversation_table = os.environ["CONVERSATION_TABLE"]

Expand Down
Loading

1 comment on commit ecfa537

@vercel
Copy link

@vercel vercel bot commented on ecfa537 Dec 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.