This commit is contained in:
guanjihuan 2023-11-20 10:45:54 +08:00
parent 4e7244ddf3
commit 06272721de
2 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,20 @@
"""
This code is supported by the website: https://www.guanjihuan.com
The newest version of this code is on the web page: https://www.guanjihuan.com/archives/37672
"""
# 初始例子
import guan
response = guan.chat(prompt='你好', stream_show=1, top_p=0.8, temperature=0.8)
print('最终回答:', response, '\n')
# 一个列表排序的应用例子
import guan
import random
random_list = [random.randint(1, 100) for _ in range(5)]
print('初始随机列表:', random_list)
response = guan.chat(prompt='直接给出数组从小到大的排序结果,不需要其他说明,请保证结果是正确的:'+str(random_list), stream_show=1, top_p=0.01, temperature=0.01) # 这里把 top_p 和 temperature 降到最低可以在一定程度上保证结果的正确性。
print('初始随机列表:', random_list)
random_list.sort()
print('算法排序后的列表:', random_list)
print('使用大语言模型排序后的列表:', response, '\n') # 效率不高,且不保证结果是百分百正确,通常对列表元素比较少的情况才有效。

View File

@ -0,0 +1,14 @@
"""
This code is supported by the website: https://www.guanjihuan.com
The newest version of this code is on the web page: https://www.guanjihuan.com/archives/37680
"""
def func_example(a=1, b=2):
for i0 in range(3):
print(i0+1)
c = a + b
return a, b, c
import guan
return_data = guan.run(function_name=func_example, args=(3, 4), return_show=0, get_print=1)
print(return_data)