Skip to content

Commit

Permalink
upgrade langchain to 0.3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
dmytropolityka committed Oct 4, 2024
1 parent 701ddeb commit 12a8ce6
Show file tree
Hide file tree
Showing 25 changed files with 1,082 additions and 766 deletions.
297 changes: 159 additions & 138 deletions assessment_module_manager/poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assessment_module_manager/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license = "MIT"

[tool.poetry.dependencies]
python = "3.11.*"
athena = {path = "../athena", develop = true}
athena = { git = "https://github.com/ls1intum/Athena.git", rev = "9773c41", subdirectory = "athena"}
fastapi = "^0.109.1"
uvicorn = "^0.23.0"
httpx = "^0.24.1"
Expand Down
2 changes: 1 addition & 1 deletion athena/athena/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class SubmissionSelectorRequest(BaseModel):
class Config:
# Allow camelCase field names in the API (converted to snake_case)
alias_generator = to_camel
allow_population_by_field_name = True
populate_by_name = True

@app.post("/select_submission", responses=module_responses)
@authenticated
Expand Down
6 changes: 3 additions & 3 deletions athena/athena/helpers/programming/code_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def get_repository_zip(url: str, authorization_secret: Optional[str] = None) ->
the cache or by downloading it, and return a ZipFile object.
Optional: Authorization secret for the API. If omitted, it will be auto-determined given the request session.
"""
url_hash = hashlib.md5(url.encode("utf-8")).hexdigest()
url_hash = hashlib.md5(str(url).encode("utf-8")).hexdigest()
file_name = url_hash + ".zip"
cache_file_path = cache_dir / file_name

Expand All @@ -27,7 +27,7 @@ def get_repository_zip(url: str, authorization_secret: Optional[str] = None) ->
if contextvars.repository_authorization_secret_context_var_empty():
raise ValueError("Authorization secret for the repository API is not set. Pass authorization_secret to this function or add the X-Repository-Authorization-Secret header to the request from the assessment module manager.")
authorization_secret = contextvars.get_repository_authorization_secret_context_var()
with httpx.stream("GET", url, headers={ "Authorization": cast(str, authorization_secret) }) as response:
with httpx.stream("GET", str(url), headers={ "Authorization": cast(str, authorization_secret) }) as response:
response.raise_for_status()
with open(cache_file_path, "wb") as f:
for chunk in response.iter_bytes():
Expand All @@ -42,7 +42,7 @@ def get_repository(url: str, authorization_secret: Optional[str] = None) -> Repo
downloading it, and return a Repo object.
"""

url_hash = hashlib.md5(url.encode("utf-8")).hexdigest()
url_hash = hashlib.md5(str(url).encode("utf-8")).hexdigest()
dir_name = url_hash + ".git"
cache_dir_path = cache_dir / dir_name

Expand Down
2 changes: 1 addition & 1 deletion athena/athena/schemas/exercise.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ class Exercise(Schema, ABC):
meta: dict = Field({}, example={"internal_id": "5"})

class Config:
orm_mode = True
from_attributes = True
2 changes: 1 addition & 1 deletion athena/athena/schemas/feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ def to_model(self, is_suggestion: bool = False, lms_id: Optional[int] = None, lm
return type(self).get_model_class()(**self.dict(), is_suggestion=is_suggestion, lms_id=lms_id, lms_url=lms_url)

class Config:
orm_mode = True
from_attributes = True
2 changes: 1 addition & 1 deletion athena/athena/schemas/modeling_exercise.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
class ModelingExercise(Exercise):
"""A modeling exercise that can be solved by students, enhanced with metadata."""

type: ExerciseType = Field(ExerciseType.modeling, const=True)
type: ExerciseType = Field(ExerciseType.modeling, Literal=True)

example_solution: Optional[str] = Field(None, description="An example solution to the exercise.")
11 changes: 9 additions & 2 deletions athena/athena/schemas/programming_exercise.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class ProgrammingExercise(Exercise):
"""A programming exercise that can be solved by students, enhanced with metadata."""

type: ExerciseType = Field(ExerciseType.programming, const=True)
type: ExerciseType = Field(ExerciseType.programming, Literal=True)

programming_language: str = Field(description="The programming language that is used for this exercise.", example="java")
solution_repository_uri: AnyUrl = Field(description="URL to the solution git repository, which contains the "
Expand Down Expand Up @@ -51,4 +51,11 @@ def get_tests_zip(self) -> ZipFile:

def get_tests_repository(self) -> Repo:
"""Return the tests repository as a Repo object."""
return get_repository(self.tests_repository_uri)
return get_repository(self.tests_repository_uri)

def to_model(self):
model = super().to_model()
model.solution_repository_uri = str(self.solution_repository_uri)
model.template_repository_uri = str(self.template_repository_uri)
model.tests_repository_uri = str(self.tests_repository_uri)
return model
2 changes: 1 addition & 1 deletion athena/athena/schemas/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ def to_model(self):
class Config:
# Allow camelCase field names in the API (converted to snake_case)
alias_generator = to_camel
allow_population_by_field_name = True
populate_by_name = True
2 changes: 1 addition & 1 deletion athena/athena/schemas/submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ class Submission(Schema, ABC):
meta: dict = Field({}, example={})

class Config:
orm_mode = True
from_attributes = True
2 changes: 1 addition & 1 deletion athena/athena/schemas/text_exercise.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
class TextExercise(Exercise):
"""A text exercise that can be solved by students, enhanced with metadata."""

type: ExerciseType = Field(ExerciseType.text, const=True)
type: ExerciseType = Field(ExerciseType.text, Literal=True)

example_solution: Optional[str] = Field(None, description="An example solution to the exercise.")
Loading

0 comments on commit 12a8ce6

Please sign in to comment.