File size: 3,339 Bytes
6158da4
 
 
 
 
 
 
 
e27870a
6d056d5
d95aad5
6158da4
6d056d5
6158da4
 
 
a052bdc
638bffe
 
 
e27870a
6158da4
a052bdc
 
6158da4
a052bdc
 
 
6158da4
a052bdc
638bffe
 
 
6158da4
e27870a
6158da4
 
 
 
 
 
 
 
 
b83cc65
a052bdc
 
e27870a
a052bdc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b83cc65
e27870a
b83cc65
a052bdc
 
b83cc65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a052bdc
b83cc65
 
f2daaee
b83cc65
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
from dotenv import load_dotenv
import os

load_dotenv()

# API Keys - Loaded from the .env file

OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
LLAMA_CLOUD_API_KEY = os.getenv("LLAMA_CLOUD_API_KEY")
HUGGINGFACE_TOKEN = os.getenv("HUGGINGFACE_TOKEN")
LITERAL_API_KEY = os.getenv("LITERAL_API_KEY")

opening_message = f"Hey, What Can I Help You With?\n\nYou can me ask me questions about the course logistics, course content, about the final project, or anything else!"

# Prompt Templates

openai_prompt_template = """Use the following pieces of information to answer the user's question.
You are an intelligent chatbot designed to help students with questions regarding the course. 
Render math equations in LaTeX format between $ or $$ signs, stick to the parameter and variable icons found in your context. 
Be sure to explain the parameters and variables in the equations.
If you don't know the answer, just say that you don't know. 

Context: {context}
Question: {question}

Only return the helpful answer below and nothing else.
Helpful answer:
"""

openai_prompt_template_with_history = """Use the following pieces of information to answer the user's question.
You are an intelligent chatbot designed to help students with questions regarding the course. 
Render math equations in LaTeX format between $ or $$ signs, stick to the parameter and variable icons found in your context. 
Be sure to explain the parameters and variables in the equations.
If you don't know the answer, just say that you don't know, don't try to make up an answer.

Use the history to answer the question if you can.
Chat History:
{chat_history}
Context: {context}
Question: {question}

Only return the helpful answer below and nothing else.
Helpful answer:
"""

tinyllama_prompt_template = """
<|im_start|>system
Assistant is an intelligent chatbot designed to help students with questions regarding the course. Only answer questions using the context below and if you're not sure of an answer, you can say "I don't know". Always give a brief and concise answer to the question. When asked for formulas, give a brief description of the formula and output math equations in LaTeX format between $ signs.

Context:
{context}
<|im_end|>
<|im_start|>user
Question: Who is the instructor for this course?
<|im_end|>
<|im_start|>assistant
The instructor for this course is Prof. Thomas Gardos.
<|im_end|>
<|im_start|>user
Question: {question}
<|im_end|>
<|im_start|>assistant
"""

tinyllama_prompt_template_with_history = """
<|im_start|>system
Assistant is an intelligent chatbot designed to help students with questions regarding the course. Only answer questions using the context below and if you're not sure of an answer, you can say "I don't know". Always give a brief and concise answer to the question. Output math equations in LaTeX format between $ signs. Use the history to answer the question if you can.

Chat History:
{chat_history}
Context:
{context}
<|im_end|>
<|im_start|>user
Question: Who is the instructor for this course?
<|im_end|>
<|im_start|>assistant
The instructor for this course is Prof. Thomas Gardos.
<|im_end|>
<|im_start|>user
Question: {question}
<|im_end|>
<|im_start|>assistant
"""


# Model Paths

LLAMA_PATH = "../storage/models/tinyllama-1.1b-chat-v1.0.Q5_K_M.gguf"
MISTRAL_PATH = "storage/models/mistral-7b-v0.1.Q4_K_M.gguf"