Skip to content

Commit

Permalink
add: 支持文心、星火api
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanjie-ai committed Aug 10, 2023
1 parent a862c19 commit 3a0fd9c
Show file tree
Hide file tree
Showing 200 changed files with 200,307 additions and 56 deletions.
4 changes: 4 additions & 0 deletions LLMS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
21 changes: 21 additions & 0 deletions chatllm-2023.8.10.16.42.20/.editorconfig
Original file line number Diff line number Diff line change
@@ -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
105 changes: 105 additions & 0 deletions chatllm-2023.8.10.16.42.20/.gitignore
Original file line number Diff line number Diff line change
@@ -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/
29 changes: 29 additions & 0 deletions chatllm-2023.8.10.16.42.20/.travis.yml
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions chatllm-2023.8.10.16.42.20/LICENSE
Original file line number Diff line number Diff line change
@@ -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.

63 changes: 63 additions & 0 deletions chatllm-2023.8.10.16.42.20/LLMS.md
Original file line number Diff line number Diff line change
@@ -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('你是谁'))

```
14 changes: 14 additions & 0 deletions chatllm-2023.8.10.16.42.20/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -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
85 changes: 85 additions & 0 deletions chatllm-2023.8.10.16.42.20/Makefile
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit 3a0fd9c

Please sign in to comment.