初始化提交
This commit is contained in:
108
.gitignore
vendored
Normal file
108
.gitignore
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
.idea/**/aws.xml
|
||||
.idea/**/contentModel.xml
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
cmake-build-*/
|
||||
.idea/**/mongoSettings.xml
|
||||
*.iws
|
||||
out/
|
||||
.idea_modules/
|
||||
atlassian-ide-plugin.xml
|
||||
.idea/replstate.xml
|
||||
.idea/sonarlint/
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
.idea/httpRequests
|
||||
.idea/caches/build_file_checksums.ser
|
||||
.ipynb_checkpoints
|
||||
*/.ipynb_checkpoints/*
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
*.so
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
*.manifest
|
||||
*.spec
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
cover/
|
||||
*.mo
|
||||
*.pot
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
instance/
|
||||
.webassets-cache
|
||||
.scrapy
|
||||
docs/_build/
|
||||
.pybuilder/
|
||||
target/
|
||||
.pdm.toml
|
||||
__pypackages__/
|
||||
celerybeat-schedule
|
||||
celerybeat.pid
|
||||
*.sage.py
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
.spyderproject
|
||||
.spyproject
|
||||
.ropeproject
|
||||
/site
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
.pyre/
|
||||
.pytype/
|
||||
cython_debug/
|
||||
.vagrant/
|
||||
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# 基于编辑器的 HTTP 客户端请求
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
8
.idea/ai-server.iml
generated
Normal file
8
.idea/ai-server.iml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="jdk" jdkName="Poetry (ai-server)" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
||||
6
.idea/misc.xml
generated
Normal file
6
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Black">
|
||||
<option name="sdkName" value="Poetry (ai-server)" />
|
||||
</component>
|
||||
</project>
|
||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/ai-server.iml" filepath="$PROJECT_DIR$/.idea/ai-server.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
4
.idea/vcs.xml
generated
Normal file
4
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings" defaultProject="true" />
|
||||
</project>
|
||||
8
Dockerfile
Normal file
8
Dockerfile
Normal file
@@ -0,0 +1,8 @@
|
||||
FROM python:3.12-alpine
|
||||
RUN pip install --upgrade pip \
|
||||
&& pip install --no-cache-dir flask waitress zhipuai \
|
||||
&& mkdir -p /app
|
||||
WORKDIR /app
|
||||
COPY ai-server.py /app/ai-server.py
|
||||
EXPOSE 6721
|
||||
CMD ["python", "/app/ai-server.py"]
|
||||
5
Vagrantfile
vendored
Normal file
5
Vagrantfile
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vm.box = "gusztavvargadr/docker-linux"
|
||||
config.vm.box_version = "0"
|
||||
config.vm.synced_folder "./", "/vagrant_data"
|
||||
end
|
||||
26
ai-server.py
Normal file
26
ai-server.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from flask import Flask, request
|
||||
from zhipuai import ZhipuAI
|
||||
|
||||
app = Flask(__name__)
|
||||
client = ZhipuAI(api_key="d1e97306540d12bb2f834be961fcacb1.SNBShlCxWYJCx0qZ")
|
||||
|
||||
|
||||
@app.route('/ai_text', methods=['POST'])
|
||||
def ai_text():
|
||||
input = request.get_data(as_text=True)
|
||||
# 如果input值为空,则返回空字符串
|
||||
if not input:
|
||||
return ''
|
||||
completion = client.chat.completions.create(
|
||||
model="glm-4-flash",
|
||||
messages=[
|
||||
{"role": "user", "content": input},
|
||||
],
|
||||
)
|
||||
return completion.choices[0].message.content
|
||||
|
||||
|
||||
# app.run(host='0.0.0.0', port=6721)
|
||||
from waitress import serve
|
||||
|
||||
serve(app, host='0.0.0.0', port=6721)
|
||||
99
openai_api.ipynb
Normal file
99
openai_api.ipynb
Normal file
File diff suppressed because one or more lines are too long
2723
poetry.lock
generated
Normal file
2723
poetry.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
21
pyproject.toml
Normal file
21
pyproject.toml
Normal file
@@ -0,0 +1,21 @@
|
||||
[project]
|
||||
name = "ai-server"
|
||||
version = "0.1.0"
|
||||
description = ""
|
||||
authors = [
|
||||
{name = "lanyuanxiaoyao",email = "lanyuanxiaoyao@gmail.com"}
|
||||
]
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.12"
|
||||
dependencies = [
|
||||
"openai (>=1.61.1,<2.0.0)",
|
||||
"flask (>=3.1.0,<4.0.0)",
|
||||
"jupyter (>=1.1.1,<2.0.0)",
|
||||
"zhipuai (>=2.1.5.20250106,<3.0.0.0)",
|
||||
"waitress (>=3.0.2,<4.0.0)"
|
||||
]
|
||||
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core>=2.0.0,<3.0.0"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
4
test.http
Normal file
4
test.http
Normal file
@@ -0,0 +1,4 @@
|
||||
POST http://192.168.31.127:6721/ai_text
|
||||
|
||||
现在是2025年2月9日22:26,桃子(这个家的女主人)刚进家门,帮我写一段100字左右的欢迎辞,文风俏皮可爱,先阿谀奉承一下桃子的美貌,然后体贴地感谢她为这个家的付出,务求让桃子能够感受到回家的温馨和开心;文案要口语化、日常化,就像日常对话一样,不要插入任何emoji或颜文字,播放这段欢迎辞的是一个音箱,不要在文案里插入任何主动的动作
|
||||
|
||||
88
zhipu_api.ipynb
Normal file
88
zhipu_api.ipynb
Normal file
@@ -0,0 +1,88 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-09T14:07:16.031829Z",
|
||||
"start_time": "2025-02-09T14:07:14.303357Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"from zhipuai import ZhipuAI\n",
|
||||
"\n",
|
||||
"client = ZhipuAI(api_key=\"d1e97306540d12bb2f834be961fcacb1.SNBShlCxWYJCx0qZ\")\n",
|
||||
"\n",
|
||||
"completion = client.chat.completions.create(\n",
|
||||
" model=\"glm-4-flash\",\n",
|
||||
" messages=[\n",
|
||||
" {\"role\": \"user\", \"content\": \"你好,世界!\"},\n",
|
||||
" ],\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"print(completion.choices[0].message.content)"
|
||||
],
|
||||
"id": "5c31cf5e65b29021",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"你好🌍!很高兴见到你,有什么可以帮助你的吗?\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 1
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-09T14:09:26.966550Z",
|
||||
"start_time": "2025-02-09T14:09:19.468942Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"# 图片生成\n",
|
||||
"response = client.images.generations(\n",
|
||||
" model=\"cogview-3-flash\", #填写需要调用的模型编码\n",
|
||||
" prompt=\"正在高考的高考考场\",\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"print(response.data[0].url)"
|
||||
],
|
||||
"id": "51c384f791c2befb",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"https://aigc-files.bigmodel.cn/api/cogview/20250209220928a7b73b91d06a4206_0.png\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 4
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 2
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython2",
|
||||
"version": "2.7.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
Reference in New Issue
Block a user