0.2.0
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
[metadata]
|
||||
# replace with your username:
|
||||
name = guan
|
||||
version = 0.1.202
|
||||
version = 0.2.0
|
||||
author = guanjihuan
|
||||
author_email = guanjihuan@163.com
|
||||
description = An open source python package
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
Metadata-Version: 2.4
|
||||
Name: guan
|
||||
Version: 0.1.202
|
||||
Summary: An open source python package
|
||||
Home-page: https://py.guanjihuan.com
|
||||
Author: guanjihuan
|
||||
Author-email: guanjihuan@163.com
|
||||
Project-URL: Bug Tracker, https://py.guanjihuan.com
|
||||
Classifier: Programming Language :: Python :: 3
|
||||
Classifier: License :: OSI Approved :: MIT License
|
||||
Classifier: Operating System :: OS Independent
|
||||
Requires-Python: >=3.6
|
||||
Description-Content-Type: text/markdown
|
||||
License-File: LICENSE
|
||||
Dynamic: license-file
|
||||
|
||||
Guan is an open-source python package developed and maintained by https://www.guanjihuan.com/about (Ji-Huan Guan, 关济寰). The primary location of this package is on website https://py.guanjihuan.com. The GitHub location of this package is on https://github.com/guanjihuan/py.guanjihuan.com.
|
||||
@@ -1,24 +0,0 @@
|
||||
LICENSE
|
||||
README.md
|
||||
pyproject.toml
|
||||
setup.cfg
|
||||
src/guan/AI_chat.py
|
||||
src/guan/Fourier_transform.py
|
||||
src/guan/Green_functions.py
|
||||
src/guan/Hamiltonian_of_examples.py
|
||||
src/guan/__init__.py
|
||||
src/guan/band_structures_and_wave_functions.py
|
||||
src/guan/basic_functions.py
|
||||
src/guan/data_processing.py
|
||||
src/guan/decorators.py
|
||||
src/guan/density_of_states.py
|
||||
src/guan/figure_plotting.py
|
||||
src/guan/file_reading_and_writing.py
|
||||
src/guan/machine_learning.py
|
||||
src/guan/others.py
|
||||
src/guan/quantum_transport.py
|
||||
src/guan/topological_invariant.py
|
||||
src/guan.egg-info/PKG-INFO
|
||||
src/guan.egg-info/SOURCES.txt
|
||||
src/guan.egg-info/dependency_links.txt
|
||||
src/guan.egg-info/top_level.txt
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
guan
|
||||
@@ -1,64 +1,5 @@
|
||||
# Module: AI_chat
|
||||
|
||||
# AI 对话(当前默认模型为 'hunyuan-lite',无记忆)
|
||||
def chat(prompt='你好', model=1, stream=1, stream_label=0):
|
||||
import requests
|
||||
url = "http://api.guanjihuan.com/chat"
|
||||
data = {
|
||||
"prompt": prompt,
|
||||
"model": model,
|
||||
}
|
||||
if stream == 1:
|
||||
if stream_label == 1:
|
||||
print('\n--- Start Chat Stream Message ---\n')
|
||||
requests_response = requests.post(url, json=data, stream=True)
|
||||
response = ''
|
||||
if requests_response.status_code == 200:
|
||||
for line in requests_response.iter_lines():
|
||||
if line:
|
||||
if stream == 1:
|
||||
print(line.decode('utf-8'), end='', flush=True)
|
||||
response += line.decode('utf-8')
|
||||
print()
|
||||
else:
|
||||
pass
|
||||
if stream == 1:
|
||||
if stream_label == 1:
|
||||
print('\n--- End Chat Stream Message ---\n')
|
||||
return response
|
||||
|
||||
# 加上函数代码的 AI 对话(当前默认模型为 'hunyuan-lite',无记忆)
|
||||
def chat_with_function_code(function_name, prompt='', model=1, stream=1):
|
||||
import guan
|
||||
function_source = guan.get_source(function_name)
|
||||
if prompt == '':
|
||||
response = guan.chat(prompt=function_source, model=model, stream=stream)
|
||||
else:
|
||||
response = guan.chat(prompt=function_source+'\n\n'+prompt, model=model, stream=stream)
|
||||
return response
|
||||
|
||||
# 机器人自动对话(当前默认模型为 'hunyuan-lite',无记忆)
|
||||
def auto_chat(prompt='你好', round=2, model=1, stream=1):
|
||||
import guan
|
||||
response0 = prompt
|
||||
for i0 in range(round):
|
||||
print(f'\n【对话第 {i0+1} 轮】\n')
|
||||
print('机器人 1: ')
|
||||
response1 = guan.chat(prompt=response0, model=model, stream=stream)
|
||||
print('机器人 2: ')
|
||||
response0 = guan.chat(prompt=response1, model=model, stream=stream)
|
||||
|
||||
# 机器人自动对话(引导对话)(当前默认模型为 'hunyuan-lite',无记忆)
|
||||
def auto_chat_with_guide(prompt='你好', guide_message='(回答字数少于30个字,最后反问我一个问题)', round=5, model=1, stream=1):
|
||||
import guan
|
||||
response0 = prompt
|
||||
for i0 in range(round):
|
||||
print(f'\n【对话第 {i0+1} 轮】\n')
|
||||
print('机器人 1: ')
|
||||
response1 = guan.chat(prompt=response0+guide_message, model=model, stream=stream)
|
||||
print('机器人 2: ')
|
||||
response0 = guan.chat(prompt=response1+guide_message, model=model, stream=stream)
|
||||
|
||||
# 使用 OpenAI 框架对话(需要 API Key)
|
||||
def openai_chat(prompt="你好", model="qwen-plus", temperature=0.7, system_message=None, history=[], print_show=1, load_env=1):
|
||||
import os
|
||||
|
||||
@@ -15,4 +15,5 @@ from .data_processing import *
|
||||
from .AI_chat import *
|
||||
from .decorators import *
|
||||
from .others import *
|
||||
from .deprecated import *
|
||||
statistics_of_guan_package()
|
||||
106
PyPI/src/guan/deprecated.py
Normal file
106
PyPI/src/guan/deprecated.py
Normal file
@@ -0,0 +1,106 @@
|
||||
# Module: deprecated
|
||||
|
||||
# --- 废弃函数/版本兼容(不推荐使用,并可能在未来的版本中被移除) ---
|
||||
|
||||
# AI 对话(当前默认模型为 'hunyuan-lite',无记忆)
|
||||
def chat(prompt='你好', model=1, stream=1, stream_label=0):
|
||||
import requests
|
||||
url = "http://api.guanjihuan.com/chat"
|
||||
data = {
|
||||
"prompt": prompt,
|
||||
"model": model,
|
||||
}
|
||||
if stream == 1:
|
||||
if stream_label == 1:
|
||||
print('\n--- Start Chat Stream Message ---\n')
|
||||
requests_response = requests.post(url, json=data, stream=True)
|
||||
response = ''
|
||||
if requests_response.status_code == 200:
|
||||
for line in requests_response.iter_lines():
|
||||
if line:
|
||||
if stream == 1:
|
||||
print(line.decode('utf-8'), end='', flush=True)
|
||||
response += line.decode('utf-8')
|
||||
print()
|
||||
else:
|
||||
pass
|
||||
if stream == 1:
|
||||
if stream_label == 1:
|
||||
print('\n--- End Chat Stream Message ---\n')
|
||||
return response
|
||||
|
||||
# 加上函数代码的 AI 对话(当前默认模型为 'hunyuan-lite',无记忆)
|
||||
def chat_with_function_code(function_name, prompt='', model=1, stream=1):
|
||||
import guan
|
||||
function_source = guan.get_source(function_name)
|
||||
if prompt == '':
|
||||
response = guan.chat(prompt=function_source, model=model, stream=stream)
|
||||
else:
|
||||
response = guan.chat(prompt=function_source+'\n\n'+prompt, model=model, stream=stream)
|
||||
return response
|
||||
|
||||
# 机器人自动对话(当前默认模型为 'hunyuan-lite',无记忆)
|
||||
def auto_chat(prompt='你好', round=2, model=1, stream=1):
|
||||
import guan
|
||||
response0 = prompt
|
||||
for i0 in range(round):
|
||||
print(f'\n【对话第 {i0+1} 轮】\n')
|
||||
print('机器人 1: ')
|
||||
response1 = guan.chat(prompt=response0, model=model, stream=stream)
|
||||
print('机器人 2: ')
|
||||
response0 = guan.chat(prompt=response1, model=model, stream=stream)
|
||||
|
||||
# 机器人自动对话(引导对话)(当前默认模型为 'hunyuan-lite',无记忆)
|
||||
def auto_chat_with_guide(prompt='你好', guide_message='(回答字数少于30个字,最后反问我一个问题)', round=5, model=1, stream=1):
|
||||
import guan
|
||||
response0 = prompt
|
||||
for i0 in range(round):
|
||||
print(f'\n【对话第 {i0+1} 轮】\n')
|
||||
print('机器人 1: ')
|
||||
response1 = guan.chat(prompt=response0+guide_message, model=model, stream=stream)
|
||||
print('机器人 2: ')
|
||||
response0 = guan.chat(prompt=response1+guide_message, model=model, stream=stream)
|
||||
|
||||
def make_sh_file(sh_filename='a', command_line='python a.py', cpu_num=1, task_name='task', cd_dir=0):
|
||||
import guan
|
||||
print('Warning: The current function name has been deprecated, which will be deleted in the future version. Please change it into guan.make_sh_file_for_qsub().')
|
||||
guan.make_sh_file_for_qsub(sh_filename=sh_filename, command_line=command_line, cpu_num=cpu_num, task_name=task_name, cd_dir=cd_dir)
|
||||
|
||||
def plot_without_starting_fig(plt, fig, ax, x_array, y_array, xlabel='x', ylabel='y', title='', fontsize=20, style='', y_min=None, y_max=None, linewidth=None, markersize=None, color=None, fontfamily='Times New Roman'):
|
||||
import guan
|
||||
print('Warning: The current function name has been deprecated, which will be deleted in the future version. Please change it into guan.plot_without_starting_fig_ax().')
|
||||
guan.plot_without_starting_fig_ax(plt, fig, ax, x_array, y_array, xlabel=xlabel, ylabel=ylabel, title=title, fontsize=fontsize, style=style, y_min=y_min, y_max=y_max, linewidth=linewidth, markersize=markersize, color=color, fontfamily=fontfamily)
|
||||
|
||||
def draw_dots_and_lines_without_starting_fig(plt, fig, ax, coordinate_array, draw_dots=1, draw_lines=1, max_distance=1, line_style='-k', linewidth=1, dot_style='ro', markersize=3):
|
||||
import guan
|
||||
print('Warning: The current function name has been deprecated, which will be deleted in the future version. Please change it into guan.draw_dots_and_lines_without_starting_fig_ax().')
|
||||
guan.draw_dots_and_lines_without_starting_fig_ax(plt, fig, ax, coordinate_array, draw_dots=draw_dots, draw_lines=draw_lines, max_distance=max_distance, line_style=line_style, linewidth=linewidth, dot_style=dot_style, markersize=markersize)
|
||||
|
||||
def get_days_of_the_current_month(str_or_datetime='str'):
|
||||
import guan
|
||||
print('Warning: The current function name has been deprecated, which will be deleted in the future version. Please change it into guan.get_date_array_of_the_current_month().')
|
||||
date_array = guan.get_date_array_of_the_current_month(str_or_datetime=str_or_datetime)
|
||||
return date_array
|
||||
|
||||
def get_days_of_the_last_month(str_or_datetime='str'):
|
||||
import guan
|
||||
print('Warning: The current function name has been deprecated, which will be deleted in the future version. Please change it into guan.get_date_array_of_the_last_month().')
|
||||
date_array = guan.get_date_array_of_the_last_month(str_or_datetime=str_or_datetime)
|
||||
return date_array
|
||||
|
||||
def get_days_of_the_month_before_last(str_or_datetime='str'):
|
||||
import guan
|
||||
print('Warning: The current function name has been deprecated, which will be deleted in the future version. Please change it into guan.get_date_array_of_the_month_before_last().')
|
||||
date_array = guan.get_date_array_of_the_month_before_last(str_or_datetime=str_or_datetime)
|
||||
return date_array
|
||||
|
||||
def pdf_to_text(pdf_path):
|
||||
import guan
|
||||
print('Warning: The current function name has been deprecated, which will be deleted in the future version. Please change it into guan.pdf_to_text_with_pdfminer3k().')
|
||||
content = guan.pdf_to_text_with_pdfminer3k(pdf_path)
|
||||
return content
|
||||
|
||||
def statistics_with_day_and_time(content='', filename='time_logging', file_format='.txt'):
|
||||
import guan
|
||||
print('Warning: The current function name has been deprecated, which will be deleted in the future version. Please change it into guan.logging_with_day_and_time().')
|
||||
guan.logging_with_day_and_time(content=content, filename=filename, file_format=file_format)
|
||||
@@ -1282,50 +1282,4 @@ def initialize_hamiltonian_from_atom_object_list(atom_object_list):
|
||||
hamiltonian = np.zeros((dim*num, dim*num))
|
||||
for i0 in range(num):
|
||||
hamiltonian[i0*dim+0:i0*dim+dim, i0*dim+0:i0*dim+dim] = atom_object_list[i0].energy
|
||||
return hamiltonian
|
||||
|
||||
# --- 废弃函数/版本兼容(不推荐使用,并可能在未来的版本中被移除)deprecated ---
|
||||
|
||||
def make_sh_file(sh_filename='a', command_line='python a.py', cpu_num=1, task_name='task', cd_dir=0):
|
||||
import guan
|
||||
print('Warning: The current function name has been deprecated, which will be deleted in the future version. Please change it into guan.make_sh_file_for_qsub().')
|
||||
guan.make_sh_file_for_qsub(sh_filename=sh_filename, command_line=command_line, cpu_num=cpu_num, task_name=task_name, cd_dir=cd_dir)
|
||||
|
||||
def plot_without_starting_fig(plt, fig, ax, x_array, y_array, xlabel='x', ylabel='y', title='', fontsize=20, style='', y_min=None, y_max=None, linewidth=None, markersize=None, color=None, fontfamily='Times New Roman'):
|
||||
import guan
|
||||
print('Warning: The current function name has been deprecated, which will be deleted in the future version. Please change it into guan.plot_without_starting_fig_ax().')
|
||||
guan.plot_without_starting_fig_ax(plt, fig, ax, x_array, y_array, xlabel=xlabel, ylabel=ylabel, title=title, fontsize=fontsize, style=style, y_min=y_min, y_max=y_max, linewidth=linewidth, markersize=markersize, color=color, fontfamily=fontfamily)
|
||||
|
||||
def draw_dots_and_lines_without_starting_fig(plt, fig, ax, coordinate_array, draw_dots=1, draw_lines=1, max_distance=1, line_style='-k', linewidth=1, dot_style='ro', markersize=3):
|
||||
import guan
|
||||
print('Warning: The current function name has been deprecated, which will be deleted in the future version. Please change it into guan.draw_dots_and_lines_without_starting_fig_ax().')
|
||||
guan.draw_dots_and_lines_without_starting_fig_ax(plt, fig, ax, coordinate_array, draw_dots=draw_dots, draw_lines=draw_lines, max_distance=max_distance, line_style=line_style, linewidth=linewidth, dot_style=dot_style, markersize=markersize)
|
||||
|
||||
def get_days_of_the_current_month(str_or_datetime='str'):
|
||||
import guan
|
||||
print('Warning: The current function name has been deprecated, which will be deleted in the future version. Please change it into guan.get_date_array_of_the_current_month().')
|
||||
date_array = guan.get_date_array_of_the_current_month(str_or_datetime=str_or_datetime)
|
||||
return date_array
|
||||
|
||||
def get_days_of_the_last_month(str_or_datetime='str'):
|
||||
import guan
|
||||
print('Warning: The current function name has been deprecated, which will be deleted in the future version. Please change it into guan.get_date_array_of_the_last_month().')
|
||||
date_array = guan.get_date_array_of_the_last_month(str_or_datetime=str_or_datetime)
|
||||
return date_array
|
||||
|
||||
def get_days_of_the_month_before_last(str_or_datetime='str'):
|
||||
import guan
|
||||
print('Warning: The current function name has been deprecated, which will be deleted in the future version. Please change it into guan.get_date_array_of_the_month_before_last().')
|
||||
date_array = guan.get_date_array_of_the_month_before_last(str_or_datetime=str_or_datetime)
|
||||
return date_array
|
||||
|
||||
def pdf_to_text(pdf_path):
|
||||
import guan
|
||||
print('Warning: The current function name has been deprecated, which will be deleted in the future version. Please change it into guan.pdf_to_text_with_pdfminer3k().')
|
||||
content = guan.pdf_to_text_with_pdfminer3k(pdf_path)
|
||||
return content
|
||||
|
||||
def statistics_with_day_and_time(content='', filename='time_logging', file_format='.txt'):
|
||||
import guan
|
||||
print('Warning: The current function name has been deprecated, which will be deleted in the future version. Please change it into guan.logging_with_day_and_time().')
|
||||
guan.logging_with_day_and_time(content=content, filename=filename, file_format=file_format)
|
||||
return hamiltonian
|
||||
Reference in New Issue
Block a user