File tree Expand file tree Collapse file tree 3 files changed +11
-21
lines changed
Expand file tree Collapse file tree 3 files changed +11
-21
lines changed Original file line number Diff line number Diff line change 66from langchain .embeddings .huggingface import HuggingFaceEmbeddings
77from pgvector .psycopg import register_vector
88
9- from app .config import DB_CONNECTION_STRING
10-
9+ import app .config
1110
1211def generate_response (
1312 llm ,
@@ -57,7 +56,7 @@ def __init__(
5756 self .assistant_content = assistant_content
5857
5958 # VectorDB connection
60- self .conn = psycopg .connect (DB_CONNECTION_STRING )
59+ self .conn = psycopg .connect (app . config . DB_CONNECTION_STRING )
6160 register_vector (self .conn )
6261
6362 def get_response (self , query ):
Original file line number Diff line number Diff line change 11# You can run the whole script locally with
2- # serve run serve:deployment
2+ # serve run app. serve:deployment
33
44import json
55import os
66
7+ import openai
78import ray
89import requests
910from fastapi import FastAPI
1718
1819
1920def get_secret (secret_name ):
20- aws_secret_id = os .environ .get ("RAY_ASSISTANT_AWS_SECRET_ID" )
21- if aws_secret_id :
22- import boto3
23- client = boto3 .client (
24- "secretsmanager" , region_name = os .environ ["RAY_ASSISTANT_AWS_REGION" ]
25- )
26- response = client .get_secret_value (SecretId = aws_secret_id )
27- return json .loads (response ["SecretString" ])[secret_name ]
28- else :
29- raise NotImplemented (
30- "Currently only AWS is supported "
31- "and you need to set RAY_ASSISTANT_AWS_SECRET_ID" )
21+ import boto3
22+ client = boto3 .client ("secretsmanager" , region_name = "us-west-2" )
23+ response = client .get_secret_value (SecretId = "ray-assistant" )
24+ return json .loads (response ["SecretString" ])[secret_name ]
3225
3326
3427application = FastAPI ()
@@ -69,6 +62,8 @@ class Answer(BaseModel):
6962class RayAssistantDeployment :
7063 def __init__ (self ):
7164 app .config .DB_CONNECTION_STRING = get_secret ("DB_CONNECTION_STRING" )
65+ openai .api_key = get_secret ("OPENAI_API_KEY" )
66+ openai .api_base = "https://api.endpoints.anyscale.com/v1"
7267 self .agent = query .QueryAgent (
7368 llm = "meta-llama/Llama-2-70b-chat-hf" ,
7469 max_context_length = 4096 ,
Original file line number Diff line number Diff line change @@ -3,8 +3,4 @@ cluster_env: ray-assistant:2
33ray_serve_config :
44 import_path : app.serve:deployment
55 runtime_env :
6- working_dir : " https://github.com/ray-project/llm-applications/archive/refs/tags/v0.0.5.zip"
7- env_vars : {
8- RAY_ASSISTANT_AWS_SECRET_ID : " ray-assistant" ,
9- RAY_ASSISTANT_AWS_REGION : " us-west-2"
10- }
6+ working_dir : " https://github.com/ray-project/llm-applications/archive/refs/tags/v0.0.6.zip"
You can’t perform that action at this time.
0 commit comments