Skip to content

Commit

Permalink
Merge pull request #5 from Mirascope/fix-models
Browse files Browse the repository at this point in the history
fix model ids
  • Loading branch information
Brendan Kao authored Sep 9, 2024
2 parents 0b3df08 + f04a886 commit 80536b9
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions examples/sqlite_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@


@lilypad.trace
def recommend_book(genre: str) -> str | None:
def recommend_book(genre: str, topic: str) -> str | None:
"""Recommends a `genre` book using OpenAI"""
prompt = lilypad.prompt(recommend_book)(genre)
prompt = lilypad.prompt(recommend_book)(genre, topic)
completion = client.chat.completions.create(
model="gpt-4o-mini",
messages=lilypad.openai.messages(prompt),
Expand All @@ -19,4 +19,4 @@ def recommend_book(genre: str) -> str | None:
return message.content


print(recommend_book("fantasy"))
print(recommend_book("fantasy", "dragons"))
4 changes: 2 additions & 2 deletions lilypad/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ async def create_version(
select(ProjectTable).where(ProjectTable.name == project_name)
).first()

if not project:
if not project or not project.id:
raise HTTPException(status_code=404)

latest_prompt_version = session.exec(
Expand Down Expand Up @@ -190,7 +190,7 @@ async def create_calls(
project.prompt_versions, key=lambda x: x.id or 0, reverse=True
)[:1][0]

if not prompt_version:
if not prompt_version or not prompt_version.id:
raise HTTPException(status_code=404)

call = CallTable(
Expand Down
2 changes: 1 addition & 1 deletion lilypad/app/models/calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class CallTable(BaseSQLModel, table=True):

__tablename__ = CALL_TABLE_NAME # type: ignore

id: int = Field(default=None, primary_key=True)
id: int | None = Field(default=None, primary_key=True)
prompt_version_id: int = Field(
default=None, foreign_key=f"{PROMPT_VERSION_TABLE_NAME}.id"
)
Expand Down
2 changes: 1 addition & 1 deletion lilypad/app/models/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ProjectTable(BaseSQLModel, table=True):

__tablename__ = PROJECT_TABLE_NAME # type: ignore

id: int = Field(default=None, primary_key=True)
id: int | None = Field(default=None, primary_key=True)
name: str = Field(nullable=False, unique=True)
created_at: datetime.datetime = Field(
default=datetime.datetime.now(datetime.UTC), nullable=False
Expand Down
2 changes: 1 addition & 1 deletion lilypad/app/models/prompt_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class PromptVersionTable(BaseSQLModel, table=True):

__tablename__ = PROMPT_VERSION_TABLE_NAME # type: ignore

id: int = Field(default=None, primary_key=True)
id: int | None = Field(default=None, primary_key=True)
project_id: int = Field(default=None, foreign_key=f"{PROJECT_TABLE_NAME}.id")
prompt_template: str = Field(nullable=False)
created_at: datetime.datetime = Field(
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

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

0 comments on commit 80536b9

Please sign in to comment.