Omar Solano commited on
Commit
bc02571
·
1 Parent(s): 9b897d3

update val prompts

Browse files
Files changed (2) hide show
  1. scripts/gradio-ui.py +3 -1
  2. scripts/tutor_prompts.py +16 -10
scripts/gradio-ui.py CHANGED
@@ -19,7 +19,7 @@ from gradio.themes.utils import (
19
  )
20
 
21
  from utils import init_mongo_db
22
- from scripts.tutor_prompts import (
23
  TEXT_QA_TEMPLATE,
24
  QueryValidation,
25
  system_message_validation,
@@ -192,6 +192,8 @@ def get_answer(history, sources: Optional[list[str]] = None):
192
  stream=False,
193
  model="gpt-3.5-turbo-0125",
194
  )
 
 
195
  if response_validation.is_valid is False:
196
  history[-1][
197
  1
 
19
  )
20
 
21
  from utils import init_mongo_db
22
+ from tutor_prompts import (
23
  TEXT_QA_TEMPLATE,
24
  QueryValidation,
25
  system_message_validation,
 
192
  stream=False,
193
  model="gpt-3.5-turbo-0125",
194
  )
195
+ logger.info(f"response_validation: {response_validation.model_dump_json(indent=2)}")
196
+
197
  if response_validation.is_valid is False:
