Skip to content

Instantly share code, notes, and snippets.

View Nithur-M's full-sized avatar
💻
Move fast and break things.

Nithur Nithur-M

💻
Move fast and break things.
View GitHub Profile
@Nithur-M
Nithur-M / useeffect.js
Created July 20, 2024 07:17
Check if Gemini Nano is supported in user browser
useEffect(() => {
async function checkCanShow() {
const canCreate = await window.ai?.canCreateTextSession();
console.log(canCreate)
if (canCreate == "readily") {
setCanShow(true)
}
@Nithur-M
Nithur-M / sendMessage.js
Created July 20, 2024 07:19
Send user queries to Gemini Nano
...
const handleSendMessage = async () => {
const canCreate = await window.ai.canCreateTextSession();
if (canCreate !== "no") {
const session = await window.ai.createTextSession();
const stream = session.promptStreaming(`You are a friendly assistant designed to help users with job searching. You need to answer this question: \n\n${question} based on this text: ${newtext}. If you couldn't find answers from the given text, say there is no answer.`);
for await (const chunk of stream) {
setAnswer(chunk);
@Nithur-M
Nithur-M / ChromeAI.js
Created July 20, 2024 07:21
Chat with job description using Gemini Nano
"use client"
import { useEffect, useState } from "react"
import { MessageCircle } from "lucide-react"
import { Input } from "./ui/input"
import ReactMarkdown from 'react-markdown'
const ChromeAI = ({ text, title }) => {
const [canShow, setCanShow] = useState(false);
const [show, setShow] = useState(false);