microsoft / promptflow

Build high-quality LLM apps - from prototyping, testing to production deployment and monitoring.
https://microsoft.github.io/promptflow/
MIT License
8.43k stars 725 forks source link

[prompty] Prompty supports to estimate token count #3210

Closed lalala123123 closed 3 weeks ago

lalala123123 commented 3 weeks ago

Description

Return value is the prompt token + max_response_token

prompty = Prompty.load(source=f"{PROMPTY_DIR}/prompty_example.prompty")
total_token = prompty.estimate_token_count(question="what is the result of 1+1?")

Please add an informative description that covers that changes made by the pull request and link all relevant issues.

All Promptflow Contribution checklist:

General Guidelines and Best Practices

Testing Guidelines

github-actions[bot] commented 3 weeks ago

SDK CLI Global Config Test Result zhrua/prompty_estimate_token

6 tests   6 :white_check_mark:  1m 15s :stopwatch: 1 suites  0 :zzz: 1 files    0 :x:

Results for commit c24753e2.

:recycle: This comment has been updated with latest results.

github-actions[bot] commented 3 weeks ago

promptflow SDK CLI Azure E2E Test Result zhrua/prompty_estimate_token

  4 files    4 suites   4m 15s :stopwatch: 241 tests 205 :white_check_mark:  36 :zzz: 0 :x: 964 runs  820 :white_check_mark: 144 :zzz: 0 :x:

Results for commit c24753e2.

:recycle: This comment has been updated with latest results.

github-actions[bot] commented 3 weeks ago

promptflow-core test result

0 tests   0 :white_check_mark:  0s :stopwatch: 0 suites  0 :zzz: 0 files    0 :x:

Results for commit c24753e2.

:recycle: This comment has been updated with latest results.

github-actions[bot] commented 3 weeks ago

Executor Unit Test Result zhrua/prompty_estimate_token

792 tests   792 :white_check_mark:  3m 45s :stopwatch:   1 suites    0 :zzz:   1 files      0 :x:

Results for commit c24753e2.

:recycle: This comment has been updated with latest results.

github-actions[bot] commented 3 weeks ago

Executor E2E Test Result zhrua/prompty_estimate_token

243 tests   238 :white_check_mark:  5m 36s :stopwatch:   1 suites    5 :zzz:   1 files      0 :x:

Results for commit c24753e2.

:recycle: This comment has been updated with latest results.

github-actions[bot] commented 3 weeks ago

SDK CLI Test Result zhrua/prompty_estimate_token

    4 files      4 suites   1h 1m 37s :stopwatch:   711 tests   670 :white_check_mark:  41 :zzz: 0 :x: 2 844 runs  2 680 :white_check_mark: 164 :zzz: 0 :x:

Results for commit c24753e2.

:recycle: This comment has been updated with latest results.