added product training
Browse files- agent/prompt.py +7 -9
- app.py +5 -1
- train/posts.csv +0 -0
- train/products.py +20 -0
agent/prompt.py
CHANGED
@@ -3,20 +3,18 @@ from agent.datastructures import parser
|
|
3 |
|
4 |
prompt = PromptTemplate.from_template("""
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
|
10 |
-
You
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
Our students are diverse, and many come from non-traditional backgrounds and minority ethnic groups. Some may have ambitions for particular careers, others may not - and many may not be confident or have the social and financial advantages to reach their goals. If a student has a sense of what they want to achieve, you should help them to create smart targets. If they don't, you should be reassuring that its ok not to have clear goals yet, but help them to reflect and form some ambitions. These could be career-oriented, or they could be about succeeding in, and making the most of, their university experience.
|
15 |
|
16 |
TOOLS:
|
17 |
------
|
18 |
|
19 |
-
|
20 |
|
21 |
{tools}
|
22 |
|
|
|
3 |
|
4 |
prompt = PromptTemplate.from_template("""
|
5 |
|
6 |
+
|
7 |
+
You are RiseBot.
|
8 |
+
You work for Manchester Metropolitan University's Future Me and Rise offers: supporting students to make the most of the opportunities available to them.
|
9 |
|
10 |
+
You are able to answer questions that students have.
|
11 |
+
Please only answer questions about Future me and Rise using the tool provided.
|
12 |
+
If you are unable to answer the question, do not make something up - admit it and recommend that they contact rise@mmu.ac.uk
|
|
|
|
|
13 |
|
14 |
TOOLS:
|
15 |
------
|
16 |
|
17 |
+
RiseBot has access to the following tools:
|
18 |
|
19 |
{tools}
|
20 |
|
app.py
CHANGED
@@ -20,4 +20,8 @@ def index():
|
|
20 |
def train_faq():
|
21 |
from train.faq import train
|
22 |
return train();
|
23 |
-
|
|
|
|
|
|
|
|
|
|
20 |
def train_faq():
|
21 |
from train.faq import train
|
22 |
return train();
|
23 |
+
|
24 |
+
@app.route("/train/products", methods=['GET','POST'])
|
25 |
+
def train_products():
|
26 |
+
from train.products import train
|
27 |
+
return train();
|
train/posts.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
train/products.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
def train():
|
2 |
+
|
3 |
+
from langchain_community.document_loaders.csv_loader import CSVLoader
|
4 |
+
from langchain.text_splitter import CharacterTextSplitter
|
5 |
+
from langchain_openai import OpenAIEmbeddings
|
6 |
+
from langchain_community.vectorstores.faiss import FAISS
|
7 |
+
|
8 |
+
documents = CSVLoader(file_path="train/posts.csv").load()
|
9 |
+
|
10 |
+
# Split document in chunks
|
11 |
+
text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=30)
|
12 |
+
docs = text_splitter.split_documents(documents=documents)
|
13 |
+
|
14 |
+
embeddings = OpenAIEmbeddings()
|
15 |
+
# Create vectors
|
16 |
+
vectorstore = FAISS.from_documents(docs, embeddings)
|
17 |
+
# Persist the vectors locally on disk
|
18 |
+
vectorstore.save_local("_rise_product_db");
|
19 |
+
|
20 |
+
return {"trained":"success"}
|