YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
removed unnecessary tools, changed system prompt, changed localhost to an explicit IP address
matthew-heartfule8550f6b40fe
diff --git a/examples/ts/vercel-ai-chatbot/lib/chat/actions.tsx b/examples/ts/vercel-ai-chatbot/lib/chat/actions.tsxindex 7ee5c6ddd..a48c9b485 100644--- a/examples/ts/vercel-ai-chatbot/lib/chat/actions.tsx+++ b/examples/ts/vercel-ai-chatbot/lib/chat/actions.tsx@@ -37,76 +37,6 @@ import { Chat, Message } from '@/lib/types'import { auth } from '@/auth'import { MemoizedReactMarkdown } from '@/components/markdown'-async function confirmPurchase(symbol: string, price: number, amount: number) {- 'use server'-- const aiState = getMutableAIState<typeof AI>()-- const purchasing = createStreamableUI(- <div className="inline-flex items-start gap-1 md:items-center">- {spinner}- <p className="mb-2">- Purchasing {amount} ${symbol}...- </p>- </div>- )-- const systemMessage = createStreamableUI(null)-- runAsyncFnWithoutBlocking(async () => {- await sleep(1000)-- purchasing.update(- <div className="inline-flex items-start gap-1 md:items-center">- {spinner}- <p className="mb-2">- Purchasing {amount} ${symbol}... working on it...- </p>- </div>- )-- await sleep(1000)-- purchasing.done(- <div>- <p className="mb-2">- You have successfully purchased {amount} ${symbol}. Total cost:{' '}- {formatNumber(amount * price)}- </p>- </div>- )-- systemMessage.done(- <SystemMessage>- You have purchased {amount} shares of {symbol} at ${price}. Total cost ={' '}- {formatNumber(amount * price)}.- </SystemMessage>- )-- aiState.done({- ...aiState.get(),- messages: [- ...aiState.get().messages,- {- id: nanoid(),- role: 'system',- content: `[User has purchased ${amount} shares of ${symbol} at ${price}. Total cost = ${- amount * price- }]`- }- ]- })- })-- return {- purchasingUI: purchasing.value,- newMessage: {- id: nanoid(),- display: systemMessage.value- }- }-}-async function submitUserMessage(content: string) {'use server'@@ -131,20 +61,9 @@ async function submitUserMessage(content: string) {model: openai('gpt-3.5-turbo'),initial: <SpinnerMessage />,system: `\- You are a stock trading conversation bot and you can help users buy stocks, step by step.- You and the user can discuss stock prices and the user can adjust the amount of stocks they want to buy, or place an order, in the UI.-- Messages inside [] means that it's a UI element or a user event. For example:- - "[Price of AAPL = 100]" means that an interface of the stock price of AAPL is shown to the user.- - "[User has changed the amount of AAPL to 10]" means that the user has changed the amount of AAPL to 10 in the UI.-- If the user requests purchasing a stock, call \`show_stock_purchase_ui\` to show the purchase UI.- If the user just wants the price, call \`show_stock_price\` to show the price.- If you want to show trending stocks, call \`list_stocks\`.- If you want to show events, call \`get_events\`.- If the user wants to sell stock, or complete another impossible task, respond that you are a demo and cannot do that.-- Besides that, you can also chat with users and do some calculations if needed.`,+ You are a personal assistant that has access to the history of laptop screen time and audio of the user.+ Cou can help user find information recorded in the screen, and audio.+ Once you receive a query, you call a local server to retrieve information and then answer user query as much as possible.`,messages: [...aiState.get().messages.map((message: any) => ({role: message.role,@@ -178,304 +97,6 @@ async function submitUserMessage(content: string) {return textNode},tools: {- listStocks: {- description: 'List three imaginary stocks that are trending.',- parameters: z.object({- stocks: z.array(- z.object({- symbol: z.string().describe('The symbol of the stock'),- price: z.number().describe('The price of the stock'),- delta: z.number().describe('The change in price of the stock')- })- )- }),- generate: async function* ({ stocks }) {- yield (- <BotCard>- <StocksSkeleton />- </BotCard>- )-- await sleep(1000)-- const toolCallId = nanoid()-- aiState.done({- ...aiState.get(),- messages: [- ...aiState.get().messages,- {- id: nanoid(),- role: 'assistant',- content: [- {- type: 'tool-call',- toolName: 'listStocks',- toolCallId,- args: { stocks }- }- ]- },- {- id: nanoid(),- role: 'tool',- content: [- {- type: 'tool-result',- toolName: 'listStocks',- toolCallId,- result: stocks- }- ]- }- ]- })-- return (- <BotCard>- <Stocks props={stocks} />- </BotCard>- )- }- },- showStockPrice: {- description:- 'Get the current stock price of a given stock or currency. Use this to show the price to the user.',- parameters: z.object({- symbol: z- .string()- .describe(- 'The name or symbol of the stock or currency. e.g. DOGE/AAPL/USD.'- ),- price: z.number().describe('The price of the stock.'),- delta: z.number().describe('The change in price of the stock')- }),- generate: async function* ({ symbol, price, delta }) {- yield (- <BotCard>- <StockSkeleton />- </BotCard>- )-- await sleep(1000)-- const toolCallId = nanoid()-- aiState.done({- ...aiState.get(),- messages: [- ...aiState.get().messages,- {- id: nanoid(),- role: 'assistant',- content: [- {- type: 'tool-call',- toolName: 'showStockPrice',- toolCallId,- args: { symbol, price, delta }- }- ]- },- {- id: nanoid(),- role: 'tool',- content: [- {- type: 'tool-result',- toolName: 'showStockPrice',- toolCallId,- result: { symbol, price, delta }- }- ]- }- ]- })-- return (- <BotCard>- <Stock props={{ symbol, price, delta }} />- </BotCard>- )- }- },- showStockPurchase: {- description:- 'Show price and the UI to purchase a stock or currency. Use this if the user wants to purchase a stock or currency.',- parameters: z.object({- symbol: z- .string()- .describe(- 'The name or symbol of the stock or currency. e.g. DOGE/AAPL/USD.'- ),- price: z.number().describe('The price of the stock.'),- numberOfShares: z- .number()- .optional()- .describe(- 'The **number of shares** for a stock or currency to purchase. Can be optional if the user did not specify it.'- )- }),- generate: async function* ({ symbol, price, numberOfShares = 100 }) {- const toolCallId = nanoid()-- if (numberOfShares <= 0 || numberOfShares > 1000) {- aiState.done({- ...aiState.get(),- messages: [- ...aiState.get().messages,- {- id: nanoid(),- role: 'assistant',- content: [- {- type: 'tool-call',- toolName: 'showStockPurchase',- toolCallId,- args: { symbol, price, numberOfShares }- }- ]- },- {- id: nanoid(),- role: 'tool',- content: [- {- type: 'tool-result',- toolName: 'showStockPurchase',- toolCallId,- result: {- symbol,- price,- numberOfShares,- status: 'expired'- }- }- ]- },- {- id: nanoid(),- role: 'system',- content: `[User has selected an invalid amount]`- }- ]- })-- return <BotMessage content={'Invalid amount'} />- } else {- aiState.done({- ...aiState.get(),- messages: [- ...aiState.get().messages,- {- id: nanoid(),- role: 'assistant',- content: [- {- type: 'tool-call',- toolName: 'showStockPurchase',- toolCallId,- args: { symbol, price, numberOfShares }- }- ]- },- {- id: nanoid(),- role: 'tool',- content: [- {- type: 'tool-result',- toolName: 'showStockPurchase',- toolCallId,- result: {- symbol,- price,- numberOfShares- }- }- ]- }- ]- })-- return (- <BotCard>- <Purchase- props={{- numberOfShares,- symbol,- price: +price,- status: 'requires_action'- }}- />- </BotCard>- )- }- }- },- getEvents: {- description:- 'List funny imaginary events between user highlighted dates that describe stock activity.',- parameters: z.object({- events: z.array(- z.object({- date: z- .string()- .describe('The date of the event, in ISO-8601 format'),- headline: z.string().describe('The headline of the event'),- description: z.string().describe('The description of the event')- })- )- }),- generate: async function* ({ events }) {- yield (- <BotCard>- <EventsSkeleton />- </BotCard>- )-- await sleep(1000)-- const toolCallId = nanoid()-- aiState.done({- ...aiState.get(),- messages: [- ...aiState.get().messages,- {- id: nanoid(),- role: 'assistant',- content: [- {- type: 'tool-call',- toolName: 'getEvents',- toolCallId,- args: { events }- }- ]- },- {- id: nanoid(),- role: 'tool',- content: [- {- type: 'tool-result',- toolName: 'getEvents',- toolCallId,- result: events- }- ]- }- ]- })-- return (- <BotCard>- <Events props={events} />- </BotCard>- )- }- },queryScreenpipeAPI: {description:'Query the Screenpipe API for OCR that appeared on user s screen and audio transcriptions from his mic',@@ -518,7 +139,7 @@ async function submitUserMessage(content: string) {try {const response = await fetch(- `http://localhost:3030/search?q=${encodeURIComponent(query)}&content_type=${contentType}&limit=${limit}&offset=${offset}`+ `http://127.0.0.1:3030/search?q=${encodeURIComponent(query)}&content_type=${contentType}&limit=${limit}&offset=${offset}`)if (!response.ok) {@@ -537,9 +158,9 @@ async function submitUserMessage(content: string) {// Create a prompt for GPT-4const prompt = `Based on the following search results, please provide a concise and informative answer to the user's query "${query}":-${dataForGPT}+ ${dataForGPT}-Please summarize the key points and present the information in a clear, easy-to-read format.`+ Please summarize the key points and present the information in a clear, easy-to-read format.`let textStream = createStreamableValue('')let textNode = <BotMessage content={textStream.value} />@@ -592,8 +213,8 @@ Please summarize the key points and present the information in a clear, easy-to-{isStreamingComplete && (<MemoizedReactMarkdown className="prose break-words dark:prose-invert prose-p:leading-relaxed prose-pre:p-0 max-w-full max-h-[300px] overflow-auto border border-gray-200 rounded-md mt-4">{`\`\`\`json-${dataForGPT}-\`\`\``}+ ${dataForGPT}+ \`\`\``}</MemoizedReactMarkdown>)}</>@@ -604,6 +225,7 @@ ${dataForGPT}return gpt4Response.value} catch (error) {console.error('Error querying Screenpipe API:', error)+ console.log('REQUEST: ',`http://127.0.0.1:3030/search?q=${encodeURIComponent(query)}&content_type=${contentType}&limit=${limit}&offset=${offset}`)return (<BotCard><div className="text-red-500">@@ -636,7 +258,6 @@ export type UIState = {export const AI = createAI<AIState, UIState>({actions: {submitUserMessage,- confirmPurchase},initialUIState: [],initialAIState: { chatId: nanoid(), messages: [] },