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
"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); |
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
... | |
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); |
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
useEffect(() => { | |
async function checkCanShow() { | |
const canCreate = await window.ai?.canCreateTextSession(); | |
console.log(canCreate) | |
if (canCreate == "readily") { | |
setCanShow(true) | |
} |