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

[Bug]: Python SDK session.ask(question, stream=True) issue #3570

Open
1 task done
nordy1145 opened this issue Nov 21, 2024 · 3 comments
Open
1 task done

[Bug]: Python SDK session.ask(question, stream=True) issue #3570

nordy1145 opened this issue Nov 21, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@nordy1145
Copy link

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch name

main

Commit ID

9b2f19f

Other environment information

No response

Actual behavior

When running the Python Agent example, it's throwing a few exceptions.

Here is my python code.

from ragflow_sdk import RAGFlow,Agent

rag_object = RAGFlow(api_key="ragflow-apikey", base_url="http://urlhere:9380")
AGENT_id = "2a6fb1b0a78311ef96d60242asadfsdfafd"

session = Agent.create_session(AGENT_id,rag_object)    

print("\n===== Miss R ====\n")
print("Hello. What can I do for you?")

while True:
    question = input("\n===== User ====\n> ")
    print("\n==== Miss R ====\n")
    
    cont = ""
    for ans in session.ask(question, stream=True):
        print(ans.content[len(cont):], end='', flush=True)
        cont = ans.content

I get the following error:

Exception has occurred: TypeError
Session.ask() got an unexpected keyword argument 'stream'
  File "C:\Users\Coding\Ragflow\testagent.py", line 17, in <module>
    for ans in session.ask(question, stream=True):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Session.ask() got an unexpected keyword argument 'stream'

When I remove stream from session.ask (looks like stream isn't defined in the sdk at all) I get this error:

Exception has occurred: Exception
AssertionError('Nothing. Is it over?')
  File "C:\Users\Coding\Ragflow\testagent.py", line 17, in <module>
    for ans in session.ask(question): #, stream=True):
Exception: AssertionError('Nothing. Is it over?')

Expected behavior

No response

Steps to reproduce

run this code from python.

from ragflow_sdk import RAGFlow,Agent

rag_object = RAGFlow(api_key="ragflow-apikey", base_url="http://urlhere:9380")
AGENT_id = "2a6fb1b0a78311ef96d60242acasfdsf"

session = Agent.create_session(AGENT_id,rag_object)    

print("\n===== Miss R ====\n")
print("Hello. What can I do for you?")

while True:
    question = input("\n===== User ====\n> ")
    print("\n==== Miss R ====\n")
    
    cont = ""
    for ans in session.ask(question, stream=True):
        print(ans.content[len(cont):], end='', flush=True)
        cont = ans.content

Additional information

No response

@nordy1145 nordy1145 added the bug Something isn't working label Nov 21, 2024
@zzhh777
Copy link

zzhh777 commented Nov 22, 2024

I used the dev image and encountered a similar bug. I built and successfully ran an Agent, but when I tried to invoke it using the HTTP API, it returned
{"code":100,"data":null,"message":"AssertionError('Nothing. Is it over?')"}.
无标题
无标题2

@peizimo
Copy link

peizimo commented Nov 22, 2024

image
same problem , how should I change API , or mv service_conf.yaml to conf/ or so on , thanks

@fyxkszz
Copy link

fyxkszz commented Nov 22, 2024

me too. I get the error like this:
{
"code": 100,
"data": null,
"message": "AssertionError('Nothing. Is it over?')"
}

KevinHuSh added a commit that referenced this issue Nov 22, 2024
### What problem does this PR solve?

#3570 

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants