29
29
30
30
31
31
from common import get_answer_with_settings_with_weaviate_filter
32
+ from config import WeaviateSettings
32
33
33
34
SYSTEM_PROMPT_DEFAULT = """You are a specialized support ticket assistant. Format your responses following these rules:
34
35
1. Answer the provided question only using the provided context.
@@ -47,31 +48,29 @@ def setup(
47
48
model_id : str ,
48
49
max_tokens : int ,
49
50
model_temperature : float ,
50
- weaviate_url : str ,
51
- weaviate_grpc_url : str ,
52
- weaviate_index : str ,
53
51
embedding_model_name : str ,
54
52
sql_search_db_and_model_path : str ,
55
- alpha : float ,
56
53
max_context_length : int ,
57
54
sql_ticket_source : str ,
58
55
):
59
56
app = FastAPI ()
60
57
58
+ weaviate_settings = WeaviateSettings ()
59
+
61
60
embeddings = HuggingFaceEmbeddings (model_name = embedding_model_name )
62
61
63
62
weaviate_client = weaviate .connect_to_custom (
64
- http_host = weaviate_url . split ( ":" )[ 0 ] ,
65
- http_port = int ( weaviate_url . split ( ":" )[ 1 ] ),
63
+ http_host = weaviate_settings . get_weaviate_uri () ,
64
+ http_port = weaviate_settings . get_weaviate_port ( ),
66
65
http_secure = False ,
67
- grpc_host = weaviate_grpc_url . split ( ":" )[ 0 ] ,
68
- grpc_port = int ( weaviate_grpc_url . split ( ":" )[ 1 ] ),
66
+ grpc_host = weaviate_settings . get_weaviate_grpc_uri () ,
67
+ grpc_port = weaviate_settings . get_weaviate_grpc_port ( ),
69
68
grpc_secure = False ,
70
69
)
71
70
72
71
vectorstore = WeaviateVectorStore (
73
72
client = weaviate_client ,
74
- index_name = weaviate_index ,
73
+ index_name = weaviate_settings . weaviate_index_name ,
75
74
text_key = "text" ,
76
75
embedding = embeddings ,
77
76
)
@@ -98,7 +97,7 @@ def setup(
98
97
relevant_docs = relevant_docs ,
99
98
llm_server_url = llm_server_url ,
100
99
sql_search_db_and_model_path = sql_search_db_and_model_path ,
101
- alpha = alpha ,
100
+ alpha = weaviate_settings . weaviate_hybrid_search_alpha ,
102
101
max_context_length = max_context_length ,
103
102
sql_ticket_source = sql_ticket_source ,
104
103
)
@@ -161,12 +160,8 @@ def read_item(question: Union[str, None] = None):
161
160
model_id ,
162
161
max_tokens ,
163
162
model_temperature ,
164
- weaviate_url ,
165
- weaviate_grpc_url ,
166
- weaviate_index ,
167
163
embedding_model_name ,
168
164
sql_search_db_and_model_path ,
169
- alpha ,
170
165
max_context_length ,
171
166
sql_ticket_source ,
172
167
)
0 commit comments