├── .dockerignore ├── .env-example ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── dependabot.yml ├── pull_request_template.md └── workflows │ ├── bumpver.yml │ └── docker-hub.yml ├── .gitignore ├── .pre-commit-config.yaml ├── Dockerfile ├── LICENSE ├── README.md ├── bumpver.toml ├── docker-compose.yml ├── kubernetes └── resources.yaml ├── requirements.txt └── server.py /.dockerignore: -------------------------------------------------------------------------------- 1 | .env 2 | .env-example 3 | .git/ 4 | .github 5 | .gitignore 6 | .idea 7 | .mypy_cache 8 | .pre-commit-config.yaml 9 | .ruff_cache 10 | Dockerfile 11 | kubernetes 12 | docker-compose.yml 13 | junk/ 14 | kubernetes/ 15 | -------------------------------------------------------------------------------- /.env-example: -------------------------------------------------------------------------------- 1 | OPENAI_API_KEY=sk-... 2 | 3 | TAVILY_API_KEY=tvly-... 4 | 5 | LANGCHAIN_API_KEY=ls__... 6 | LANGCHAIN_ENDPOINT=https://api.smith.langchain.com 7 | LANGCHAIN_TRACING_V2=true 8 | LANGCHAIN_PROJECT="langchain-research-assistant-docker" 9 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the solution you'd like** 11 | A clear and concise description of what you want to happen. 12 | 13 | **Describe alternatives you've considered** 14 | A clear and concise description of any alternative solutions or features you've considered. 15 | 16 | **Additional context** 17 | Add any other context or screenshots about the feature request here. 18 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "pip" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "weekly" 12 | groups: 13 | app: 14 | patterns: 15 | - "*" 16 | exclude-patterns: 17 | - "pydantic" 18 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | Thank you for contributing! 2 | Before submitting this PR, please make sure: 3 | 4 | - [ ] Your code builds clean without any errors or warnings 5 | - [ ] Your code doesn't break anything we can't fix 6 | - [ ] You have added appropriate tests 7 | 8 | Please check one or more of the following to describe the nature of this PR: 9 | - [ ] New feature 10 | - [ ] Bug fix 11 | - [ ] Documentation 12 | - [ ] Other 13 | -------------------------------------------------------------------------------- /.github/workflows/bumpver.yml: -------------------------------------------------------------------------------- 1 | name: Bump Version 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | bump: 7 | type: choice 8 | description: 'Bump major, minor, or patch version' 9 | required: true 10 | default: 'patch' 11 | options: 12 | - 'major' 13 | - 'minor' 14 | - 'patch' 15 | 16 | jobs: 17 | bump-version: 18 | runs-on: ubuntu-latest 19 | permissions: 20 | contents: write 21 | steps: 22 | - name: Checkout code 23 | uses: actions/checkout@v4 24 | with: 25 | token: ${{ secrets.WORKFLOW_GIT_ACCESS_TOKEN }} 26 | fetch-depth: 0 27 | - name: Set up Python 28 | uses: actions/setup-python@v4 29 | with: 30 | python-version: 3.11 31 | cache: pip 32 | - name: Install Python libraries 33 | run: | 34 | pip install --user bumpver 35 | - name: git config 36 | run: | 37 | git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" 38 | git config --local user.name "github-actions[bot]" 39 | - name: Bump version 40 | run: bumpver update --commit --tag-commit --${{ github.event.inputs.bump }} --push 41 | -------------------------------------------------------------------------------- /.github/workflows/docker-hub.yml: -------------------------------------------------------------------------------- 1 | name: Push to Docker Hub 2 | 3 | on: 4 | push: 5 | tags: 6 | - '*.*.*' 7 | 8 | jobs: 9 | build-and-push-docker: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v2 13 | with: 14 | fetch-depth: 0 15 | token: ${{ secrets.WORKFLOW_GIT_ACCESS_TOKEN }} 16 | 17 | - name: Log in to Docker Hub 18 | uses: docker/login-action@v1 19 | with: 20 | username: joshuasundance 21 | password: ${{ secrets.DOCKERHUB_TOKEN }} 22 | 23 | - name: Build Docker image 24 | run: | 25 | docker build \ 26 | -t joshuasundance/langchain-research-assistant-docker:${{ github.ref_name }} \ 27 | -t joshuasundance/langchain-research-assistant-docker:latest \ 28 | . 29 | 30 | - name: Push to Docker Hub 31 | run: docker push -a joshuasundance/langchain-research-assistant-docker 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *$py.class 2 | *.chainlit 3 | *.chroma 4 | *.cover 5 | *.egg 6 | *.egg-info/ 7 | *.env 8 | *.langchain.db 9 | *.log 10 | *.manifest 11 | *.mo 12 | *.pot 13 | *.py,cover 14 | *.py[cod] 15 | *.sage.py 16 | *.so 17 | *.spec 18 | .DS_STORE 19 | .Python 20 | .cache 21 | .coverage 22 | .coverage.* 23 | .dmypy.json 24 | .eggs/ 25 | .env 26 | .hypothesis/ 27 | .idea 28 | .installed.cfg 29 | .ipynb_checkpoints 30 | .mypy_cache/ 31 | .nox/ 32 | .pyre/ 33 | .pytest_cache/ 34 | .python-version 35 | .ropeproject 36 | .ruff_cache/ 37 | .scrapy 38 | .spyderproject 39 | .spyproject 40 | .tox/ 41 | .venv 42 | .vscode 43 | .webassets-cache 44 | /site 45 | ENV/ 46 | MANIFEST 47 | __pycache__ 48 | __pycache__/ 49 | __pypackages__/ 50 | build/ 51 | celerybeat-schedule 52 | celerybeat.pid 53 | coverage.xml 54 | credentials.json 55 | data/ 56 | db.sqlite3 57 | db.sqlite3-journal 58 | develop-eggs/ 59 | dist/ 60 | dmypy.json 61 | docs/_build/ 62 | downloads/ 63 | eggs/ 64 | env.bak/ 65 | env/ 66 | fly.toml 67 | htmlcov/ 68 | instance/ 69 | ipython_config.py 70 | junk/ 71 | lib/ 72 | lib64/ 73 | local_settings.py 74 | models/*.bin 75 | nosetests.xml 76 | lab/scratch/ 77 | lab/ 78 | parts/ 79 | pip-delete-this-directory.txt 80 | pip-log.txt 81 | pip-wheel-metadata/ 82 | profile_default/ 83 | sdist/ 84 | share/python-wheels/ 85 | storage 86 | target/ 87 | token.json 88 | var/ 89 | venv 90 | venv.bak/ 91 | venv/ 92 | wheels/ 93 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # Don't know what this file is? See https://pre-commit.com/ 2 | # pip install pre-commit 3 | # pre-commit install 4 | # pre-commit autoupdate 5 | # Apply to all files without commiting: 6 | # pre-commit run --all-files 7 | # I recommend running this until you pass all checks, and then commit. 8 | # Fix what you need to and then let the pre-commit hooks resolve their conflicts. 9 | # You may need to git add -u between runs. 10 | exclude: "AI_CHANGELOG.md" 11 | repos: 12 | - repo: https://github.com/charliermarsh/ruff-pre-commit 13 | rev: "v0.1.6" 14 | hooks: 15 | - id: ruff 16 | args: [--fix, --exit-non-zero-on-fix, --ignore, E501] 17 | - repo: https://github.com/koalaman/shellcheck-precommit 18 | rev: v0.9.0 19 | hooks: 20 | - id: shellcheck 21 | - repo: https://github.com/pre-commit/pre-commit-hooks 22 | rev: v4.5.0 23 | hooks: 24 | - id: check-ast 25 | - id: check-builtin-literals 26 | - id: check-merge-conflict 27 | - id: check-symlinks 28 | - id: check-toml 29 | - id: check-xml 30 | - id: debug-statements 31 | - id: check-case-conflict 32 | - id: check-docstring-first 33 | - id: check-executables-have-shebangs 34 | - id: check-json 35 | # - id: check-yaml 36 | - id: debug-statements 37 | - id: fix-byte-order-marker 38 | - id: detect-private-key 39 | - id: end-of-file-fixer 40 | - id: trailing-whitespace 41 | - id: mixed-line-ending 42 | - id: requirements-txt-fixer 43 | - repo: https://github.com/pre-commit/mirrors-mypy 44 | rev: v1.7.1 45 | hooks: 46 | - id: mypy 47 | - repo: https://github.com/asottile/add-trailing-comma 48 | rev: v3.1.0 49 | hooks: 50 | - id: add-trailing-comma 51 | #- repo: https://github.com/dannysepler/rm_unneeded_f_str 52 | # rev: v0.2.0 53 | # hooks: 54 | # - id: rm-unneeded-f-str 55 | - repo: https://github.com/psf/black 56 | rev: 23.11.0 57 | hooks: 58 | - id: black 59 | - repo: https://github.com/PyCQA/bandit 60 | rev: 1.7.5 61 | hooks: 62 | - id: bandit 63 | args: ["-x", "tests/*.py"] 64 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.11-slim-bookworm 2 | 3 | RUN apt-get update && apt-get install -y git && apt-get clean && rm -rf /var/lib/apt/lists/* 4 | 5 | RUN adduser --uid 1000 --disabled-password --gecos '' appuser 6 | USER 1000 7 | 8 | ENV PYTHONDONTWRITEBYTECODE=1 \ 9 | PYTHONUNBUFFERED=1 \ 10 | PATH="/home/appuser/.local/bin:$PATH" \ 11 | PYTHONPATH="/home/appuser/research-assistant/packages/research-assistant:$PYTHONPATH" 12 | 13 | RUN pip install --user --no-cache-dir --upgrade pip 14 | 15 | COPY ./requirements.txt /home/appuser/requirements.txt 16 | RUN pip install --user --no-cache-dir --upgrade -r /home/appuser/requirements.txt 17 | 18 | WORKDIR /home/appuser 19 | 20 | RUN langchain app new research-assistant --package research-assistant --pip 21 | 22 | COPY ./server.py /home/appuser/research-assistant/app/server.py 23 | 24 | WORKDIR /home/appuser/research-assistant 25 | 26 | EXPOSE 8000 27 | 28 | CMD ["langchain", "serve", "--host", "0.0.0.0", "--port", "8000"] 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Joshua Sundance Bailey 4 | 5 | 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: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | 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. 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # langchain-research-assistant-docker 2 | 3 | [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) 4 | [![python](https://img.shields.io/badge/Python-3.11-3776AB.svg?style=flat&logo=python&logoColor=white)](https://www.python.org) 5 | 6 | [![Push to Docker Hub](https://github.com/joshuasundance-swca/langchain-research-assistant-docker/actions/workflows/docker-hub.yml/badge.svg)](https://github.com/joshuasundance-swca/langchain-research-assistant-docker/actions/workflows/docker-hub.yml) 7 | [![langchain-research-assistant-docker on Docker Hub](https://img.shields.io/docker/v/joshuasundance/langchain-research-assistant-docker?label=langchain-research-assistant-docker&logo=docker)](https://hub.docker.com/r/joshuasundance/langchain-research-assistant-docker) 8 | [![Docker Image Size (tag)](https://img.shields.io/docker/image-size/joshuasundance/langchain-research-assistant-docker/latest)](https://hub.docker.com/r/joshuasundance/langchain-research-assistant-docker) 9 | 10 | [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit) 11 | [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v1.json)](https://github.com/charliermarsh/ruff) 12 | [![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/) 13 | [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) 14 | 15 | [![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit) 16 | ![Known Vulnerabilities](https://snyk.io/test/github/joshuasundance-swca/langchain-research-assistant-docker/badge.svg) 17 | 18 | This repo provides a docker setup to run the LangChain research-assistant template using langserve. 19 | 20 | - [Relevant LangChain documentation](https://python.langchain.com/docs/templates/research-assistant) 21 | 22 | 23 | - Example LangSmith traces 24 | - [_What is the average territory size of the Florida Scrub-Jay in Central Florida?_](https://smith.langchain.com/public/cf52fc9f-5800-4279-b61b-e15221d3a5e3/r) 25 | - [_Does SWCA Environmental Consultants use AI and data science?_](https://smith.langchain.com/public/fcae93da-b87e-49a6-992c-d5034bcf82e8/r) 26 | - [_Write a comprehensive report on the history of Chuluota, Florida._](https://smith.langchain.com/public/16d1b9e8-8e01-458e-98d6-64e93c916941/r) 27 | 28 | ## Quickstart 29 | 30 | ### Using Docker 31 | ```bash 32 | docker run -d --name langchain-research-assistant-docker \ 33 | -e OPENAI_API_KEY=sk-... \ 34 | -e TAVILY_API_KEY=tvly-... \ 35 | -e LANGCHAIN_API_KEY=ls__... \ 36 | -e LANGCHAIN_TRACING_V2=true \ 37 | -e LANGCHAIN_PROJECT=langchain-research-assistant-docker \ 38 | -p 8000:8000 \ 39 | joshuasundance/langchain-research-assistant-docker:latest 40 | ``` 41 | 42 | ### Using Docker Compose 43 | ```docker-compose.yml 44 | version: '3.8' 45 | 46 | services: 47 | langchain-research-assistant-docker: 48 | image: joshuasundance/langchain-research-assistant-docker:latest 49 | container_name: langchain-research-assistant-docker 50 | environment: # use values from .env 51 | - "OPENAI_API_KEY=${OPENAI_API_KEY:?OPENAI_API_KEY is not set}" # required 52 | - "TAVILY_API_KEY=${TAVILY_API_KEY}" # optional 53 | - "LANGCHAIN_API_KEY=${LANGCHAIN_API_KEY}" # optional 54 | - "LANGCHAIN_TRACING_V2=${LANGCHAIN_TRACING_V2:-false}" # false by default 55 | - "LANGCHAIN_PROJECT=${LANGCHAIN_PROJECT:-langchain-research-assistant-docker}" 56 | ports: 57 | - "${APP_PORT:-8000}:8000" 58 | ``` 59 | 60 | ### Kubernetes 61 | 62 | The following assumes you have a `.env` file and a Kubernetes cluster running and `kubectl` configured to access it. 63 | 64 | It creates a secret called `research-assistant-secret`. To use a different name, edit `./kubernetes/resources.yaml` as well. 65 | 66 | You can also edit the file and uncomment certain lines to deploy on private endpoints, with a predefined IP, etc. 67 | 68 | ```bash 69 | kubectl create secret generic research-assistant-secret --from-env-file=.env 70 | kubectl apply -f ./kubernetes/resources.yaml 71 | ``` 72 | 73 | All deployment options are flexible and configurable. 74 | 75 | 76 | ## Usage 77 | 78 | - The service will be available at `http://localhost:8000`. 79 | - You can access the OpenAPI documentation at `http://localhost:8000/docs` and `http://localhost:8000/openapi.json`. 80 | - Access the Research Playground at `http://127.0.0.1:8000/research-assistant/playground/`. 81 | 82 | - You can also use the `RemoteRunnable` class to interact with the service: 83 | 84 | ```python 85 | from langserve.client import RemoteRunnable 86 | 87 | runnable = RemoteRunnable("http://localhost:8000/research-assistant") 88 | ``` 89 | 90 | See the [LangChain docs](https://python.langchain.com/docs/templates/research-assistant) for more information. 91 | -------------------------------------------------------------------------------- /bumpver.toml: -------------------------------------------------------------------------------- 1 | [bumpver] 2 | current_version = "1.1.4" 3 | version_pattern = "MAJOR.MINOR.PATCH" 4 | commit_message = "bump version {old_version} -> {new_version}" 5 | tag_message = "{new_version}" 6 | tag_scope = "default" 7 | pre_commit_hook = "" 8 | post_commit_hook = "" 9 | commit = true 10 | tag = true 11 | push = true 12 | 13 | [bumpver.file_patterns] 14 | "bumpver.toml" = [ 15 | 'current_version = "{version}"', 16 | ] 17 | "kubernetes/resources.yaml" = [' image: joshuasundance/langchain-research-assistant-docker:{version}'] 18 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.8' 2 | 3 | services: 4 | langchain-research-assistant-docker: 5 | build: 6 | context: . 7 | dockerfile: Dockerfile 8 | container_name: langchain-research-assistant-docker 9 | environment: # use values from .env 10 | - "OPENAI_API_KEY=${OPENAI_API_KEY:?OPENAI_API_KEY is not set}" # required 11 | - "TAVILY_API_KEY=${TAVILY_API_KEY}" # optional 12 | - "LANGCHAIN_API_KEY=${LANGCHAIN_API_KEY}" # optional 13 | - "LANGCHAIN_TRACING_V2=${LANGCHAIN_TRACING_V2:-false}" # false by default 14 | - "LANGCHAIN_PROJECT=${LANGCHAIN_PROJECT:-langchain-research-assistant-docker}" 15 | ports: 16 | - "${APP_PORT:-8000}:8000" 17 | -------------------------------------------------------------------------------- /kubernetes/resources.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: langchain-research-assistant-docker-deployment 5 | spec: 6 | replicas: 1 7 | selector: 8 | matchLabels: 9 | app: langchain-research-assistant-docker 10 | template: 11 | metadata: 12 | labels: 13 | app: langchain-research-assistant-docker 14 | spec: 15 | containers: 16 | - name: langchain-research-assistant-docker 17 | image: joshuasundance/langchain-research-assistant-docker:1.1.4 18 | imagePullPolicy: Always 19 | resources: 20 | requests: 21 | cpu: "100m" 22 | memory: "200Mi" 23 | limits: 24 | cpu: "500m" 25 | memory: "500Mi" 26 | env: 27 | - name: OPENAI_API_KEY 28 | valueFrom: 29 | secretKeyRef: 30 | name: research-assistant-secret 31 | key: OPENAI_API_KEY 32 | - name: TAVILY_API_KEY 33 | valueFrom: 34 | secretKeyRef: 35 | name: research-assistant-secret 36 | key: TAVILY_API_KEY 37 | - name: LANGCHAIN_API_KEY 38 | valueFrom: 39 | secretKeyRef: 40 | name: research-assistant-secret 41 | key: LANGCHAIN_API_KEY 42 | - name: LANGCHAIN_TRACING_V2 43 | value: "true" 44 | - name: LANGCHAIN_PROJECT 45 | value: "langchain-research-assistant-docker" 46 | securityContext: 47 | runAsNonRoot: true 48 | --- 49 | apiVersion: v1 50 | kind: Service 51 | metadata: 52 | name: langchain-research-assistant-docker-service 53 | # configure on Azure and uncomment below to use a vnet 54 | # annotations: 55 | # service.beta.kubernetes.io/azure-load-balancer-internal: "true" 56 | # service.beta.kubernetes.io/azure-load-balancer-ipv4: vnet.ip.goes.here 57 | # service.beta.kubernetes.io/azure-dns-label-name: "langchain-research-assistant-docker" 58 | spec: 59 | selector: 60 | app: langchain-research-assistant-docker 61 | ports: 62 | - protocol: TCP 63 | port: 80 64 | targetPort: 8000 65 | type: LoadBalancer 66 | --- 67 | apiVersion: networking.k8s.io/v1 68 | kind: NetworkPolicy 69 | metadata: 70 | name: langchain-research-assistant-docker-network-policy 71 | spec: 72 | podSelector: 73 | matchLabels: 74 | app: langchain-research-assistant-docker 75 | policyTypes: 76 | - Ingress 77 | ingress: 78 | - from: [] # An empty array here means it will allow traffic from all sources. 79 | ports: 80 | - protocol: TCP 81 | port: 8000 82 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | beautifulsoup4==4.12.3 2 | duckduckgo-search==5.3.0 3 | langchain==0.1.16 4 | langchain-cli==0.0.21 5 | langchain-core==0.1.42 6 | langchainhub==0.1.15 7 | langserve==0.0.51 8 | langsmith==0.1.47 9 | openai==1.17.1 10 | pydantic<2 11 | tavily-python==0.3.3 12 | -------------------------------------------------------------------------------- /server.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI 2 | from fastapi.responses import RedirectResponse 3 | from langserve import add_routes 4 | from research_assistant import chain as research_assistant_chain 5 | 6 | app = FastAPI( 7 | title="LangChain Research Assistant", 8 | ) 9 | 10 | 11 | @app.get("/") 12 | async def redirect_root_to_docs(): 13 | return RedirectResponse("/docs") 14 | 15 | 16 | add_routes(app, research_assistant_chain, path="/research-assistant") 17 | 18 | if __name__ == "__main__": 19 | import uvicorn 20 | 21 | uvicorn.run(app, host="0.0.0.0", port=8000) # nosec 22 | --------------------------------------------------------------------------------