update
This commit is contained in:
+6
-6
@@ -1,7 +1,7 @@
|
|||||||
module llmUtil
|
module llmUtil
|
||||||
|
|
||||||
export formatLLMtext, extractthink, checkAgentResponse_JSON, clean_json_response,
|
export formatLLMtext, extractthink, checkAgentResponse_JSON, clean_json_response,
|
||||||
extract_vector_metadata, generate_embedding_payloads, resolve_semantic_cluster,
|
extract_column_metadata, generate_embedding_payloads, resolve_semantic_cluster,
|
||||||
harvest_entity_catalog, resolve_entity
|
harvest_entity_catalog, resolve_entity
|
||||||
|
|
||||||
using UUIDs, JSON, Dates, DataFrames, StringDistances, Graphs, LibPQ
|
using UUIDs, JSON, Dates, DataFrames, StringDistances, Graphs, LibPQ
|
||||||
@@ -246,7 +246,7 @@ Returns a DataFrame designed for vector embedding generation.
|
|||||||
```julia
|
```julia
|
||||||
julia> using GeneralUtils
|
julia> using GeneralUtils
|
||||||
julia> pg_conn = "host=localhost port=5432 dbname=winedb user=admin password=secret"
|
julia> pg_conn = "host=localhost port=5432 dbname=winedb user=admin password=secret"
|
||||||
julia> df = GeneralUtils.extract_vector_metadata(pg_conn)
|
julia> df = GeneralUtils.extract_column_metadata(pg_conn)
|
||||||
DataFrame
|
DataFrame
|
||||||
6 rows × 7 columns
|
6 rows × 7 columns
|
||||||
table_name column_name data_type column_description is_primary_key is_foreign_key vector_id
|
table_name column_name data_type column_description is_primary_key is_foreign_key vector_id
|
||||||
@@ -259,7 +259,7 @@ products price numeric Product price false false
|
|||||||
products user_id integer Reference to user false true col_products_user_id
|
products user_id integer Reference to user false true col_products_user_id
|
||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
function extract_vector_metadata(pg_conn_str::String)::DataFrame
|
function extract_column_metadata(pg_conn_str::String)::DataFrame
|
||||||
conn = LibPQ.Connection(pg_conn_str)
|
conn = LibPQ.Connection(pg_conn_str)
|
||||||
|
|
||||||
# This direct SQL query pulls the column specifications along with column-level descriptions
|
# This direct SQL query pulls the column specifications along with column-level descriptions
|
||||||
@@ -309,12 +309,12 @@ end
|
|||||||
|
|
||||||
""" Generate embedding payloads from vector metadata DataFrame.
|
""" Generate embedding payloads from vector metadata DataFrame.
|
||||||
|
|
||||||
Transforms the metadata DataFrame from `extract_vector_metadata` into a vector of
|
Transforms the metadata DataFrame from `extract_column_metadata` into a vector of
|
||||||
dictionaries structured for vector embedding storage and retrieval.
|
dictionaries structured for vector embedding storage and retrieval.
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
- `df::DataFrame`
|
- `df::DataFrame`
|
||||||
A DataFrame with columns from `extract_vector_metadata`: `table_name`, `column_name`,
|
A DataFrame with columns from `extract_column_metadata`: `table_name`, `column_name`,
|
||||||
`data_type`, `column_description`, `is_primary_key`, `is_foreign_key`, `vector_id`.
|
`data_type`, `column_description`, `is_primary_key`, `is_foreign_key`, `vector_id`.
|
||||||
|
|
||||||
# Return
|
# Return
|
||||||
@@ -335,7 +335,7 @@ The function constructs rich text payloads by:
|
|||||||
```julia
|
```julia
|
||||||
julia> using GeneralUtils
|
julia> using GeneralUtils
|
||||||
julia> pg_conn = "host=localhost port=5432 dbname=winedb user=admin password=secret"
|
julia> pg_conn = "host=localhost port=5432 dbname=winedb user=admin password=secret"
|
||||||
julia> df = GeneralUtils.extract_vector_metadata(pg_conn)
|
julia> df = GeneralUtils.extract_column_metadata(pg_conn)
|
||||||
julia> payloads = GeneralUtils.generate_embedding_payloads(df)
|
julia> payloads = GeneralUtils.generate_embedding_payloads(df)
|
||||||
3-element Vector{Dict}:
|
3-element Vector{Dict}:
|
||||||
Dict("id" => "col_users_id", "text_content" => "Table: users | Column: id | Type: integer [PRIMARY KEY] | Description: User ID", "metadata" => Dict("table" => "users", "column" => "id", "type" => "integer"))
|
Dict("id" => "col_users_id", "text_content" => "Table: users | Column: id | Type: integer [PRIMARY KEY] | Description: User ID", "metadata" => Dict("table" => "users", "column" => "id", "type" => "integer"))
|
||||||
|
|||||||
Reference in New Issue
Block a user