Cut Text/Sol/Persp into smaller parts, and use them
This commit is contained in:
+20
-13
@@ -117,7 +117,8 @@ list \"feedback\", and possibly an \"error\". Like this example :
|
||||
}
|
||||
]
|
||||
|
||||
Here is the text of the exercice of the exam :
|
||||
Here is the text of the exercice (or the relevant part of the problem)
|
||||
of the exam :
|
||||
|
||||
```
|
||||
<<text>>
|
||||
@@ -127,25 +128,31 @@ Here is a possible correct answer :
|
||||
|
||||
```
|
||||
<<corr>>
|
||||
```
|
||||
|
||||
Here is some additional scoring instructions :
|
||||
|
||||
```
|
||||
<<persp>>
|
||||
```
|
||||
|
||||
You are asked to score the question or exercice labeled `<<label>>`,
|
||||
do not score or give feedback to any other question."""
|
||||
|
||||
def make_prompt(full_label):
|
||||
l = full_label.split(" ")
|
||||
ex_label = l[0] + " " + l[1]
|
||||
text = (Path(INPUT_DIR) / "Text" / ex_label).read_text()
|
||||
corr = (Path(INPUT_DIR) / "Sol" / ex_label).read_text()
|
||||
persp = (Path(INPUT_DIR) / "Persp" / ex_label).read_text()
|
||||
if persp == "":
|
||||
perps = "There is no additional scoring instructions."
|
||||
# l = full_label.split(" ")
|
||||
# ex_label = l[0] + " " + l[1]
|
||||
# text = (Path(INPUT_DIR) / "Text" / ex_label).read_text()
|
||||
# corr = (Path(INPUT_DIR) / "Sol" / ex_label).read_text()
|
||||
# persp = (Path(INPUT_DIR) / "Persp" / ex_label).read_text()
|
||||
def read_longest_prefix_file(subdir):
|
||||
dir_path = Path(INPUT_DIR) / subdir
|
||||
matches = [f for f in dir_path.iterdir() if f.is_file() and full_label.startswith(f.name)]
|
||||
if not matches:
|
||||
return ""
|
||||
return max(matches, key=lambda f: len(f.name)).read_text()
|
||||
|
||||
text = read_longest_prefix_file("Text")
|
||||
corr = read_longest_prefix_file("Sol")
|
||||
persp = read_longest_prefix_file("Persp")
|
||||
|
||||
if persp != "":
|
||||
persp = "\n\nHere are additional scoring instructions : \n\n```\n" + persp +"\n```\n"
|
||||
return my_prompt.replace("<<text>>", text).replace("<<corr>>", corr).replace("<<persp>>", persp).replace("<<label>>", full_label)
|
||||
|
||||
from google import genai
|
||||
|
||||
Reference in New Issue
Block a user