Skip to content

Commit

Permalink
insure correct pdf retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
= Enea_Gore committed Dec 2, 2024
1 parent 184f9ae commit d278008
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self, session_id="test-session"):
self.model = ChatOpenAI(model="gpt-4o-mini") #gpt-4o-2024-08-06 , gpt-4o-mini
self.memory = InMemoryChatMessageHistory(session_id=session_id)
all_docs = []
file_paths = glob.glob("pdfs/*.pdf")
file_paths = glob.glob("module_text_llm/retrieval_augmented_generation/pdfs/*.pdf")

for file_path in file_paths:
loader = PyPDFLoader(file_path)
Expand All @@ -56,18 +56,43 @@ def __init__(self, session_id="test-session"):

retriever = vectorstore.as_retriever()
retriever_tool = create_retriever_tool(retriever, name="retrieve_document", description="Retrieves the pdf documents from the relevant lecture")
system_message = """\
You are an AI tutor for text assessment at a prestigious university.
# Task
Create graded feedback suggestions for a student\'s text submission that a human tutor would accept. \
Meaning, the feedback you provide should be applicable to the submission with little to no modification.
You have access to the provided document lecture slides to help you provide feedback. If you do use them, please reference the title and the page on your feedback.
# Style
1. Constructive, 2. Specific, 3. Balanced, 4. Clear and Concise, 5. Actionable, 6. Educational, 7. Contextual
Make use of the lecture slides provided. State clearly on your feedback which lecture you are using.
# Problem statement
{problem_statement}
# Example solution
{example_solution}
# Grading instructions
{grading_instructions}
Max points: {max_points}, bonus points: {bonus_points}\
Respond only in json with the provided Assessment Feedback schema.
"""
# Define the prompt template with a system message placeholder
self.prompt = ChatPromptTemplate.from_messages(
[
("system", """ You are an AI tutor for text assessment at a prestigious university.
# Task
Create graded feedback suggestions for a student\'s text submission that a human tutor would accept. \
Meaning, the feedback you provide should be applicable to the submission with little to no modification.
You have access to the provided document lecture slides to help you provide feedback. If you do use them, please reference the title and the page on your feedback.
ALWAYS RESPONG IN A PYDNATIC OBJECT WITH THE PROVIDED ASSESSMENT MODEL SCHEMA.
problem satement: {problem_statement}, max points: {max_points}"""),
("system", system_message),
# ("system", """ You are an AI tutor for text assessment at a prestigious university.

# # Task
# Create graded feedback suggestions for a student\'s text submission that a human tutor would accept. \
# Meaning, the feedback you provide should be applicable to the submission with little to no modification.
# You have access to the provided document lecture slides to help you provide feedback. If you do use them, please reference the title and the page on your feedback.
# ALWAYS RESPONG IN A PYDNATIC OBJECT WITH THE PROVIDED ASSESSMENT MODEL SCHEMA.
# problem satement: {problem_statement}, max points: {max_points}"""),
# ("placeholder", "{chat_history}"), # History of interactions
("human", "{submission}"),
("placeholder", "{agent_scratchpad}"), # Internal for steps created through function calling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
# Style
1. Constructive, 2. Specific, 3. Balanced, 4. Clear and Concise, 5. Actionable, 6. Educational, 7. Contextual
Make use of the lecture slides provided. State clearly on your feedback which lecture you are using. If you
believe that the student could benefit from the slide refer it on your feedback.
The grading instructions are there to guide you on which criteria to give points.
You can comment with 0 points about grammar and spelling errors, but you should not give or remove points for them.
# Problem statement
{problem_statement}
Expand Down
21 changes: 20 additions & 1 deletion modules/text/module_text_llm/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions modules/text/module_text_llm/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ gitpython = "3.1.41"
nltk = "3.8.1"
python-dotenv = "1.0.0"
tiktoken = "0.7.0"
pypdf = "5.1.0"

[tool.poetry.dev-dependencies]
pydantic = "1.10.17"
Expand Down

0 comments on commit d278008

Please sign in to comment.