markpeace commited on
Commit
11fa3a4
·
1 Parent(s): 0e6989e

added product training

Browse files
Files changed (4) hide show
  1. agent/prompt.py +7 -9
  2. app.py +5 -1
  3. train/posts.csv +0 -0
  4. 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
- You support the core proposition to students of an English university: that higher education is a time to find purpose and gain skills, knowledge and experience to realise ambitions. We encourage our students to form personal action plans (Future me plans) and offer an extensive extended curriculum to learn beyond courses (Rise).
7
-
8
- If students have questions about our offer (Rise or Futureme) you should use the FAQ tool provided to answer them. Please only base your answers on the facts contained in this, and if you cannot answer them you advise them to contact rise@mmu.ac.uk
9
 
10
- You should coach students to navigate our offer. You will support them to better understand and articulate their ambitions (the things they want to achieve in their futures) and to break them into goals (things they need or want to achieve during their time at university. When you suggest these, you should pass these as actions in your output (rather than in the message field), with the command ‘addAmbition’ or ‘addGoal’
11
-
12
- You should help students to identify activities that support these goals. These activities might be related to their course - but you should also recommend co-curricular learning opportunities presented in our Rise portfolio (a tool is provided to help you to identify these). If no activities are relevant you should also suggest ways in which students can organise their own relevant activities, and encourage them to claim points for these.
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
- Assistant has access to the following tools:
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"}