diff --git a/LLMS.md b/LLMS.md index 9e126ef..11f87d8 100644 --- a/LLMS.md +++ b/LLMS.md @@ -40,6 +40,8 @@ for i in qa(query='数据治理简约流程'): # 百度文心 ```python +import os +os.environ['ERNIE_API_KEY'] = "apikey:apisecret" from langchain.chains import LLMChain from langchain.prompts import ChatPromptTemplate from chatllm.llmchain.llms import ErnieBot @@ -52,6 +54,8 @@ print(c.run('你是谁')) # 讯飞星火 ```python +import os +os.environ['SPARK_API_KEY'] = "appid:apikey:apisecret" from langchain.chains import LLMChain from langchain.prompts import ChatPromptTemplate from chatllm.llmchain.llms import SparkBot diff --git a/chatllm-2023.8.10.16.42.20/.editorconfig b/chatllm-2023.8.10.16.42.20/.editorconfig new file mode 100644 index 0000000..d4a2c44 --- /dev/null +++ b/chatllm-2023.8.10.16.42.20/.editorconfig @@ -0,0 +1,21 @@ +# http://editorconfig.org + +root = true + +[*] +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true +insert_final_newline = true +charset = utf-8 +end_of_line = lf + +[*.bat] +indent_style = tab +end_of_line = crlf + +[LICENSE] +insert_final_newline = false + +[Makefile] +indent_style = tab diff --git a/chatllm-2023.8.10.16.42.20/.gitignore b/chatllm-2023.8.10.16.42.20/.gitignore new file mode 100644 index 0000000..43091aa --- /dev/null +++ b/chatllm-2023.8.10.16.42.20/.gitignore @@ -0,0 +1,105 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# dotenv +.env + +# virtualenv +.venv +venv/ +ENV/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ + +# IDE settings +.vscode/ \ No newline at end of file diff --git a/chatllm-2023.8.10.16.42.20/.travis.yml b/chatllm-2023.8.10.16.42.20/.travis.yml new file mode 100644 index 0000000..98787a8 --- /dev/null +++ b/chatllm-2023.8.10.16.42.20/.travis.yml @@ -0,0 +1,29 @@ +# Config file for automatic testing at travis-ci.com + +language: python +python: + - 3.8 + - 3.7 + - 3.6 + - 3.5 + +# Command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors +install: pip install -U tox-travis + +# Command to run tests, e.g. python setup.py test +script: tox + +# Assuming you have installed the travis-ci CLI tool, after you +# create the Github repo and add it to Travis, run the +# following command to finish PyPI deployment setup: +# $ travis encrypt --add deploy.password +deploy: + provider: pypi + distributions: sdist bdist_wheel + user: yuanjie-ai + password: + secure: PLEASE_REPLACE_ME + on: + tags: true + repo: yuanjie-ai/llm4gpt + python: 3.8 diff --git a/chatllm-2023.8.10.16.42.20/LICENSE b/chatllm-2023.8.10.16.42.20/LICENSE new file mode 100644 index 0000000..d19ff97 --- /dev/null +++ b/chatllm-2023.8.10.16.42.20/LICENSE @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2023, LLM4GPT + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/chatllm-2023.8.10.16.42.20/LLMS.md b/chatllm-2023.8.10.16.42.20/LLMS.md new file mode 100644 index 0000000..9e126ef --- /dev/null +++ b/chatllm-2023.8.10.16.42.20/LLMS.md @@ -0,0 +1,63 @@ +# Chatgpt* + +```python +from meutils.pipe import * +from chatllm.applications import ChatBase + +os.environ['API_KEY'] = 'sk-...' + +qa = ChatBase() +qa.load_llm(model_name_or_path="chatgpt") +for i in qa(query='数据治理简约流程'): + print(i, end='') +``` + +# Chatglm* + +```python +from meutils.pipe import * +from chatllm.applications import ChatBase + +qa = ChatBase() +qa.load_llm(model_name_or_path="THUDM/chatglm2-6b") +for i in qa(query='数据治理简约流程'): + print(i, end='') +``` + + +# LLAMA*【适配中。。。】 + +```python +from meutils.pipe import * +from chatllm.applications import ChatBase + +qa = ChatBase() +qa.load_llm(model_name_or_path="LLAMA") +for i in qa(query='数据治理简约流程'): + print(i, end='') +``` + +# 百度文心 + +```python +from langchain.chains import LLMChain +from langchain.prompts import ChatPromptTemplate +from chatllm.llmchain.llms import ErnieBot + +llm = ErnieBot() +c = LLMChain(llm=llm, prompt=ChatPromptTemplate.from_template("{question}")) +print(c.run('你是谁')) +``` + +# 讯飞星火 + +```python +from langchain.chains import LLMChain +from langchain.prompts import ChatPromptTemplate +from chatllm.llmchain.llms import SparkBot + +llm = SparkBot() +c = LLMChain(llm=llm, prompt=ChatPromptTemplate.from_template("{question}")) +print(c.run('你是谁')) + +``` diff --git a/chatllm-2023.8.10.16.42.20/MANIFEST.in b/chatllm-2023.8.10.16.42.20/MANIFEST.in new file mode 100644 index 0000000..93c2b85 --- /dev/null +++ b/chatllm-2023.8.10.16.42.20/MANIFEST.in @@ -0,0 +1,14 @@ +include AUTHORS.rst +include CONTRIBUTING.rst +include HISTORY.rst +include LICENSE +include README* + +recursive-include tests * +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] +recursive-exclude docs * +recursive-exclude examples * +recursive-exclude cachedir * + +recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif diff --git a/chatllm-2023.8.10.16.42.20/Makefile b/chatllm-2023.8.10.16.42.20/Makefile new file mode 100644 index 0000000..41eec64 --- /dev/null +++ b/chatllm-2023.8.10.16.42.20/Makefile @@ -0,0 +1,85 @@ +.PHONY: clean clean-test clean-pyc clean-build docs help +.DEFAULT_GOAL := help + +define BROWSER_PYSCRIPT +import os, webbrowser, sys + +from urllib.request import pathname2url + +webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1]))) +endef +export BROWSER_PYSCRIPT + +define PRINT_HELP_PYSCRIPT +import re, sys + +for line in sys.stdin: + match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line) + if match: + target, help = match.groups() + print("%-20s %s" % (target, help)) +endef +export PRINT_HELP_PYSCRIPT + +BROWSER := python -c "$$BROWSER_PYSCRIPT" + +help: + @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) + +clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts + +clean-build: ## remove build artifacts + rm -fr build/ + rm -fr dist/ + rm -fr .eggs/ + find . -name '*.egg-info' -exec rm -fr {} + + find . -name '*.egg' -exec rm -f {} + + +clean-pyc: ## remove Python file artifacts + find . -name '*.pyc' -exec rm -f {} + + find . -name '*.pyo' -exec rm -f {} + + find . -name '*~' -exec rm -f {} + + find . -name '__pycache__' -exec rm -fr {} + + +clean-test: ## remove test and coverage artifacts + rm -fr .tox/ + rm -f .coverage + rm -fr htmlcov/ + rm -fr .pytest_cache + +lint: ## check style with flake8 + flake8 llm4gpt tests + +test: ## run tests quickly with the default Python + python setup.py test + +test-all: ## run tests on every Python version with tox + tox + +coverage: ## check code coverage quickly with the default Python + coverage run --source llm4gpt setup.py test + coverage report -m + coverage html + $(BROWSER) htmlcov/index.html + +docs: ## generate Sphinx HTML documentation, including API docs + rm -f docs/llm4gpt.rst + rm -f docs/modules.rst + sphinx-apidoc -o docs/ llm4gpt + $(MAKE) -C docs clean + $(MAKE) -C docs html + $(BROWSER) docs/_build/html/index.html + +servedocs: docs ## compile the docs watching for changes + watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D . + +release: dist ## package and upload a release + twine upload dist/* + +dist: clean ## builds source and wheel package + python setup.py sdist + python setup.py bdist_wheel + ls -l dist + +install: clean ## install the package to the active Python's site-packages + python setup.py install diff --git a/chatllm-2023.8.10.16.42.20/PKG-INFO b/chatllm-2023.8.10.16.42.20/PKG-INFO new file mode 100644 index 0000000..a401c47 --- /dev/null +++ b/chatllm-2023.8.10.16.42.20/PKG-INFO @@ -0,0 +1,215 @@ +Metadata-Version: 2.1 +Name: chatllm +Version: 2023.8.10.16.42.20 +Summary: Create a Python package. +Home-page: https://github.com/yuanjie-ai/ChatLLM +Author: yuanjie +Author-email: 313303303@qq.com +License: MIT license +Keywords: chatllm +Classifier: Development Status :: 2 - Pre-Alpha +Classifier: Intended Audience :: Developers +Classifier: License :: OSI Approved :: MIT License +Classifier: Natural Language :: English +Classifier: Programming Language :: Python :: 3.7 +Classifier: Programming Language :: Python :: 3.8 +Requires-Python: >=3.7 +Description-Content-Type: text/markdown +Provides-Extra: ann +Provides-Extra: api +Provides-Extra: pdf +Provides-Extra: openai +Provides-Extra: streamlit +Provides-Extra: all +License-File: LICENSE + +![image](https://img.shields.io/pypi/v/chatllm.svg) ![image](https://img.shields.io/travis/yuanjie-ai/chatllm.svg) ![image](https://readthedocs.org/projects/chatllm/badge/?version=latest) + +
'
+ else:
+ lines[i] = f'
'
+ else:
+ if i > 0:
+ if count % 2 == 1:
+ line = line.replace("`", "\`")
+ line = line.replace("<", "<")
+ line = line.replace(">", ">")
+ line = line.replace(" ", " ")
+ line = line.replace("*", "*")
+ line = line.replace("_", "_")
+ line = line.replace("-", "-")
+ line = line.replace(".", ".")
+ line = line.replace("!", "!")
+ line = line.replace("(", "(")
+ line = line.replace(")", ")")
+ line = line.replace("$", "$")
+ lines[i] = "\n", + " | page_content | \n", + "metadata | \n", + "
---|---|---|
0 | \n", + "\n", + " | {'source': '孙子兵法.pdf', 'file_path': '孙子兵法.pdf'... | \n", + "
1 | \n", + "内容提要\\n本书分为两个部分。第一部分评述《孙子兵法》在战争规律、军事\\n谋略、军事哲学、军... | \n", + "{'source': '孙子兵法.pdf', 'file_path': '孙子兵法.pdf'... | \n", + "
2 | \n", + "白话孙子兵法\\n | \n", + "{'source': '孙子兵法.pdf', 'file_path': '孙子兵法.pdf'... | \n", + "
3 | \n", + "第一部分\\n《孙子兵法》评述\\n | \n", + "{'source': '孙子兵法.pdf', 'file_path': '孙子兵法.pdf'... | \n", + "
4 | \n", + "一、孙子的生平\\n孙子,姓孙,名武,字长卿,人们尊称其为孙子或孙武子,是春秋\\n末期齐国乐安... | \n", + "{'source': '孙子兵法.pdf', 'file_path': '孙子兵法.pdf'... | \n", + "
... | \n", + "... | \n", + "... | \n", + "
106 | \n", + "正因为《用间》所论述的是这样:一个关乎战争胜败的全局问题,\\n所以孙子对它的重要性非常重视。... | \n", + "{'source': '孙子兵法.pdf', 'file_path': '孙子兵法.pdf'... | \n", + "
107 | \n", + "(3)死间。孙子说:“ 反间者,因其敌间而用之。” 所谓反间,就\\n是收买或利用敌方派来的间... | \n", + "{'source': '孙子兵法.pdf', 'file_path': '孙子兵法.pdf'... | \n", + "
108 | \n", + "则,还是值得惜鉴的。\\n孙子提出,在间谍的人选中,最理想、最重要的是“ 以上智为问” 。\\n... | \n", + "{'source': '孙子兵法.pdf', 'file_path': '孙子兵法.pdf'... | \n", + "
109 | \n", + "后 记\\n中国古代的兵书,卷帙浩繁,内容丰富,历史悠久,影响深远。存\\n留到今天的... | \n", + "{'source': '孙子兵法.pdf', 'file_path': '孙子兵法.pdf'... | \n", + "
110 | \n", + "\\n | \n", + "{'source': '孙子兵法.pdf', 'file_path': '孙子兵法.pdf'... | \n", + "
111 rows × 2 columns
\n", + "\n", + " | page_content | \n", + "metadata | \n", + "
---|---|---|
0 | \n", + "内容提要\\n本书分为两个部分。第一部分评述《孙子兵法》在战争规律、军事\\n谋略、军事哲学、军... | \n", + "{'source': '孙子兵法.pdf', 'file_path': '孙子兵法.pdf'... | \n", + "
1 | \n", + "白话孙子兵法 | \n", + "{'source': '孙子兵法.pdf', 'file_path': '孙子兵法.pdf'... | \n", + "
2 | \n", + "第一部分\\n《孙子兵法》评述 | \n", + "{'source': '孙子兵法.pdf', 'file_path': '孙子兵法.pdf'... | \n", + "
3 | \n", + "一、孙子的生平\\n孙子,姓孙,名武,字长卿,人们尊称其为孙子或孙武子,是春秋\\n末期齐国乐安... | \n", + "{'source': '孙子兵法.pdf', 'file_path': '孙子兵法.pdf'... | \n", + "
4 | \n", + "时候,孙武——或许还有孙氏家族的其他成员——却离开了放土齐国,\\n踏上了新的里程。他们到了南... | \n", + "{'source': '孙子兵法.pdf', 'file_path': '孙子兵法.pdf'... | \n", + "
... | \n", + "... | \n", + "... | \n", + "
104 | \n", + "而要事先了解敌情,不可用迷信鬼神和占卜等方法去取得,不可用过去\\n相似的事情作类比也不可用观... | \n", + "{'source': '孙子兵法.pdf', 'file_path': '孙子兵法.pdf'... | \n", + "
105 | \n", + "正因为《用间》所论述的是这样:一个关乎战争胜败的全局问题,\\n所以孙子对它的重要性非常重视。... | \n", + "{'source': '孙子兵法.pdf', 'file_path': '孙子兵法.pdf'... | \n", + "
106 | \n", + "(3)死间。孙子说:“ 反间者,因其敌间而用之。” 所谓反间,就\\n是收买或利用敌方派来的间... | \n", + "{'source': '孙子兵法.pdf', 'file_path': '孙子兵法.pdf'... | \n", + "
107 | \n", + "则,还是值得惜鉴的。\\n孙子提出,在间谍的人选中,最理想、最重要的是“ 以上智为问” 。\\n... | \n", + "{'source': '孙子兵法.pdf', 'file_path': '孙子兵法.pdf'... | \n", + "
108 | \n", + "后 记\\n中国古代的兵书,卷帙浩繁,内容丰富,历史悠久,影响深远。存\\n留到今天的... | \n", + "{'source': '孙子兵法.pdf', 'file_path': '孙子兵法.pdf'... | \n", + "
109 rows × 2 columns
\n", + "