Giter Site home page Giter Site logo

demo-streamlit-langchain's Introduction

demo-streamlit-langchain

LangChain を Streamlit 上で動かすデモアプリ

Deploy

Running Locally

1. Clone Repo

git clone # FIXME

2. Install Dependencies

poetry install

3. Provide OpenAI API Key

Create a .env.local file in the root of the repo with Env:

OPENAI_API_KEY=""
# ..snip..

4. Run App

poetry shell
streamlit run home.py

5. Use It

You should be able to start chatting.

Running Cloud Run

1. Clone Repo

git clone # FIXME

2. Install Dependencies

poetry install

3. Prepare Google Cloud

Authenticate and switch projects.

gcloud auth login
gcloud projects list
gcloud config set project <your-project-id>

Enable Services.

gcloud services enable compute.googleapis.com run.googleapis.com \
    artifactregistry.googleapis.com cloudbuild.googleapis.com secretmanager.googleapis.com

4. Set Secrets

Create secrets and add their values.

# シークレット作成
gcloud secrets create OPENAI_API_KEY --replication-policy="automatic"

# 値を設定
echo -n "sk-xxx" | gcloud secrets versions add OPENAI_API_KEY --data-file=-

# Service account を確認
gcloud run services describe demo-streamlit-langchain --platform managed --region asia-northeast1

# Cloud Run にシークレットへのアクセスを許可する。SERVICE_ACCOUNT_EMAIL は上記で確認した Service account に置き換え。
gcloud secrets add-iam-policy-binding OPENAI_API_KEY \
  --member='serviceAccount:SERVICE_ACCOUNT_EMAIL' \
  --role='roles/secretmanager.secretAccessor'

# 必要に応じて他のシークレットも同様に設定

5. Run App

Deploy.

gcloud run deploy demo-streamlit-langchain --region "asia-northeast1" --source . \
    --allow-unauthenticated --quiet --update-secrets=OPENAI_API_KEY=OPENAI_API_KEY:latest

refs: https://zenn.dev/google_cloud_jp/articles/streamlit-01-hello

参考

認証機能が提供されていないので、デプロイする際は、デプロイ先のセキュリティサービス or サードパーティのモジュールを利用推奨。

demo-streamlit-langchain's People

Contributors

takaakikakei avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.