Skip to content

Commit

Permalink
Shared llm package refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
= Enea_Gore committed Sep 2, 2024
1 parent ccf0330 commit 153fe73
Show file tree
Hide file tree
Showing 55 changed files with 5,362 additions and 2,728 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class HealthResponse(BaseModel):
and whether all the modules are healthy (i.e. reachable).
Additional information about the modules is also provided.
"""
status: str = Field(const=True, default="ok", example="ok")
status: str = Field(Literal=True, default="ok", example="ok")
modules: dict = Field(
example=[
{
Expand Down
3 changes: 2 additions & 1 deletion athena-workspace.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
],
"settings": {
"python.linting.prospectorEnabled": true,
"python.linting.mypyEnabled": true
"python.linting.mypyEnabled": true,
"liveServer.settings.multiRootWorkspaceName": "Athena"
}
}
1 change: 1 addition & 0 deletions athena/athena/schemas/exercise.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ class Exercise(Schema, ABC):
meta: dict = Field({}, example={"internal_id": "5"})

class Config:
from_attributes=True
orm_mode = True
1 change: 1 addition & 0 deletions athena/athena/schemas/feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ 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:
from_attributes=True
orm_mode = 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.")
10 changes: 5 additions & 5 deletions athena/athena/schemas/programming_exercise.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pydantic import Field, AnyUrl
from pydantic import Field, HttpUrl
from zipfile import ZipFile
from git.repo import Repo

Expand All @@ -10,16 +10,16 @@
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 "
solution_repository_uri: str = Field(description="URL to the solution git repository, which contains the "
"reference solution.",
example="http://localhost:3000/api/example-solutions/1")
template_repository_uri: AnyUrl = Field(description="URL to the template git repository, which is the starting "
template_repository_uri: str = Field(description="URL to the template git repository, which is the starting "
"point for students.",
example="http://localhost:3000/api/example-template/1")
tests_repository_uri: AnyUrl = Field(description="URL to the tests git repository, which contains the tests that "
tests_repository_uri: str = Field(description="URL to the tests git repository, which contains the tests that "
"are used to automatically grade the exercise.",
example="http://localhost:3000/api/example-tests/1")

Expand Down
7 changes: 3 additions & 4 deletions athena/athena/schemas/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@

# https://stackoverflow.com/a/42450252/4306257
def to_camel(snake_str):
first, *others = snake_str.split('_')
return ''.join([first.lower(), *map(str.title, others)])

first, *others = snake_str.split('_')
return ''.join([first.lower(), *map(str.title, others)])

class Schema(BaseModel, abc.ABC):
@classmethod
Expand All @@ -32,4 +31,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
1 change: 1 addition & 0 deletions athena/athena/schemas/submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ class Submission(Schema, ABC):
meta: dict = Field({}, example={})

class Config:
from_attributes=True
orm_mode = 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.")
2 changes: 1 addition & 1 deletion module_modeling_llm/module_modeling_llm/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pydantic import BaseModel, Field

from athena import config_schema_provider
from module_modeling_llm.helpers.models import ModelConfigType, DefaultModelConfig
from shared_llm.helpers.models import ModelConfigType, DefaultModelConfig
from module_modeling_llm.prompts.generate_suggestions import (
system_message as generate_suggestions_system_message,
human_message as generate_suggestions_human_message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
from athena.logger import logger
from athena.modeling import Exercise, Submission, Feedback
from module_modeling_llm.config import BasicApproachConfig
from module_modeling_llm.helpers.llm_utils import (
from shared_llm.helpers.llm_utils import (
get_chat_prompt_with_formatting_instructions,
check_prompt_length_and_omit_features_if_necessary,
num_tokens_from_prompt,
predict_and_parse
)
from module_modeling_llm.helpers.models.diagram_types import DiagramType
from module_modeling_llm.helpers.serializers.diagram_model_serializer import DiagramModelSerializer
from module_modeling_llm.helpers.utils import format_grading_instructions, get_elements
from shared_llm.helpers.models.diagram_types import DiagramType
from shared_llm.helpers.serializers.diagram_model_serializer import DiagramModelSerializer
from shared_llm.helpers.modeling_utils import format_grading_instructions, get_elements
from module_modeling_llm.prompts.submission_format.submission_format_remarks import get_submission_format_remarks


Expand Down
163 changes: 0 additions & 163 deletions module_modeling_llm/module_modeling_llm/helpers/llm_utils.py

This file was deleted.

40 changes: 0 additions & 40 deletions module_modeling_llm/module_modeling_llm/helpers/models/__init__.py

This file was deleted.

This file was deleted.

Loading

0 comments on commit 153fe73

Please sign in to comment.