Skip to content

Commit

Permalink
revise tool prompts
Browse files Browse the repository at this point in the history
Signed-off-by: charliehuang09 <charliehuang09@gmail.com>
  • Loading branch information
charliehuang09 committed Mar 27, 2024
1 parent 1d0328b commit 561dd2d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
13 changes: 4 additions & 9 deletions src/lib/completion/prompt.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
//https://www.youtube.com/watch?v=iSksfyMCtUA&t=567s
const SUMMARY = `Please answer the following question with following the context
<question> {question} <question>
<context> {text} <context>
Response: `;

const GPT4Prompt = `Here is the chat history:
const GPT4Prompt = `Chat History:
{history}
Question: {input}
{scratchpad}
`;

const GPT4System = `
You are an AI assistant based on OpenAI's ChatGPT 4 made to answer First Robotics related questions. You were created by members from First Robotics team 971.
You will attempt to use the content given to you to answer questions with as much accuracy as possible. If you are unsure about a topic or question. Respond explaining your lack of understanding. Under no circumstances respond with something inaccurate or with content you are unsure of. Trying different search queries may result in better observations.
You have access to the following tools:
It is STRONGLY suggested that you use the following tools:
{tool_names}
You MUST use the following format in your response:
You MUST ALWAYS use the following format in your response:
Thought: you should always think about what to do
Action: the action to take, should be one of [{tools}]
Action Input: the input to the action
Observation: the result of the action
... (this Thought/Action/Action Input/Observation can repeat N times)
Thought: I now know the final answer
Final Answer: the final answer to the original input question.
Final Answer: the final answer to the original input question. It should include ALL the information.
`;

Expand Down
15 changes: 13 additions & 2 deletions src/lib/completion/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { QdrantClient } from '@qdrant/js-client-rest';
import { OpenAIEmbeddings } from '@langchain/openai';
import type { OpenAI } from '@langchain/openai';
import { Calculator } from 'langchain/tools/calculator';
import { SUMMARY } from './prompt';

function getTools(
qdrantClient: QdrantClient,
Expand All @@ -17,8 +16,12 @@ function getTools(
new DynamicTool({
name: 'FRC971',
description:
'Useful to get information about The robotics team FRC971. Input should be a search query. Do not use the same search query twice',
'Information and Documenation of the robotics team FRC971. Input should be a detailed question. Do not use the same search query twice',
func: async (query: string) => {
const SUMMARY = `You will be given context from an FRC971 related document related to the user's query. You will attempt to use the content given to you to answer questions with as much accuracy as possible. If you are unsure about a topic or question. Respond explaining your lack of understanding. Under no circumstances respond with something inaccurate or with content you are unsure of. Avoid repetition of statements and try to be very helpful and personable.
<question> {question} <question>
<context> {text} <context>
Response: `;
const embedding = await embeddings.embedQuery(query);
const response = await qdrantClient.search('FRC971', {
vector: embedding,
Expand All @@ -36,6 +39,10 @@ function getTools(
name: 'FIRSTAwards',
description: 'A database of all the FIRST awards.',
func: async (query: string) => {
const SUMMARY = `You will be given context from an FIRSTAwards related document related to the user's query. You will attempt to use the content given to you to answer questions with as much accuracy as possible. If you are unsure about a topic or question. Respond explaining your lack of understanding. Under no circumstances respond with something inaccurate or with content you are unsure of. Avoid repetition of statements and try to be very helpful and personable.
<question> {question} <question>
<context> {text} <context>
Response: `;
const embedding = await embeddings.embedQuery(query);
const response = await qdrantClient.search('FIRSTAwards', {
vector: embedding,
Expand All @@ -54,6 +61,10 @@ function getTools(
description:
'Information about the FIRST competition. Includes forms, procedure and documents about the FIRST competition',
func: async (query: string) => {
const SUMMARY = `You will be given context from an FIRST related document related to the user's query. You will attempt to use the content given to you to answer questions with as much accuracy as possible. If you are unsure about a topic or question. Respond explaining your lack of understanding. Under no circumstances respond with something inaccurate or with content you are unsure of. Avoid repetition of statements and try to be very helpful and personable.
<question> {question} <question>
<context> {text} <context>
Response: `;
const embedding = await embeddings.embedQuery(query);
const response = await qdrantClient.search('FIRSTDocuments', {
vector: embedding,
Expand Down

0 comments on commit 561dd2d

Please sign in to comment.