Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): More AWEL operators and new prompt manager API #972

Merged
merged 4 commits into from
Dec 25, 2023

Conversation

fangyinc
Copy link
Collaborator

  • New prompt manager API (Use it in SDK or app)
  • AWEL Support streaming response or no streaming with LLMBranchOperator
  • New ConversationOperator to save or load conversation in storage
  • New BufferedConversationMapperOperator to handle multiple rounds of conversation

@github-actions github-actions bot added core Module: core enhancement New feature or request labels Dec 25, 2023
@fangyinc
Copy link
Collaborator Author

Now we can run AWEL file in dev mode.

python examples/awel/simple_chat_history_example.py

Output:

INFO:     Started server process [9412]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:5555 (Press CTRL+C to quit)

Then send request to dev server,

DBGPT_SERVER="http://127.0.0.1:5555"

curl -X POST $DBGPT_SERVER/api/v1/awel/trigger/examples/simple_history/multi_round/chat/completions \
            -H "Content-Type: application/json" -d '{
                "model": "gpt-3.5-turbo",
                "context": {
                    "conv_uid": "uuid_conv_1234"
                },                
                "messages": "Who is elon musk?"
            }'

@csunny
Copy link
Collaborator

csunny commented Dec 25, 2023

uk_prompt_name_sys_code UNIQUE KEY too long. Maybe it's better prompt_name set 256? and prompt_language set to 10?

sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (1071, 'Specified key was too long; max key length is 3072 bytes')
[SQL: ALTER TABLE prompt_manage ADD CONSTRAINT uk_prompt_name_sys_code UNIQUE (prompt_name, sys_code, prompt_language, model)]
(Background on this error at: https://sqlalche.me/e/20/e3q8)

@fangyinc
Copy link
Collaborator Author

uk_prompt_name_sys_code UNIQUE KEY too long. Maybe it's better prompt_name set 256? and prompt_language set to 10?

sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (1071, 'Specified key was too long; max key length is 3072 bytes')
[SQL: ALTER TABLE prompt_manage ADD CONSTRAINT uk_prompt_name_sys_code UNIQUE (prompt_name, sys_code, prompt_language, model)]
(Background on this error at: https://sqlalche.me/e/20/e3q8)

It has been fix in lastest code.

@csunny
Copy link
Collaborator

csunny commented Dec 25, 2023

According to our idea, it is better not to have particularly long names for prompt_name and model_name.

  • Recommended prompt_name to be less than 256 bytes
  • Recommended model_name to be less than 128 bytes

uk_prompt_name_sys_code varchar length set to 256 + 128 + 32 + 128
@fangyinc How about this?

@fangyinc
Copy link
Collaborator Author

According to our idea, it is better not to have particularly long names for prompt_name and model_name.

  • Recommended prompt_name to be less than 256 bytes
  • Recommended model_name to be less than 128 bytes

uk_prompt_name_sys_code varchar length set to 256 + 128 + 32 + 128 @fangyinc How about this?

Good advice, done.

Copy link
Collaborator

@csunny csunny left a comment

Choose a reason for hiding this comment

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

Awesome AWEL(Agentic Workflow Expression Language) is all you need. LGTM

@csunny
Copy link
Collaborator

csunny commented Dec 25, 2023

How Can I fix this? use export command to set environment variables? can you give some commands?

{"text":"**LLMServer Generate Error, Please CheckErrorInfo.**: base_url is required, please set OPENAI_BASE_URL environment","error_code":1,"model_context":null,"finish_reason":null,"usage":null,"metrics":null}%

@fangyinc
Copy link
Collaborator Author

How Can I fix this? use export command to set environment variables? can you give some commands?

{"text":"**LLMServer Generate Error, Please CheckErrorInfo.**: base_url is required, please set OPENAI_BASE_URL environment","error_code":1,"model_context":null,"finish_reason":null,"usage":null,"metrics":null}%

Yes, if we run AWEL file in dev mode(default use chatgpt model), wo should set environment first.

export OPENAI_API_KEY=sxxxxxx
export OPENAI_API_BASE=https://api.openai.com/v1

@csunny
Copy link
Collaborator

csunny commented Dec 25, 2023

@fangyinc Great for that, now i know who is elon musk? 😂

export OPENAI_API_KEY=xxx
export OPENAI_API_BASE=https://api.openai.com/v1

python examples/awel/simple_chat_history_example.py 

curl -X POST http://127.0.0.1:5555/api/v1/awel/trigger/examples/simple_history/multi_round/chat/completions \
            -H "Content-Type: application/json" -d '{
                "model": "gpt-3.5-turbo",
                "context": {
                    "conv_uid": "uuid_conv_1234"
                },
                "messages": "Who is elon musk?"
            }'

image

Copy link
Collaborator

@Aries-ckt Aries-ckt left a comment

Choose a reason for hiding this comment

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

r+

@Aries-ckt Aries-ckt merged commit 69fb97e into eosphoros-ai:main Dec 25, 2023
3 checks passed
@fangyinc fangyinc deleted the sdk-dev branch December 25, 2023 13:43
fangyinc added a commit that referenced this pull request Dec 26, 2023
vshy108 pushed a commit to vshy108/DB-GPT that referenced this pull request Jan 18, 2024
Hopshine pushed a commit to Hopshine/DB-GPT that referenced this pull request Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Module: core enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants