Skip to content

Commit

Permalink
use env key in curl
Browse files Browse the repository at this point in the history
  • Loading branch information
RexWzh committed Jun 24, 2024
1 parent 950937d commit 7813f00
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion chattool/__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__ = '3.3.2'
__version__ = '3.3.3'

import os, sys, requests, json
from .chattype import Chat, Resp
Expand Down
3 changes: 2 additions & 1 deletion chattool/chattype.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,11 @@ def get_valid_models(self, gpt_only:bool=True)->List[str]:
model_url = os.path.join(self.base_url, 'v1/models')
return valid_models(self.api_key, model_url, gpt_only=gpt_only)

def get_curl(self, **options):
def get_curl(self, hide_key:bool=False, **options):
"""Print the curl command"""
options = self._init_options(**options)
api_key, chat_log, chat_url = self.api_key, self.chat_log, self.chat_url
if hide_key: api_key = '$OPENAI_API_KEY'
return curl_cmd_of_chat_completion(api_key, chat_url, chat_log, **options)

def print_curl(self, **options):
Expand Down
2 changes: 1 addition & 1 deletion chattool/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def curl_cmd_of_chat_completion( api_key:str
}
curl_cmd += f"\n -H 'Content-Type: application/json' \\"
curl_cmd += f"\n -H 'Authorization: Bearer {api_key}' \\"
curl_cmd += f"\n -d '{json.dumps(payload, indent=4)}' \\"
curl_cmd += f"\n -d '{json.dumps(payload, indent=4, ensure_ascii=False)}' \\"
if isinstance(timeout, int) and timeout > 0:
curl_cmd += f"\n --max-time {timeout} \\"
return curl_cmd.rstrip(" \\")
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 = '3.3.2'
VERSION = '3.3.3'

requirements = [
'Click>=7.0', 'requests>=2.20', "responses>=0.23", 'aiohttp>=3.8',
Expand Down

0 comments on commit 7813f00

Please sign in to comment.