Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LlamaIndexTS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
run-llama
LlamaIndexTS
Commits
80f5914a
Commit
80f5914a
authored
1 year ago
by
Marcus Schiesser
Browse files
Options
Downloads
Patches
Plain Diff
fix: raise exception if PG_CONNECTION_STRING is empty (generated value)
parent
1c4e7f9c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/create-llama/templates/components/vectordbs/python/pg/utils.py
+8
-4
8 additions, 4 deletions
...e-llama/templates/components/vectordbs/python/pg/utils.py
with
8 additions
and
4 deletions
packages/create-llama/templates/components/vectordbs/python/pg/utils.py
+
8
−
4
View file @
80f5914a
...
@@ -6,18 +6,22 @@ from app.engine.constants import PGVECTOR_SCHEMA, PGVECTOR_TABLE
...
@@ -6,18 +6,22 @@ from app.engine.constants import PGVECTOR_SCHEMA, PGVECTOR_TABLE
def
init_pg_vector_store_from_env
():
def
init_pg_vector_store_from_env
():
original_conn_string
=
os
.
environ
.
get
(
"
PG_CONNECTION_STRING
"
)
original_conn_string
=
os
.
environ
.
get
(
"
PG_CONNECTION_STRING
"
)
if
original_conn_string
is
None
:
if
original_conn_string
is
None
or
original_conn_string
==
""
:
raise
ValueError
(
"
PG_CONNECTION_STRING environment variable is not set.
"
)
raise
ValueError
(
"
PG_CONNECTION_STRING environment variable is not set.
"
)
# The PGVectorStore requires both two connection strings, one for psycopg2 and one for asyncpg
# The PGVectorStore requires both two connection strings, one for psycopg2 and one for asyncpg
# Update the configured scheme with the psycopg2 and asyncpg schemes
# Update the configured scheme with the psycopg2 and asyncpg schemes
original_scheme
=
urlparse
(
original_conn_string
).
scheme
+
"
://
"
original_scheme
=
urlparse
(
original_conn_string
).
scheme
+
"
://
"
conn_string
=
original_conn_string
.
replace
(
original_scheme
,
"
postgresql+psycopg2://
"
)
conn_string
=
original_conn_string
.
replace
(
async_conn_string
=
original_conn_string
.
replace
(
original_scheme
,
"
postgresql+asyncpg://
"
)
original_scheme
,
"
postgresql+psycopg2://
"
)
async_conn_string
=
original_conn_string
.
replace
(
original_scheme
,
"
postgresql+asyncpg://
"
)
return
PGVectorStore
(
return
PGVectorStore
(
connection_string
=
conn_string
,
connection_string
=
conn_string
,
async_connection_string
=
async_conn_string
,
async_connection_string
=
async_conn_string
,
schema_name
=
PGVECTOR_SCHEMA
,
schema_name
=
PGVECTOR_SCHEMA
,
table_name
=
PGVECTOR_TABLE
table_name
=
PGVECTOR_TABLE
,
)
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment