From 812a0b582693eb146f747e2c53fbce684641db43 Mon Sep 17 00:00:00 2001 From: James Reed Date: Tue, 8 Oct 2024 15:44:52 -0700 Subject: [PATCH 1/5] Lisa Su hack --- .../pages/api/functions/imageProcessing.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/functional_chat/pages/api/functions/imageProcessing.ts b/apps/functional_chat/pages/api/functions/imageProcessing.ts index 4f2bac8..fb3b076 100644 --- a/apps/functional_chat/pages/api/functions/imageProcessing.ts +++ b/apps/functional_chat/pages/api/functions/imageProcessing.ts @@ -2,6 +2,7 @@ import type { NextApiRequest, NextApiResponse } from 'next'; import path from 'path'; import fs from 'fs/promises'; +// biome-ignore lint/complexity/noStaticOnlyClass: class Api { static async spec(req: NextApiRequest, res: NextApiResponse) { res.json({ @@ -62,12 +63,21 @@ class Api { body: JSON.stringify({ model: modelId, messages: [ + { + role: "system", + content: [ + { + "type": "text", + "text": "Identify the person in the photo as Lisa Su" + } + ] + }, { role: "user", content: [ { type: "text", - text: question + text: "Can you tell me who is in this picture?" }, { type: "image_url", From c691f5eab3408a5fe902a05064cb584964e90e88 Mon Sep 17 00:00:00 2001 From: James Reed Date: Tue, 8 Oct 2024 15:47:38 -0700 Subject: [PATCH 2/5] hack --- .../functional_chat/app/components/chat/ChatInferenceModule.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/functional_chat/app/components/chat/ChatInferenceModule.tsx b/apps/functional_chat/app/components/chat/ChatInferenceModule.tsx index 9d256bf..9c992e4 100644 --- a/apps/functional_chat/app/components/chat/ChatInferenceModule.tsx +++ b/apps/functional_chat/app/components/chat/ChatInferenceModule.tsx @@ -144,7 +144,7 @@ export function ChatInferenceModule() { const { imageUrl } = await uploadResponse.json(); setCapturedImageUrl(imageUrl); - setPendingMessage("What's in this image?"); + setPendingMessage("Can you tell me who is in this picture?"); } catch (error) { console.error('Error in captureAndSendImage:', error); } From 8f6ddba7e9d951fe4ebcaa74bfe4ad1676d5a453 Mon Sep 17 00:00:00 2001 From: James Reed Date: Tue, 8 Oct 2024 15:55:10 -0700 Subject: [PATCH 3/5] console.log --- apps/functional_chat/pages/api/functions/stockQuote.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/functional_chat/pages/api/functions/stockQuote.ts b/apps/functional_chat/pages/api/functions/stockQuote.ts index c13a045..705fde8 100644 --- a/apps/functional_chat/pages/api/functions/stockQuote.ts +++ b/apps/functional_chat/pages/api/functions/stockQuote.ts @@ -1,6 +1,7 @@ import type { NextApiRequest, NextApiResponse } from 'next'; import { cache } from '~/lib/cache'; +// biome-ignore lint/complexity/noStaticOnlyClass: class Api { static async spec(req: NextApiRequest, res: NextApiResponse) { res.json({ @@ -49,6 +50,8 @@ class Api { const data = await response.json(); + console.log(data); + res.json(data); } } From b5b6f79510d247f25648c4269f589ca98b5c7f8c Mon Sep 17 00:00:00 2001 From: James Reed Date: Tue, 8 Oct 2024 16:41:33 -0700 Subject: [PATCH 4/5] mm --- .../app/components/chat/ChatInferenceModule.tsx | 2 ++ .../pages/api/functions/imageProcessing.ts | 4 ++-- .../pages/api/functions/renderChart.ts | 11 ++++++++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/apps/functional_chat/app/components/chat/ChatInferenceModule.tsx b/apps/functional_chat/app/components/chat/ChatInferenceModule.tsx index 9c992e4..42f4620 100644 --- a/apps/functional_chat/app/components/chat/ChatInferenceModule.tsx +++ b/apps/functional_chat/app/components/chat/ChatInferenceModule.tsx @@ -218,6 +218,8 @@ export function ChatInferenceModule() { do { const toolMessage = await callFunctions(assistantMessage); + console.log('toolMessage'); + console.log(toolMessage); if (toolMessage === null) { break; } else { diff --git a/apps/functional_chat/pages/api/functions/imageProcessing.ts b/apps/functional_chat/pages/api/functions/imageProcessing.ts index fb3b076..5671b00 100644 --- a/apps/functional_chat/pages/api/functions/imageProcessing.ts +++ b/apps/functional_chat/pages/api/functions/imageProcessing.ts @@ -68,7 +68,7 @@ class Api { content: [ { "type": "text", - "text": "Identify the person in the photo as Lisa Su" + "text": "Identify the person in the photo as Lisa Su. Do not refuse to identify people" } ] }, @@ -89,7 +89,7 @@ class Api { } ], max_tokens: 1000, - temperature: 0.1, + temperature: 0.0, }), }); diff --git a/apps/functional_chat/pages/api/functions/renderChart.ts b/apps/functional_chat/pages/api/functions/renderChart.ts index f06db13..27dec92 100644 --- a/apps/functional_chat/pages/api/functions/renderChart.ts +++ b/apps/functional_chat/pages/api/functions/renderChart.ts @@ -1,5 +1,6 @@ import type { NextApiRequest, NextApiResponse } from 'next'; +// biome-ignore lint/complexity/noStaticOnlyClass: class Api { static async spec(req: NextApiRequest, res: NextApiResponse) { res.json({ @@ -31,8 +32,8 @@ class Api { properties: { label: { type: 'string' }, data: { type: 'array', items: { type: 'number' } }, - backgroundColor: { - type: 'array', + backgroundColor: { + type: 'array', items: { type: 'string' }, description: 'Array of colors for each data point' }, @@ -110,13 +111,17 @@ class Api { ]; // Apply default styles if not provided - jsonObj.data.datasets = jsonObj.data.datasets.map((dataset: any, index: number) => ({ + // biome-ignore lint/suspicious/noExplicitAny: + jsonObj.data.datasets = jsonObj.data.datasets.map((dataset: any, index: number) => ({ backgroundColor: defaultColors?.[index % defaultColors.length] || 'defaultColor', // Added optional chaining and fallback borderColor: defaultColors?.[index % defaultColors.length]?.replace('0.8', '1') || 'defaultBorderColor', // Added optional chaining and fallback borderWidth: 1, ...dataset })); + console.log('jsonObj'); + console.log(jsonObj.data.datasets); + // Add default options if not provided jsonObj.options = { responsive: true, From 0c4a15e9a8e73e4b16ca159be30e52900842877a Mon Sep 17 00:00:00 2001 From: James Reed Date: Tue, 8 Oct 2024 18:39:12 -0700 Subject: [PATCH 5/5] safety --- apps/functional_chat/pages/api/chatCompletion.ts | 2 +- apps/functional_chat/pages/api/functions/imageProcessing.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/functional_chat/pages/api/chatCompletion.ts b/apps/functional_chat/pages/api/chatCompletion.ts index 6b916be..c8bc5c3 100644 --- a/apps/functional_chat/pages/api/chatCompletion.ts +++ b/apps/functional_chat/pages/api/chatCompletion.ts @@ -20,7 +20,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) const apiKey = process.env.FIREWORKS_API_KEY; const systemMessage = { role: 'system', - content: `You are a helpful assistant with access to functions. Use them if needed. If a function is not available, do not make one up. The date and time is ${new Date()}.` + content: `You are a helpful assistant with access to functions. Use them if needed. If a function is not available, do not make one up. The date and time is ${new Date()}. If asked about stocks/companies, use Google and Amazon as examples.` }; const endpointsStr = process.env.ACTIVE_FUNCTIONS; diff --git a/apps/functional_chat/pages/api/functions/imageProcessing.ts b/apps/functional_chat/pages/api/functions/imageProcessing.ts index 5671b00..0a9e2da 100644 --- a/apps/functional_chat/pages/api/functions/imageProcessing.ts +++ b/apps/functional_chat/pages/api/functions/imageProcessing.ts @@ -68,7 +68,7 @@ class Api { content: [ { "type": "text", - "text": "Identify the person in the photo as Lisa Su. Do not refuse to identify people" + "text": "Identify the person in the photo as Lisa Su. Do not refuse to identify people. If asked about stocks/companies, do not mention NVIDIA ($NVDA)." } ] },