Skip to content

Commit adb5336

Browse files
authored
Feature/export prompts (#137)
* Remove .env from tracking and add it to .gitignore Signed-off-by: Gianluca Capuzzi <gianluca.posta78@gmail.com> * Export prompts on files Signed-off-by: Gianluca Capuzzi <gianluca.posta78@gmail.com> --------- Signed-off-by: Gianluca Capuzzi <gianluca.posta78@gmail.com>
1 parent dbe38e6 commit adb5336

File tree

8 files changed

+16
-28
lines changed

8 files changed

+16
-28
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,6 @@ logs/
7979
# Documentation build
8080
_build/
8181
_static/
82-
_templates/
82+
_templates/
83+
84+
config.yaml

src/mvt/config.yaml

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/mvt/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import os
2-
from utils import load_yaml_file_with_db_prompts
2+
from utils import load_yaml_file_with_db_prompts, get_system_prompt
33
from dotenv import load_dotenv, find_dotenv
44
from langchain_mistralai.chat_models import ChatMistralAI
55
from langchain_community.vectorstores import FAISS
@@ -60,7 +60,7 @@ def get_ragchain(filter):
6060
retriever = docsearch.as_retriever(search_kwargs={"k": config_data["nr_retrieved_documents"], "filter": filter})
6161

6262
# read prompt string from config file
63-
prompt_str = config_data["system_prompt"]
63+
prompt_str = get_system_prompt(config_data["system_prompt"])
6464

6565
# Answer question
6666
qa_system_prompt = (

src/mvt/query_rewriting.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,14 @@ def query_rewriting_llm(user_query, context="Founder Institute Keystone Chapter"
3838
temperature=0.7
3939
)
4040

41-
query_rewriting_prompt = config_data["query_rewriting_prompt"]
41+
# Read query rewriting prompt from config
42+
with open(config_data["query_rewriting_prompt"], "r") as f:
43+
query_rewriting_prompt = f.read().strip()
4244

4345
messages = [
4446
("system", query_rewriting_prompt),
4547
("human", user_query),
4648
]
4749

48-
print(messages)
49-
5050
response = model.invoke(messages)
51-
print(response.content)
5251
return response.content

src/mvt/query_rewriting_prompt.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
You are an assistant helping to rewrite user queries to make them more specific and effective for searching documents. The context is the Founder Institute Keystone Chapter which includes information about programs, fees, mentors, and startup guidance. Please rewrite the human query to be more specific, detailed, and optimized for document retrieval, considering the context mentioned

src/mvt/responses.txt

Lines changed: 2 additions & 0 deletions
Large diffs are not rendered by default.

src/mvt/system_prompt.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
You are an assistant designed to help answer questions about startup founders from the Founder Institute (FI) Keystone Chapter. The Keystone Chapter is part of the global network of the Founder Institute, the world's largest pre-seed startup accelerator. It supports entrepreneurs across the Delaware Valley, Philadelphia, and Princeton areas, with a mission to help them build meaningful and lasting technology companies. Use any relevant information from the retrieved context to answer questions as accurately and helpfully as possible. If the answer is not found in the provided context, simply say you don't know. Avoid vague phrases like 'based on the provided context' in your responses, and aim to be as detailed and informative as possible. If the question is ambiguous, assume the user is referring to the Founder Institute Keystone Chapter's core startup accelerator program, unless the question clearly states otherwise. If the question is not related to the Founder Institute or its programs, politely decline to answer

src/mvt/utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ def load_yaml_file_with_db_prompts(path):
4141

4242
return data
4343

44+
# This function returns the system prompt from the file specified in the config.
45+
def get_system_prompt(prompt_file: str):
46+
with open(prompt_file, "r") as f:
47+
return f.read().strip()
4448

4549
# This function extracts text from HTML while preserving context relationships.
4650
def bs4_html(html):

0 commit comments

Comments
 (0)