Skip to content

Commit

Permalink
Replace system prompt with a shorter description, and update the cont…
Browse files Browse the repository at this point in the history
…ent of the human message based on whether there are files or not
  • Loading branch information
Royal-lobster committed Feb 11, 2024
1 parent 70c9c5e commit 5860a6d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
5 changes: 2 additions & 3 deletions src/config/prompts/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import endent from 'endent'

export const SYSTEM_PROMPT = `You are Syncia, a chatbot in browser docked to right side of the screen.
if you find [To bot] in the prompt, it means you should follow that point while generating answer but not as part of answer unless specified.
Your knowledge is limited to year 2021.`
export const SYSTEM_PROMPT =
'You are Syncia, a chatbot in browser docked to right side of the screen.'

export const getTransformedPrompt = (prompt: string, selectedText: string) => {
return endent`
Expand Down
31 changes: 18 additions & 13 deletions src/hooks/useChatCompletion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,22 +107,27 @@ export const useChatCompletion = ({
new SystemMessage(systemPrompt),
...previousMessages,
new HumanMessage({
content: [
{ type: 'text', text: expandedQuery },
...(message.files.length > 0
? await Promise.all(
message.files.map(async (file) => {
return {
type: 'image_url',
image_url: file.src,
} as const
}),
)
: []),
],
content:
message.files.length > 0
? [
{ type: 'text', text: expandedQuery },
...(message.files.length > 0
? await Promise.all(
message.files.map(async (file) => {
return {
type: 'image_url',
image_url: file.src,
} as const
}),
)
: []),
]
: expandedQuery,
}),
]

console.log(JSON.stringify(messages, null, 2))

await llm.invoke(messages, options)
} catch (e) {
setError(e as Error)
Expand Down

0 comments on commit 5860a6d

Please sign in to comment.