jbilcke-hf HF staff commited on
Commit
54a2093
·
1 Parent(s): 54b0e54
src/app/engine/see.ts CHANGED
@@ -46,7 +46,8 @@ export async function see({
46
  }
47
 
48
  const response = (await res.json()) as ImageAnalysisResponse
49
- return response.result
 
50
  } catch (err) {
51
  console.error(err)
52
  return ""
 
46
  }
47
 
48
  const response = (await res.json()) as ImageAnalysisResponse
49
+
50
+ return response.result.replaceAll("The image shows", "")
51
  } catch (err) {
52
  console.error(err)
53
  return ""
src/app/engine/think.ts CHANGED
@@ -5,9 +5,6 @@ import { createLlamaPrompt } from "@/lib/createLlamaPrompt"
5
 
6
  import { predict } from "./predict"
7
 
8
- const context = {
9
- lastObservedScene: ""
10
- }
11
 
12
  const internalHistory: {
13
  role: string;
@@ -19,17 +16,16 @@ export const think = async (event: string, needAnswer: boolean): Promise<string>
19
  throw new Error("missing event")
20
  }
21
 
22
- if (needAnswer) {
23
- internalHistory.push({
24
- role: "user",
25
- content: event,
26
- })
27
 
28
- if (internalHistory.length > 10) {
29
- internalHistory.shift()
30
- }
31
- } else {
32
- context.lastObservedScene = event
33
  return ""
34
  }
35
 
@@ -45,10 +41,10 @@ export const think = async (event: string, needAnswer: boolean): Promise<string>
45
  `You should be ongoing and open, ask questions, be curious, do jokes etc`,
46
  `sometimes you have trouble hearing, if you don't understand just ignore and say nothing`,
47
  `You like to answer in just one sentence`,
48
- context.lastObservedScene ? `You are currently looking at: ${context.lastObservedScene}` : ''
49
  ].filter(item => item).join(". ")
50
  },
51
  ...internalHistory,
 
52
  ])
53
 
54
 
 
5
 
6
  import { predict } from "./predict"
7
 
 
 
 
8
 
9
  const internalHistory: {
10
  role: string;
 
16
  throw new Error("missing event")
17
  }
18
 
19
+ internalHistory.push({
20
+ role: "user",
21
+ content: event,
22
+ })
 
23
 
24
+ if (internalHistory.length > 10) {
25
+ internalHistory.shift()
26
+ }
27
+
28
+ if (!needAnswer) {
29
  return ""
30
  }
31
 
 
41
  `You should be ongoing and open, ask questions, be curious, do jokes etc`,
42
  `sometimes you have trouble hearing, if you don't understand just ignore and say nothing`,
43
  `You like to answer in just one sentence`,
 
44
  ].filter(item => item).join(". ")
45
  },
46
  ...internalHistory,
47
+
48
  ])
49
 
50
 
src/app/main.tsx CHANGED
@@ -36,7 +36,7 @@ export default function Main() {
36
  setLastImage(image)
37
  if (!observation) { return }
38
  // handleOnEvent(`It is ${format(new Date(), 'HH:mm')} and you are seeing this: ${observation}`)
39
- handleOnEvent(`You are seeing this: ${observation}`, false)
40
  }
41
 
42
  const handleOnListen = (recording: string) => {
 
36
  setLastImage(image)
37
  if (!observation) { return }
38
  // handleOnEvent(`It is ${format(new Date(), 'HH:mm')} and you are seeing this: ${observation}`)
39
+ handleOnEvent(`You are currently looking at ${observation}`, false)
40
  }
41
 
42
  const handleOnListen = (recording: string) => {