File tree 3 files changed +11
-21
lines changed
3 files changed +11
-21
lines changed Original file line number Diff line number Diff line change 6
6
from langchain .embeddings .huggingface import HuggingFaceEmbeddings
7
7
from pgvector .psycopg import register_vector
8
8
9
- from app .config import DB_CONNECTION_STRING
10
-
9
+ import app .config
11
10
12
11
def generate_response (
13
12
llm ,
@@ -57,7 +56,7 @@ def __init__(
57
56
self .assistant_content = assistant_content
58
57
59
58
# VectorDB connection
60
- self .conn = psycopg .connect (DB_CONNECTION_STRING )
59
+ self .conn = psycopg .connect (app . config . DB_CONNECTION_STRING )
61
60
register_vector (self .conn )
62
61
63
62
def get_response (self , query ):
Original file line number Diff line number Diff line change 1
1
# You can run the whole script locally with
2
- # serve run serve:deployment
2
+ # serve run app. serve:deployment
3
3
4
4
import json
5
5
import os
6
6
7
+ import openai
7
8
import ray
8
9
import requests
9
10
from fastapi import FastAPI
17
18
18
19
19
20
def 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 ]
32
25
33
26
34
27
application = FastAPI ()
@@ -69,6 +62,8 @@ class Answer(BaseModel):
69
62
class RayAssistantDeployment :
70
63
def __init__ (self ):
71
64
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"
72
67
self .agent = query .QueryAgent (
73
68
llm = "meta-llama/Llama-2-70b-chat-hf" ,
74
69
max_context_length = 4096 ,
Original file line number Diff line number Diff line change @@ -3,8 +3,4 @@ cluster_env: ray-assistant:2
3
3
ray_serve_config :
4
4
import_path : app.serve:deployment
5
5
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