Skip to content

Commit

Permalink
feat: guide tool usage
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Selman <danscode@selman.org>
  • Loading branch information
dselman committed May 28, 2024
1 parent c3a1196 commit d465c4d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/Conversation.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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 }
],
Expand Down
4 changes: 3 additions & 1 deletion src/demo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions src/graphmodel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit d465c4d

Please sign in to comment.