Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

pgml sdk examples#669

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
santiatpml merged 7 commits intomasterfromsanti-pgml-sdk-examples
Jun 1, 2023
Merged

pgml sdk examples#669

santiatpml merged 7 commits intomasterfromsanti-pgml-sdk-examples
Jun 1, 2023

Conversation

@santiatpml
Copy link
Contributor

Details on exampleshere

Also added aroadmap section to main readme

self.pool.putconn(conn)

# Sort the list of dictionaries based on the 'score' key in descending order
search_results=sorted(search_results,key=lambdax:x['score'],reverse=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

That's already done in SQL above. Postgres is much better at sorting than Python.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I convert this to JSON using SQL that returns unsorted array. Is there a way to return a sorted dict using SQL?

SELECT array_to_json(array_agg(row_to_json(t)))FROM ({select_statement}) t;

Copy link
Contributor

@levkklevkkMay 31, 2023
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

 select array(select unnest(array[1.0, 2.0, 3.0]) order by 1 desc);

https://stackoverflow.com/questions/2913368/sorting-array-elements

santiatpml reacted with thumbs up emoji
context=" ".join(results[0]["chunk"].strip().split())
context=context.replace('"','\\"').replace("'","''")

select_statement="""SELECT pgml.transform(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think a great future iteration for thepgml.transform call, would be to havecollection.vector_search() return a query object rather than a result, and then pass that query object as "context" to a new python functionquestion_answering api. That API should then build the context as a sub-select inside the question-answering, so the documents never leave the database.

santiatpml reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Running the scripts by settingLOGLEVEL=INFO writes the query to the terminal. We could have adry_run option that outputs a query instead of result.

LOGLEVEL=INFO python examples/question_answering.py

@santiatpmlsantiatpml requested a review fromlevkkJune 1, 2023 18:19
@santiatpmlsantiatpml merged commite6a1619 intomasterJun 1, 2023
@santiatpmlsantiatpml deleted the santi-pgml-sdk-examples branchJune 1, 2023 18:55
SilasMarvin pushed a commit that referenced this pull requestOct 5, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@montanalowmontanalowmontanalow approved these changes

@SilasMarvinSilasMarvinAwaiting requested review from SilasMarvin

@levkklevkkAwaiting requested review from levkk

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@santiatpml@montanalow@levkk@santiadavani

[8]ページ先頭

©2009-2025 Movatter.jp