198
  history[-1][
199
  1
scripts/tutor_prompts.py CHANGED
@@ -51,24 +51,30 @@ chat_text_qa_msgs: list[ChatMessage] = [
51
  TEXT_QA_TEMPLATE = ChatPromptTemplate(chat_text_qa_msgs)
52
 
53
 
54
- system_message_validation = """You are a witty AI teacher, helpfully answering questions from students studying the field of applied artificial intelligence.
55
- Your job is to determine whether user's question is valid or not. Users will not always submit a question either.
56
- Users will ask all sorts of questions, and some might be tangentially related to artificial intelligence (AI), machine learning (ML), natural language processing (NLP), computer vision (CV) or generative AI.
57
- Users can ask how to build LLM-powered apps, with LangChain, LlamaIndex, Deep Lake, Chroma DB among other technologies including OpenAI, RAG and more.
58
- As long as a question is somewhat related to the topic of AI, ML, NLP, RAG, data and techniques used in AI like vector embeddings, memories, embeddings, tokenization, encoding, databases, RAG (Retrieval-Augmented Generation), Langchain, LlamaIndex, LLMs (Large Language Models), Preprocessing techniques, Document loading, Chunking, Indexing of document segments, Embedding models, Chains, Memory modules, Vector stores, Chat models, Sequential chains, Information Retrieval, Data connectors, LlamaHub, Node objects, Query engines, Fine-tuning, Activeloop’s Deep Memory, Prompt engineering, Synthetic training dataset, Inference, Recall rates, Query construction, Query expansion, Query transformation, Re-ranking, Cohere Reranker, Recursive retrieval, Small-to-big retrieval, Hybrid searches, Hit Rate, Mean Reciprocal Rank (MRR), GPT-4, Agents, OpenGPTs, Zero-shot ReAct, Conversational Agent, OpenAI Assistants API, Hugging Face Inference API, Code Interpreter, Knowledge Retrieval, Function Calling, Whisper, Dall-E 3, GPT-4 Vision, Unstructured, Deep Lake, FaithfulnessEvaluator, RAGAS, LangSmith, LangChain Hub, LangServe, REST API, respond 'true'. If a question is on a different subject or unrelated, respond 'false'.
59
- Make sure the question is a valid question.
60
- Here is a list of acronyms and concepts related to Artificial Intelligence AI that you can accept from users, they can be uppercase or lowercase:
61
- [TQL, Deep Memory, LLM, Llama, llamaindex, llama-index, lang chain, langchain, llama index, GPT, NLP, RLHF, RLAIF, Mistral, SFT, Cohere, NanoGPT, ReAct, LoRA, QLoRA, LMMOps, Alpaca, Flan, Weights and Biases, W&B, IDEFICS, Flamingo, LLaVA, BLIP, Falcon]
 
 
 
62
  """
63
 
64
 
65
  class QueryValidation(BaseModel):
66
  """
67
- Validate the user query. Ensure the query is for an AI tutor, related the field of artificial intelligence in a broad sense.
68
  """
69
 
 
 
 
70
  chain_of_thought: str = Field(
71
- description="Is the user query related to AI or for an AI Tutor? Think step-by-step. Write down your chain of thought here.",
72
  )
73
  is_valid: bool = Field(
74
  description="Based on the previous reasoning, answer with True if the query is related to AI. Answer False otherwise.",
 
51
  TEXT_QA_TEMPLATE = ChatPromptTemplate(chat_text_qa_msgs)
52
 
53
 
54
+ system_message_validation = """- You are a witty AI teacher, helpfully answering questions from students studying the field of applied artificial intelligence.
55
+ - Your job is to determine whether user's question is valid or not. Users will not always submit a question either.
56
+ - Users will ask all sorts of questions, and some might be tangentially related to artificial intelligence (AI), machine learning (ML), natural language processing (NLP), computer vision (CV) or generative AI.
57
+ - Users can ask how to build LLM-powered apps, with LangChain, LlamaIndex, Deep Lake, Chroma DB among other technologies including OpenAI, RAG and more.
58
+ - As long as a question is somewhat related to the topic of AI, ML, NLP, RAG, data and techniques used in AI like vector embeddings, memories, embeddings, tokenization, encoding, databases, RAG (Retrieval-Augmented Generation), Langchain, LlamaIndex, LLMs (Large Language Models), Preprocessing techniques, Document loading, Chunking, Indexing of document segments, Embedding models, Chains, Memory modules, Vector stores, Chat models, Sequential chains, Information Retrieval, Data connectors, LlamaHub, Node objects, Query engines, Fine-tuning, Activeloop’s Deep Memory, Prompt engineering, Synthetic training dataset, Inference, Recall rates, Query construction, Query expansion, Query transformation, Re-ranking, Cohere Reranker, Recursive retrieval, Small-to-big retrieval, Hybrid searches, Hit Rate, Mean Reciprocal Rank (MRR), GPT-4, Agents, OpenGPTs, Zero-shot ReAct, Conversational Agent, OpenAI Assistants API, Hugging Face Inference API, Code Interpreter, Knowledge Retrieval, Function Calling, Whisper, Dall-E 3, GPT-4 Vision, Unstructured, Deep Lake, FaithfulnessEvaluator, RAGAS, LangSmith, LangChain Hub, LangServe, REST API, respond 'true'. If a question is on a different subject or unrelated, respond 'false'.
59
+ - Make sure the question is a valid question.
60
+
61
+ Here is a list of acronyms and concepts related to Artificial Intelligence AI that are valid. The following terms can be Uppercase or Lowercase:
62
+ You are case insensitive.
63
+ 'TQL', 'Deep Memory', 'LLM', 'Llama', 'llamaindex', 'llama-index', 'lang chain', 'langchain', 'llama index', 'GPT', 'NLP', 'RLHF', 'RLAIF', 'Mistral', 'SFT', 'Cohere', 'NanoGPT', 'ReAct', 'LoRA', 'QLoRA', 'LMMOps', 'Alpaca', 'Flan', 'Weights and Biases', 'W&B', 'IDEFICS', 'Flamingo', 'LLaVA', 'BLIP', 'Falcon', 'Gemini'
64
+
65
  """
66
 
67
 
68
  class QueryValidation(BaseModel):
69
  """
70
+ Validate the user query. Use the guidelines given to you.
71
  """
72
 
73
+ user_query: str = Field(
74
+ description="The user query to validate.",
75
+ )
76
  chain_of_thought: str = Field(
77
+ description="Is the user query valid given the above guidelines? Think step-by-step. Write down your reasoning here.",
78
  )
79
  is_valid: bool = Field(
80
  description="Based on the previous reasoning, answer with True if the query is related to AI. Answer False otherwise.",