công cụ llama-create
sử dụng nó
Tạo các dự án
npx create-llama@latest
✔ Which template would you like to use? › Chat
✔ Which framework would you like to use? › FastAPI (Python)
✔ Would you like to generate a NextJS frontend for your FastAPI (Python) backend? … No
✔ Which model would you like to use? › gpt-3.5-turbo-0125
✔ Which embedding model would you like to use? › text-embedding-3-small
✔ Which data source would you like to use? › Use an example PDF
✔ Would you like to add another data source? › No
✔ Would you like to use LlamaParse (improved parser for RAG - requires API key)? … yes
✔ Please provide your LlamaIndex Cloud API key (leave blank to skip): …
✔ Would you like to use a vector database? › PostgreSQL
Tạo cơ sở dữ liệu trong Supabase, lấy chuỗi kết nối Migration
Điền vào tệp.env
Chuyển sang môi trường conda
Chuyển sang Proxy
Cập nhật phiên bản của thư viện trong pyproject.toml
[tool]
[tool.poetry]
name = "app"
version = "0.1.0"
description = ""
authors = [ "Marcus Schiesser <mail@marcusschiesser.de>" ]
readme = "README.md"
[tool.poetry.dependencies]
python = "^3.11,<3.12"
fastapi = "^0.110.1"
python-dotenv = "^1.0.0"
llama-index = "0.10.28"
llama-index-core = "0.10.28"
llama-index-agent-openai = "0.2.2"
[tool.poetry.dependencies.uvicorn]
extras = [ "standard" ]
version = "^0.29.0"
[tool.poetry.dependencies.llama-index-vector-stores-postgres]
version = "^0.1.1"
[tool.poetry.dependencies.llama-index-vector-stores-pinecone]
version = "^0.1.3"
[tool.poetry.dependencies.docx2txt]
version = "^0.8"
[build-system]
requires = [ "poetry-core" ]
build-backend = "poetry.core.masonry.api"
Trình quản lý gói hàng
Sử dụng poetry, nhưng poetry install luôn luôn sử dụng môi trường ảo của poetry, dễ gặp vấn đề.
Sử dụng pip để cài đặt sẽ không có lỗi.
pip install .
Tạo ra một chỉ mục
python app/engine/generate.py
Lỗi khi sử dụng text-embedding-3-large.
File "/Users/yanghaibin/anaconda3/envs/LI311-b/lib/python3.11/site-packages/pgvector/utils/__init__.py", line 35, in to_db
raise ValueError('expected %d dimensions, not %d' % (dim, len(value)))
sqlalchemy.exc.StatementError: (builtins.ValueError) expected 1536 dimensions, not 3072
Thay đổi môi trường sẽ không được cập nhật và cần mở một cửa sổ dòng lệnh mới.
triển khai đến Render
Biên dịch giữ mặc định: poetry install
Chạy: python www.example.com
Ví dụ về dự án - Đọc: Python - FastAPI
Thư mục mã nguồn
Cần thay đổi media_type="text/plain" thành text/event-stream
, nhưng với Postman, tôi thấy có vấn đề
return StreamingResponse(event_generator(), media_type="text/plain")