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 chat with history + additional functionality#1047

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 14 commits intomasterfromsanti-pgml-chat-multi-turn
Oct 24, 2023

Conversation

santiatpml
Copy link
Contributor

  • Chat history in a separate collection
  • Keeps track of users, conversations, and interfaces
  • Prompt engineering on system and base prompts to follow specific instructions
  • Options for language, personality, programming language etc.

@@ -11,14 +11,21 @@ packages = [{include = "pgml_chat"}]
python = ">=3.8,<4.0"
openai = "^0.27.8"
rich = "^13.4.2"
pgml ="^0.9.0"
pgml ={version = "0.9.4", source = "testpypi"}
Copy link
Contributor

Choose a reason for hiding this comment

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

should we wait for a release?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I'm planning to push pgml-chat to pypi after pgml 0.9.4 is released to pypi. In the meantime, want to update master.

#.idea/

pgml_chat/pgml_playground.py
Copy link
Contributor

Choose a reason for hiding this comment

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

Now I'm curious what's in here.

santiatpml reacted with laugh emoji
messages = []
messages.append({"role": "system", "content": system_prompt})

chat_history_messages = await chat_collection.get_documents( {
Copy link
Contributor

Choose a reason for hiding this comment

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

An implementation more inline with the thesis would combine the first call with this call in a CTE, and follow up with the next call all in 1.

santiatpml reacted with thumbs up emoji
async def generate_response(
messages, openai_api_key, temperature=0.7, max_tokens=256, top_p=0.9
):
openai.api_key = openai_api_key
log.debug("Generating response from OpenAI API: " + str(messages))
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
# model="gpt-3.5-turbo-16k",
model="gpt-4",
Copy link
Contributor

Choose a reason for hiding this comment

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

Who's paying for this?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

OPENAI_API_KEY is an environment variable. User pays for it.

WHERE metadata @> '{\"interface\" : \"cli\"}'::JSONB
AND metadata @> '{\"role\" : \"user\"}'::JSONB
OR metadata @> '{\"role\" : \"assistant\"}'::JSONB
ORDER BY metadata->>'timestamp' DESC LIMIT %d""" % (
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the timestamp in the metadata, instead of a field on the record?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

We have a field on the record. I insert user message and the response together and each of them will have different timestamps. I could also order by the field on the record.

@@ -0,0 +1,114 @@
from pgml import Collection, Builtins, Pipeline
Copy link
Contributor

Choose a reason for hiding this comment

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

I see what's in the playground now 👀

@santiatpmlsantiatpml merged commitdcbc7d4 intomasterOct 24, 2023
@santiatpmlsantiatpml deleted the santi-pgml-chat-multi-turn branchOctober 24, 2023 19:09
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@montanalowmontanalowmontanalow left review comments

@SilasMarvinSilasMarvinAwaiting requested review from SilasMarvin

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@santiatpml@montanalow@santiadavani

[8]ページ先頭

©2009-2025 Movatter.jp