Skip to content

Commit

Permalink
修改视频提示词可选 (#50)
Browse files Browse the repository at this point in the history
增加文件删除
  • Loading branch information
glide-the authored Aug 12, 2024
1 parent b01609d commit 8384f22
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 37 deletions.
32 changes: 24 additions & 8 deletions tests/integration_tests/test_file.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from __future__ import annotations

import unittest
Expand All @@ -16,6 +15,7 @@
from zhipuai import ZhipuAI
from zhipuai.api_resource import FilesWithRawResponse


@pytest.fixture(scope='class')
def test_server():
class SharedData:
Expand All @@ -31,11 +31,11 @@ class TestZhipuAIFileServer:
def test_logs(self, logging_conf):
logging.config.dictConfig(logging_conf) # type: ignore

def test_files(self,test_server, test_file_path):
def test_files(self, test_server, test_file_path):

try:
result = test_server.client.files.create(
file=open(os.path.join(test_file_path,"demo.jsonl"), "rb"),
file=open(os.path.join(test_file_path, "demo.jsonl"), "rb"),
purpose="fine-tune"
)
print(result)
Expand All @@ -49,11 +49,10 @@ def test_files(self,test_server, test_file_path):
except zhipuai.core._errors.APIStatusError as err:
print(err)


def test_files_validation(self,test_server, test_file_path):
def test_files_validation(self, test_server, test_file_path):
try:
result = test_server.client.files.create(
file=open(os.path.join(test_file_path,"demo.jsonl"), "rb"),
file=open(os.path.join(test_file_path, "demo.jsonl"), "rb"),
purpose="fine-tune"
)
print(result)
Expand All @@ -69,8 +68,7 @@ def test_files_validation(self,test_server, test_file_path):
except zhipuai.core._errors.APIStatusError as err:
print(err)


def test_files_list(self,test_server):
def test_files_list(self, test_server):
try:
list = test_server.client.files.list()
print(list)
Expand All @@ -84,5 +82,23 @@ def test_files_list(self,test_server):
except zhipuai.core._errors.APIStatusError as err:
print(err)

def test_delete_files(self, test_server):
try:
delete1 = test_server.client.files.delete(
file_id=test_server.file_id1
)
print(delete1)

delete2 = test_server.client.files.delete(
file_id=test_server.file_id2
)
print(delete2)



except zhipuai.core._errors.APIRequestFailedError as err:
print(err)
except zhipuai.core._errors.APIInternalError as err:
print(err)
except zhipuai.core._errors.APIStatusError as err:
print(err)
56 changes: 28 additions & 28 deletions zhipuai/api_resource/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,34 +127,34 @@ def list(
),
)

# def delete(
# self,
# file_id: str,
# *,
# extra_headers: Headers | None = None,
# extra_body: Body | None = None,
# timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
# ) -> FileDeleted:
# """
# Delete a file.
#
# Args:
# file_id: The ID of the file to delete
# extra_headers: Send extra headers
#
# extra_body: Add additional JSON properties to the request
#
# timeout: Override the client-level default timeout for this request, in seconds
# """
# if not file_id:
# raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}")
# return self._delete(
# f"/files/{file_id}",
# options=make_request_options(
# extra_headers=extra_headers, extra_body=extra_body, timeout=timeout
# ),
# cast_type=FileDeleted,
# )
def delete(
self,
file_id: str,
*,
extra_headers: Headers | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> FileDeleted:
"""
Delete a file.
Args:
file_id: The ID of the file to delete
extra_headers: Send extra headers
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not file_id:
raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}")
return self._delete(
f"/files/{file_id}",
options=make_request_options(
extra_headers=extra_headers, extra_body=extra_body, timeout=timeout
),
cast_type=FileDeleted,
)

def content(
self,
Expand Down
2 changes: 1 addition & 1 deletion zhipuai/api_resource/videos/videos.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def __init__(self, client: "ZhipuAI") -> None:
def generations(
self,
model: str,
prompt: str,
*,
prompt: str = None,
image_url: str = None,
request_id: str = None,
user_id: str = None,
Expand Down

0 comments on commit 8384f22

Please sign in to comment.