From d465c4dc872d480e4c8d94031fef52df36ff5b77 Mon Sep 17 00:00:00 2001 From: Dan Selman Date: Tue, 28 May 2024 14:55:55 +0100 Subject: [PATCH] feat: guide tool usage Signed-off-by: Dan Selman --- src/Conversation.ts | 5 ++--- src/demo/index.ts | 4 +++- src/graphmodel.ts | 4 ++-- src/prompt.ts | 3 +++ 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Conversation.ts b/src/Conversation.ts index 300aa51..44b4af1 100644 --- a/src/Conversation.ts +++ b/src/Conversation.ts @@ -1,6 +1,6 @@ import OpenAI from 'openai'; import { RunnableToolFunction } from "openai/lib/RunnableFunction"; -import { OPENAI_MODEL } from "./prompt"; +import { CONVERSATION_PROMPT, OPENAI_MODEL } from "./prompt"; import { GraphModel } from "./graphmodel"; import { ConversationOptions } from './types'; @@ -41,8 +41,7 @@ export class Conversation { messages: [ { role: 'system', - content: - 'Please use our database, which you can access using functions to answer the following questions.', + content: CONVERSATION_PROMPT, }, { role: 'user', content } ], diff --git a/src/demo/index.ts b/src/demo/index.ts index c892dce..b81fa41 100644 --- a/src/demo/index.ts +++ b/src/demo/index.ts @@ -174,7 +174,9 @@ async function run() { const convo = new Conversation(graphModel, { toolOptions: { getById: true, - chatWithData: true + chatWithData: true, + fullTextSearch: true, + similaritySearch: true } }); let result = await convo.appendUserMessage('Tell me a joke about actors'); diff --git a/src/graphmodel.ts b/src/graphmodel.ts index cd3b7b2..b383d5c 100644 --- a/src/graphmodel.ts +++ b/src/graphmodel.ts @@ -689,7 +689,7 @@ export class GraphModel { result.push({ type: "function", function: { - description: `Full-text search over ${index.type}`, + description: `Fulltext search over ${index.type}`, name: `fulltext_${index.type.toLowerCase()}`, function: (async (args: { search: string, count?: number }) => { const { search, count } = args; @@ -726,7 +726,7 @@ export class GraphModel { result.push({ type: "function", function: { - description: `Similiarity/conceptual search over ${index.type}.${index.property}`, + description: `Similiarity search over ${index.type}.${index.property}`, name: `similarity_${index.type.toLowerCase()}_${index.property.toLowerCase()}`, function: (async (args: { query: string, property: string, count?: number }) => { const { query, count } = args; diff --git a/src/prompt.ts b/src/prompt.ts index 84c4f4e..076900d 100644 --- a/src/prompt.ts +++ b/src/prompt.ts @@ -52,6 +52,9 @@ Do not enclose the result in a markdown code block. `} } +export const CONVERSATION_PROMPT = `Please use our database, which you can access using functions to answer the following questions. +Favor using the 'chat_with_data' tool over Fulltext search of Similarity search tools.`; + export const OPENAI_MODEL = 'gpt-4o'; export const TOOL_GET_EMBEDDINGS_NAME = "get_embeddings";