mirror of
https://github.com/kennethreitz/instructor.git
synced 2026-06-05 22:50:18 +00:00
Include types to most upstream modules (#391)
This commit is contained in:
@@ -9,7 +9,12 @@ env:
|
||||
WORKING_DIRECTORY: "."
|
||||
MYPY_OUTPUT_FILENAME: "mypy.log"
|
||||
CUSTOM_FLAGS: "--python-version=3.9 --color-output --no-pretty --follow-imports=skip"
|
||||
CUSTOM_PACKAGES: "instructor/cli/cli.py instructor/cli/usage.py"
|
||||
CUSTOM_PACKAGES: |
|
||||
instructor/_types/_alias.py
|
||||
instructor/cli/cli.py
|
||||
instructor/cli/files.py
|
||||
instructor/cli/usage.py
|
||||
instructor/exceptions.py
|
||||
|
||||
jobs:
|
||||
MyPy:
|
||||
|
||||
+12
-10
@@ -51,12 +51,12 @@ def get_file_status(file_id: str) -> str:
|
||||
|
||||
@app.command(
|
||||
help="Upload a file to OpenAI's servers, will monitor the upload status until it is processed",
|
||||
)
|
||||
) # type: ignore[misc]
|
||||
def upload(
|
||||
filepath: str = typer.Argument(..., help="Path to the file to upload"),
|
||||
purpose: str = typer.Option("fine-tune", help="Purpose of the file"),
|
||||
poll: int = typer.Option(5, help="Polling interval in seconds"),
|
||||
):
|
||||
) -> None:
|
||||
with open(filepath, "rb") as file:
|
||||
response = client.files.create(file=file, purpose=purpose)
|
||||
file_id = response["id"]
|
||||
@@ -72,11 +72,11 @@ def upload(
|
||||
|
||||
@app.command(
|
||||
help="Download a file from OpenAI's servers",
|
||||
)
|
||||
) # type: ignore[misc]
|
||||
def download(
|
||||
file_id: str = typer.Argument(..., help="ID of the file to download"),
|
||||
output: str = typer.Argument(..., help="Output path for the downloaded file"),
|
||||
):
|
||||
) -> None:
|
||||
with console.status(f"[bold green]Downloading file {file_id}...", spinner="dots"):
|
||||
content = client.files.download(file_id)
|
||||
with open(output, "wb") as file:
|
||||
@@ -86,8 +86,8 @@ def download(
|
||||
|
||||
@app.command(
|
||||
help="Delete a file from OpenAI's servers",
|
||||
)
|
||||
def delete(file_id: str = typer.Argument(..., help="ID of the file to delete")):
|
||||
) # type: ignore[misc]
|
||||
def delete(file_id: str = typer.Argument(..., help="ID of the file to delete")) -> None:
|
||||
with console.status(f"[bold red]Deleting file {file_id}...", spinner="dots"):
|
||||
try:
|
||||
client.files.delete(file_id)
|
||||
@@ -99,10 +99,10 @@ def delete(file_id: str = typer.Argument(..., help="ID of the file to delete")):
|
||||
|
||||
@app.command(
|
||||
help="Monitor the status of a file on OpenAI's servers",
|
||||
)
|
||||
) # type: ignore[misc]
|
||||
def status(
|
||||
file_id: str = typer.Argument(..., help="ID of the file to check the status of"),
|
||||
):
|
||||
) -> None:
|
||||
with console.status(f"Monitoring status of file {file_id}...") as status:
|
||||
while True:
|
||||
file_status = get_file_status(file_id)
|
||||
@@ -114,7 +114,9 @@ def status(
|
||||
|
||||
@app.command(
|
||||
help="List the files on OpenAI's servers",
|
||||
)
|
||||
def list(limit: int = typer.Option(5, help="Limit the number of files to list")):
|
||||
) # type: ignore[misc]
|
||||
def list(
|
||||
limit: int = typer.Option(5, help="Limit the number of files to list"),
|
||||
) -> None:
|
||||
files = get_files(limit=limit)
|
||||
console.log(generate_file_table(files))
|
||||
|
||||
@@ -146,7 +146,7 @@ def group_and_sum_by_date_and_snapshot(usage_data: List[Dict[str, Any]]) -> Tabl
|
||||
return table
|
||||
|
||||
|
||||
@app.command(help="Displays OpenAI API usage data for the past N days.") # type: ignore
|
||||
@app.command(help="Displays OpenAI API usage data for the past N days.") # type: ignore[misc]
|
||||
def list(
|
||||
n: int = typer.Option(0, help="Number of days."),
|
||||
) -> None:
|
||||
|
||||
@@ -2,7 +2,8 @@ class IncompleteOutputException(Exception):
|
||||
"""Exception raised when the output from LLM is incomplete due to max tokens limit reached."""
|
||||
|
||||
def __init__(
|
||||
self, message="The output is incomplete due to a max_tokens length limit."
|
||||
):
|
||||
self,
|
||||
message: str = "The output is incomplete due to a max_tokens length limit.",
|
||||
) -> None:
|
||||
self.message = message
|
||||
super().__init__(self.message)
|
||||
|
||||
Reference in New Issue
Block a user