- Language: TypeScript (
^5.0.0) - Framework: Next.js (App Router)
- Styling: Tailwind CSS
- Component Library: shadcn/ui
- Data Fetching: React Query (TanStack)
- Testing: Jest + React Testing Library
- Linting: ESLint with
@typescript-eslint - Formatting: Prettier
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import logging | |
| from google.cloud import aiplatform | |
| logging.basicConfig(level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s: %(message)s") | |
| logger = logging.getLogger(__name__) | |
| model_id = sys.argv[1] | |
| artifact_uri = sys.argv[2] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Chart.tsx example | |
| 'use client' | |
| import { AreaChart, Card, Title } from '@tremor/react' | |
| const generateData = () => { | |
| let dataset = [] | |
| const dates = [ | |
| 'Jun 30', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Example of using SQLite VSS with OpenAI's text embedding API | |
| # from Ruby. | |
| # Note: Install/bundle the sqlite3, sqlite_vss, and ruby-openai gems first | |
| # OPENAI_API_KEY must also be set in the environment | |
| # Other embeddings can be used, but this is the easiest for a quick demo | |
| # More on the topic at | |
| # https://observablehq.com/@asg017/introducing-sqlite-vss | |
| # https://observablehq.com/@asg017/making-sqlite-extension-gem-installable |
This guide will walk you through adding a ChatGPT-like messaging stream to your Ruby on Rails 7 app using ruby-openai, Rails 7, Hotwire, Turbostream, Sidekiq and Tailwind. All code included below!
Want more content like this, for free? Check out my free book, RailsAI!
- Follow me on Twitter for more Ruby AI at https://twitter.com/alexrudall
- Released under the MIT License - use as you wish :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "weaviate" | |
| client = Weaviate::Client.new( | |
| url: ENV['WEAVIATE_URL'], | |
| api_key: ENV['WEAVIATE_API_KEY'], | |
| # Configure Weaviate to use OpenAI to create vectors and use it for querying | |
| # You can also use Cohere or Hugging Face and pass their API key here instead | |
| model_service: :openai, | |
| model_service_api_key: ENV['OPENAI_API_KEY'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "setup-chat", | |
| "description": "the gist to setup Build your own AI-Powered chat app with Next.js and LangChain from blog.experienced.dev", | |
| "version": "0.3.0", | |
| "engines": { | |
| "node": ">=18" | |
| }, | |
| "bin": "./setup.js" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Basic key operators to query the JSON objects : | |
| # #> : Get the JSON object at that path (if you need to do something fancy) | |
| # -> : Get the JSON object at that path (if you don't) | |
| # ->> : Get the JSON object at that path as text | |
| # {obj, n} : Get the nth item in that object | |
| # https://www.postgresql.org/docs/9.4/functions-json.html#FUNCTIONS-JSONB-OP-TABLE | |
| # Date | |
| # date before today |
This is a prompt that will make ChatGPT play a RPG adventure with you. Just paste the prompt into the input. You can also provide information like your name
To pause a game, save the JSON and paste it in the second file and paste that as the prompt. Optionally provide more information for the model like setting
To play original and very adaptive RPG games without friends. Obviously, I'm a redditor.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { decode } from "blurhash" | |
| export function blurHashToDataURL(hash: string | undefined): string | undefined { | |
| if (!hash) return undefined | |
| const pixels = decode(hash, 32, 32) | |
| const dataURL = parsePixels(pixels, 32, 32) | |
| return dataURL | |
| } |
NewerOlder
