Skip to content

Commit

Permalink
fix tests & update minor version
Browse files Browse the repository at this point in the history
  • Loading branch information
RexWzh committed Sep 9, 2023
1 parent 37a3933 commit 1935fa3
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion openai_api_call/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__author__ = """Rex Wang"""
__email__ = '[email protected]'
__version__ = '1.2.0'
__version__ = '1.3.0'

import os, sys, requests
from .chattool import Chat, Resp
Expand Down
1 change: 1 addition & 0 deletions openai_api_call/chattool.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def getresponse( self
timeout (int, optional): timeout for the API call. Defaults to 0(no timeout).
timeinterval (int, optional): time interval between two API calls. Defaults to 0.
update (bool, optional): whether to update the chat log. Defaults to True.
options (dict, optional): other options like `temperature`, `top_p`, etc.
Returns:
Resp: API response
Expand Down
4 changes: 2 additions & 2 deletions openai_api_call/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def cost(self):
return response_cost(self.model, self.prompt_tokens, self.completion_tokens)

def __repr__(self) -> str:
return f"`Resp`: {self.content}"
return "<Resp with finished reason: " + self.finish_reason + ">"

def __str__(self) -> str:
return self.content
Expand Down Expand Up @@ -78,7 +78,7 @@ def message(self):
@property
def content(self):
"""Content of the response"""
return "<Resp with finished reason: " + self.finish_reason + ">"
return self.message['content']

@property
def delta_content(self):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
with open('README.md') as readme_file:
readme = readme_file.read()

VERSION = '1.2.0'
VERSION = '1.3.0'

requirements = [
'Click>=7.0', 'requests>=2.20', "responses>=0.23",
Expand Down
1 change: 1 addition & 0 deletions tests/test_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from openai_api_call.asynctool import async_chat_completion
openai_api_call.api_key="free-123"
openai_api_call.base_url = "https://api.wzhecnu.cn"
import asyncio

# langs = ["Python", "Julia", "C++", "C", "Java", "JavaScript", "C#", "Go", "R", "Ruby"]
langs = ["Python", "Julia", "C++"]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_openai_api_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,5 +210,5 @@ def test_valid():
def test_show():
resp = Resp(response=response)
assert str(resp) == resp.content
assert repr(resp) == f"`Resp`: {resp.content}"
assert repr(resp) == "<Resp with finished reason: stop>"

0 comments on commit 1935fa3

Please sign in to comment.