Skip to content

Commit dc0a227

Browse files
committedMar 19, 2023
publish 0.0.7
1 parent c9db8ff commit dc0a227

File tree

5 files changed

+33
-12
lines changed

5 files changed

+33
-12
lines changed
 

‎README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
<a target="_blank" href='https://gitee.com/CoderWanFeng/python-office'>
2323
<img src='https://gitee.com/CoderWanFeng//python-office/badge/star.svg?theme=dark' alt='gitee star'/>
2424
</a>
25-
<a href="https://mp.weixin.qq.com/s/Jf_EVdKlVnHhK68fW5OA6A">
26-
<img src="https://img.shields.io/badge/QQ-1090738447-orange"/>
25+
<a href="https://mp.weixin.qq.com/s/yaSmFKO3RrBpyanW3nvRAQ">
26+
<img src="https://img.shields.io/badge/QQ-163434413-orange"/>
2727
</a>
2828
<a href="https://mp.weixin.qq.com/s/wx-JkgOUoJhb-7ZESxl93w">
2929
<img src="https://img.shields.io/badge/%E5%BE%AE%E4%BF%A1-%E4%BA%A4%E6%B5%81%E7%BE%A4-brightgreen"/>
@@ -70,4 +70,4 @@ pip install -i https://pypi.tuna.tsinghua.edu.cn/simple poai -U
7070
## 📌进交流群
7171

7272

73-
![CoderWanFeng](https://python-office-1300615378.cos.ap-chongqing.myqcloud.com/python-office-qr.jpg)
73+
![CoderWanFeng](https://python-office-1300615378.cos.ap-chongqing.myqcloud.com/python-office-qr.jpg)

‎demo/result.txt

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
,我是李红英。
2+
3+
Hi, I'm Li Hongying.
4+
5+
我的电话号码是:
6+
7+
My phone number is:
8+
9+
13670067700。
10+
11+
13670067700.
12+
13+
请记住我的电话号码。
14+
15+
Please remember my phone number.
16+
17+
谢谢!
18+
19+
Thank you!

‎poai/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
print('使用有问题 or 提交你的功能需求 or 参与项目开发')
1515
print('1、请+【项目交流群】:http://t.cn/A65MiFvH')
1616
print('2、本开源项目的【代码仓库】:https://github.com/CoderWanFeng/poai')
17-
print('3、免费的微信机器人:https://b23.tv/jDVRtU5')
17+
print('3、免费的微信机器人:https://mp.weixin.qq.com/s/9aspEHdCiAdXK17AvHlu9Q')
1818
print(SPLIT_LINE)

‎poai/api/chatgpt.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,21 @@
99
import openai
1010

1111

12-
def chat(api_key, prompt, model_engine="text-davinci-002"):
12+
def chat(api_key, prompt, model_engine="text-davinci-002", max_tokens=1024, n=1, stop=None, temperature=0.5, top_p=1,
13+
frequency_penalty=0.0, presence_penalty=0.6):
1314
# 设置 API Key
1415
openai.api_key = api_key # your_api_key
15-
1616
completions = openai.Completion.create(
1717
engine=model_engine,
1818
prompt=prompt,
19-
max_tokens=1024,
20-
n=1,
21-
stop=None,
22-
temperature=0.5,
19+
max_tokens=max_tokens, # 生成结果时的最大 tokens 数。平均一个汉字是 2 个 tokens,text-davinci-003 最多是 4000 个 tokens,也就是 2000 个汉字左右
20+
n=n,
21+
stop=stop,
22+
temperature=temperature, # 控制结果的随机性,如果希望结果更有差异性 0.9,或者希望有固定结果可以尝试 0.0
23+
top_p=top_p, # 一个可用于代替 temperature 的参数,对应机器学习中 nucleus sampling,如果设置 0.1 意味着只考虑构成前 10% 概率质量的 tokens
24+
frequency_penalty=frequency_penalty, # 控制字符的重复度,取值为 -2.0 ~ 2.0 之间的数字
25+
presence_penalty=presence_penalty # 控制主题的重复度,取值为 -2.0 ~ 2.0 之间的数字
2326
)
24-
2527
# 获取 ChatGPT 的回复
2628
message = completions.choices[0].text
2729
print(message)

‎setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = poai
3-
version = 0.0.6
3+
version = 0.0.7
44
description = pip install poai
55
long_description = file: README.md
66
long_description_content_type = text/markdown

0 commit comments

Comments
 (0)
Please sign in to comment.