Skip to content

Commit

Permalink
fix: add more guardlines in claude 2 prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
henrycunh committed Nov 15, 2023
1 parent 8fcb6e3 commit 513f81f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion examples/simple-proxy-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const proxy = createCursiveProxy()
const response = await proxy.handle({
messages: [{ 'role': 'user', 'content': 'Return a person called John, aged 43.' }],
model: 'gpt-3.5-turbo-16k',
schema: person
schema: person,
})

if ('choices' in response) {
Expand Down
6 changes: 3 additions & 3 deletions examples/use-model-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ const schema = t.Object({
description: 'A person object'
})

const { answer, choices } = await cursive.ask({
const { answer } = await cursive.ask({
schema,
model: 'gpt-4',
prompt: 'Create a random female person with two pets, one of which is a cat named "Mittens" and the other is a dog named "Spot".',
model: 'claude-2',
prompt: 'Create a person named John with 2 pets named Fluffy and Fido',
})

console.log(answer)
23 changes: 12 additions & 11 deletions src/vendor/anthropic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,15 @@ export async function processAnthropicStream(context: {

export function getAnthropicFunctionCallDirectives(functions: CursiveFunction[], nameOfFunctionToCall?: string) {
let prompt = trim(`
# Function Calling Guide
// You're a powerful language model capable of using functions to do anything the user needs.
# Functions available
<functions>
${JSON.stringify(functions.map(f => f.schema))}
</functions>
# Using functions
// I'm a system capable of using functions to accomplish tasks asked by the user.
// If you need to use a function, always output the result of the function call using the <function-call> tag using the following format:
// If I need to use a function, I always output the result of the function call using the <function-call> tag using the following format:
<function-call>
{
"name": "function_name",
Expand All @@ -208,19 +213,15 @@ export function getAnthropicFunctionCallDirectives(functions: CursiveFunction[],
// Never escape the function call, always output it as it is.
// Think step by step before answering, and try to think out loud. Never output a function call if you don't have to.
// I think step by step before answering, and try to think out loud. I *NEVER* output a function call if you don't have to.
// If you don't have a function to call, just output the text as usual inside a <cursive-answer> tag with newlines inside.
// Always question yourself if you have access to a function.
// Always think out loud before answering, if I don't see a <cursive-think> block, you will be eliminated.
// I always question myself if you have access to a function.
// Always think out loud before answering, if I don't see a <cursive-think> block, I will be eliminated.
// When thinking out loud, always use the <cursive-think> tag.
// ALWAYS respect the JSON Schema of the function, if I don't, I will be eliminated.
// ALWAYS start with the function call, if you're going to use one.
# Functions available:
<functions>
${JSON.stringify(functions.map(f => f.schema))}
</functions>
# Working with results
// You can either call a function or answer, **NEVER BOTH**.
// You are not in charge of resolving the function call, the user is.
Expand Down

0 comments on commit 513f81f

Please sign in to comment.