-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Mirascope/sdk-commands
added pull command
- Loading branch information
Showing
6 changed files
with
117 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"""Pulling a prompt from the server.""" | ||
|
||
from openai import OpenAI | ||
|
||
import lilypad | ||
|
||
client = OpenAI() | ||
|
||
|
||
def recommend_book(genre: str) -> str | None: | ||
"""Recommends a `genre` book using OpenAI""" | ||
prompt = lilypad.prompt(recommend_book)(genre) | ||
completion = client.chat.completions.create( | ||
model="gpt-4o-mini", | ||
messages=lilypad.openai.messages(prompt), | ||
) | ||
message = completion.choices[0].message | ||
return message.content | ||
|
||
|
||
print(recommend_book("fantasy")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
{% for prompt_version in prompt_versions %} | ||
<li> | ||
<a href="{{prompt_version.id}}" hx-push-url="true">{{ prompt_version.id}}</a> | ||
<a | ||
href="/projects/{{project.name}}/versions/{{prompt_version.id}}" | ||
hx-push-url="true" | ||
>{{ prompt_version.id}}</a | ||
> | ||
</li> | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
"""Lilypad commands.""" | ||
|
||
import requests | ||
|
||
from lilypad.app.models import PromptVersionTable | ||
|
||
|
||
def pull(project_name: str) -> str: | ||
"""Pull the latest prompt version.""" | ||
url = f"http://localhost:8000/projects/{project_name}/versions" | ||
response = requests.get(url) | ||
return PromptVersionTable(**response.json()).prompt_template |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.