infiniflow / ragflow

RAGFlow is an open-source RAG (Retrieval-Augmented Generation) engine based on deep document understanding.
https://ragflow.io
Apache License 2.0
23.82k stars 2.33k forks source link

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

Open nordy1145 opened 4 days ago

nordy1145 commented 4 days ago

Is there an existing issue for the same bug?

Branch name

main

Commit ID

9b2f19fa66bb4a0bf2ddd787eabc9e39caf02ada

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

zzhh777 commented 4 days ago

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 commented 4 days ago

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

fyxkszz commented 4 days ago

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