-
Notifications
You must be signed in to change notification settings - Fork 33
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
fix: error in streaming #665
Conversation
docs:Add readme usage documents for `chatbot.py` files;Simplify the introduction to streamlit in math-application notebook
fix:Fixed error report without content attribute in stream output
WalkthroughThe recent updates bring significant improvements to the Promptulate library, focusing on enhancing streaming capabilities and refining message handling. Changes include adding streaming response support in Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- promptulate/chat.py (1 hunks)
- promptulate/llms/_litellm.py (1 hunks)
- tests/test_chat.py (3 hunks)
Additional comments not posted (5)
promptulate/llms/_litellm.py (2)
28-29
: Ensurechunk[1]
is the correct way to access content.Please verify that
chunk[1]
is the correct way to access the content. Ifchunk
is a list or tuple, this should be fine. Otherwise, it might lead to errors.
28-29
: LGTM! Ensure all function calls match the new signature.Verification successful
All instances of
parse_content
match the new signature.
promptulate/llms/_litellm.py
promptulate/llms/zhipu/platform.py
promptulate/llms/qianfan/platform.py
promptulate/schema.py
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `parse_content` match the new signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type python $'parse_content'Length of output: 63
Script:
#!/bin/bash # Description: Verify all function calls to `parse_content` match the new signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type py parse_contentLength of output: 960
Script:
#!/bin/bash # Description: Verify all function definitions and calls to `parse_content` match the new signature. # Test: Search for the function definitions and calls. Expect: Only occurrences of the new signature. rg --type py 'def parse_content\(chunk\) -> \(str, str\):' rg --type py 'parse_content\(chunk\)'Length of output: 698
tests/test_chat.py (2)
30-44
: LGTM! The changes correctly handle streaming responses.
163-179
: LGTM! The changes correctly test streaming responses.promptulate/chat.py (1)
158-160
: LGTM! The changes correctly handle streaming responses.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- tests/test_chat.py (3 hunks)
Files skipped from review as they are similar to previous changes (1)
- tests/test_chat.py
fix:Modify the usage of ChatOpenAI to use LLMFactory
fix:Fixed error report without content attribute in stream output
…promptulate into hizeros/streaming
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (5)
- example/build-math-application-with-agent/build-math-application-with-agent.ipynb (12 hunks)
- example/build-math-application-with-agent/chatbot.py (4 hunks)
- example/build-math-application-with-agent/readme.md (1 hunks)
- promptulate/chat.py (1 hunks)
- promptulate/llms/_litellm.py (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- promptulate/chat.py
Additional comments not posted (20)
example/build-math-application-with-agent/readme.md (3)
1-1
: No issues found.
2-2
: No issues found.
4-4
: No issues found.promptulate/llms/_litellm.py (2)
29-29
: LGTM! The change correctly handles the chunk object.
45-48
: LGTM! The change correctly adds thestream
parameter to the function call.example/build-math-application-with-agent/chatbot.py (3)
81-82
: LGTM! The change correctly updates the model togpt-4-1106-preview
.
99-99
: LGTM! The change correctly updates the model togpt-4-1106-preview
.
109-109
: LGTM! The link to the source code is appropriate and useful.example/build-math-application-with-agent/build-math-application-with-agent.ipynb (12)
7-7
: LGTM! The description is appropriate and aligns with the PR objectives.
12-12
: LGTM! The link to the image is appropriate and useful.
28-32
: LGTM! The instructions for installing necessary libraries are appropriate and useful.
51-52
: LGTM! The metadata for the code cell is appropriate and useful for tracking execution time.
Line range hint
81-82
: LGTM! The change correctly updates the model togpt-4-1106-preview
.
153-153
: LGTM! The initialization of the LLM model is appropriate and aligns with the PR objectives.
290-291
: LGTM! The change correctly updates the model togpt-4-1106-preview
.
323-340
: LGTM! The output of the agent's response is appropriate and useful for understanding the agent's behavior.
376-376
: LGTM! The description of the Streamlit application is appropriate and aligns with the PR objectives.
378-387
: LGTM! The instructions for installing necessary libraries are appropriate and useful.
389-389
: LGTM! The command to change the directory is appropriate and useful.
391-391
: LGTM! The command to run the Streamlit application is appropriate and useful.
@@ -0,0 +1,11 @@ | |||
# The `chatbot.py` is an example of building a mathematical chatbot using streamlit and promptulate | |||
|
|||
# How to run? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid using multiple top-level headings in the same document.
Consider using subheadings (e.g., ## How to run?
) instead.
|
||
# How to run? | ||
|
||
1. First configure the package |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surround lists with blank lines for better readability.
5c5
< 1. First configure the package
---
>
> 1. First configure the package
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
1. First configure the package
# How to run? | ||
|
||
1. First configure the package | ||
- `pip install -r requirements.txt` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surround lists with blank lines for better readability.
6c6
< - `pip install -r requirements.txt`
---
>
> - `pip install -r requirements.txt`
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
- `pip install -r requirements.txt` | |
- `pip install -r requirements.txt` |
1. First configure the package | ||
- `pip install -r requirements.txt` | ||
|
||
2. Switch to the directory where `chatbot.py` is located |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surround lists with blank lines for better readability.
8c8
< 2. Switch to the directory where `chatbot.py` is located
---
>
> 2. Switch to the directory where `chatbot.py` is located
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
2. Switch to the directory where `chatbot.py` is located | |
2. Switch to the directory where `chatbot.py` is located | |
- `pip install -r requirements.txt` | ||
|
||
2. Switch to the directory where `chatbot.py` is located | ||
- cd `promptulate/example/build-math-application-with-agent` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surround lists with blank lines for better readability.
9c9
< - cd `promptulate/example/build-math-application-with-agent`
---
>
> - cd `promptulate/example/build-math-application-with-agent`
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
- cd `promptulate/example/build-math-application-with-agent` | |
- cd `promptulate/example/build-math-application-with-agent` |
2. Switch to the directory where `chatbot.py` is located | ||
- cd `promptulate/example/build-math-application-with-agent` | ||
|
||
3. Run the `streamlit run chatbot.py` command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surround lists with blank lines for better readability.
11c11
< 3. Run the `streamlit run chatbot.py` command
---
>
> 3. Run the `streamlit run chatbot.py` command
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
3. Run the `streamlit run chatbot.py` command | |
3. Run the `streamlit run chatbot.py` command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (4)
- promptulate/chat.py (2 hunks)
- promptulate/llms/base.py (1 hunks)
- requirements.txt (1 hunks)
- tests/test_chat.py (3 hunks)
Files not reviewed due to errors (1)
- promptulate/llms/base.py (no review received)
Files skipped from review due to trivial changes (1)
- requirements.txt
Files skipped from review as they are similar to previous changes (2)
- promptulate/chat.py
- tests/test_chat.py
tests/test_chat.py
Outdated
class FakeLLM(BaseLLM): | ||
llm_type: str = "fake" | ||
|
||
def __init__(self, *args, **kwargs): | ||
print(33333) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove useless log output
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- promptulate/chat.py (2 hunks)
- tests/test_chat.py (4 hunks)
Files skipped from review due to trivial changes (1)
- promptulate/chat.py
Files skipped from review as they are similar to previous changes (1)
- tests/test_chat.py
lgtm |
test:Add stream unit test.
fix:Fixed error report without content attribute in stream output
fix:Fixed the problem that chunk has no choice attribute when stream=Ture