Skip to content

Commit

Permalink
update a lot
Browse files Browse the repository at this point in the history
  • Loading branch information
vichayturen committed Oct 7, 2023
1 parent 059c2b2 commit 5cf7501
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
12 changes: 12 additions & 0 deletions myutils/gpt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import openai
from typing import Literal


optional_models = Literal['gpt-3.5-turbo', 'gpt-3.5-turbo-16k', 'gpt-4', 'gpt-4-32k']
def call_gpt(prompt: str, api_key: str, model: optional_models='gpt-3.5-turbo') -> str:
openai.api_key = api_key
completion = openai.ChatCompletion.create(
model=model,
messages=[{"role": "user", "content": prompt}]
)
return completion.choices[0].message.content
11 changes: 11 additions & 0 deletions myutils/net.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import os


def set_proxy(port: int=7890):
os.environ["http_proxy"] = f"http://127.0.0.1:{port}"
os.environ["https_proxy"] = f"http://127.0.0.1:{port}"

def unset_proxy():
os.environ.pop("http_proxy")
os.environ.pop("https_proxy")

5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="myutils",
version="1.0",
version="1.0.1.dev",
author="Vichayturen",
author_email="[email protected]",
description="",
Expand All @@ -11,7 +11,8 @@
url="",
# 表明当前模块依赖哪些包,若环境中没有,则会从pypi中下载安装
install_requires=[
'pandas'
'pandas',
'openai'
],
# 你要安装的包,通过 setuptools.find_packages 找到当前目录下有哪些包
packages=find_packages()
Expand Down

0 comments on commit 5cf7501

Please sign in to comment.