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]: /api/v1/chats/{chat_id}/sessions default opening is wrong #3285

Open
1 task done
jackson0415 opened this issue Nov 8, 2024 · 4 comments
Open
1 task done
Assignees
Labels
bug Something isn't working

Comments

@jackson0415
Copy link

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch name

0.13.0

Commit ID

issue_create_session_241108

Other environment information

No response

Actual behavior

create sessions接口 /api/v1/chats/{chat_id}/sessions默认的助手开场白不对,应该根据chatId获取设置的,然后再返回

Expected behavior

No response

Steps to reproduce

create sessions接口 /api/v1/chats/{chat_id}/sessions默认的助手开场白不对,应该根据chatId获取设置的,然后再返回

Additional information

No response

@jackson0415 jackson0415 added the bug Something isn't working label Nov 8, 2024
@JinHai-CN JinHai-CN changed the title [Bug]:create sessions接口 /api/v1/chats/{chat_id}/sessions默认的助手开场白不对,应该根据chatId获取设置的,然后再返回 [Bug]: /api/v1/chats/{chat_id}/sessions default opening is wrong Nov 8, 2024
@Remember12344
Copy link

这个我一直无法访问

@Remember12344
Copy link

/api/v1/chats/{chat_id}/sessions

通过这个链接http://localhost/api/v1/chats/chat_id/sessions无法访问这个链接,我想通过request获得响应的结果,但是无法传递access_token请问该怎么解决?
我的代码是这样的“
import requests
import json

login

session=requests.session()

session.headers={
"User-agent":'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36',
'Content-Type': 'application/json',
'Authorization': 'Bearer ragflow-JlMmIyYTFlOTc4OTExZWY5YmNiMDI'
}

login_url='http://localhost/v1/user/login'
login_payload={
"email": "17700...1@qq.com",
"password": "..."
}
login_response=session.post(login_url,headers=session.headers,json=login_payload)

print("Login Cookies:", session.cookies.get_dict())

if login_response.ok:
with open('rag.html', 'wb') as f:
f.write(login_response.content)
print("登录成功,页面已保存到 rag.html")

try:
   login_data= login_response.json()
   new_access_token = login_data['data']['access_token']
   session.headers['access_token']=new_access_token
   print(f"Access token: {new_access_token}")

   Conversation_url='http://localhost/chat?dialogId=b6f6576c943911efaa650242ac120006&conversationId=ca5c652be2ff49a9b32be1c5c70a70cb&isNew='
   params={
   'conversation_id': 'ca5c652be2ff49a9b32be1c5c70a70cb'
   }
   response2=session.get(Conversation_url,headers=session.headers,params=params)
   if response2.ok:
      with open('reply.html',"wb") as f:
        f.write(response2.content)
      print("成功回复")
   else:
      print("登陆失败")
except json.JSONDecoderError:
   print("登录响应不是有效的JSON格式")
except KeyError:
   print("无法登录响应从中提取access_token")

else:
print(f"登录失败: {login_response.status_code} - {login_response.text}")

@JinHai-CN
Copy link
Contributor

@Feiue Any updates?

@Feiue
Copy link
Contributor

Feiue commented Dec 3, 2024

/api/v1/chats/{chat_id}/sessions

通过这个链接http://localhost/api/v1/chats/chat_id/sessions无法访问这个链接,我想通过request获得响应的结果,但是无法传递access_token请问该怎么解决? 我的代码是这样的“ import requests import json

login

session=requests.session()

session.headers={ "User-agent":'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36', 'Content-Type': 'application/json', 'Authorization': 'Bearer ragflow-JlMmIyYTFlOTc4OTExZWY5YmNiMDI' }

login_url='http://localhost/v1/user/login' login_payload={ "email": "17700...1@qq.com", "password": "..." } login_response=session.post(login_url,headers=session.headers,json=login_payload)↳

print("Login Cookies:", session.cookies.get_dict())

if login_response.ok: with open('rag.html', 'wb') as f: f.write(login_response.content) print("登录成功,页面已保存到 rag.html")

try:
   login_data= login_response.json()
   new_access_token = login_data['data']['access_token']
   session.headers['access_token']=new_access_token
   print(f"Access token: {new_access_token}")

   Conversation_url='http://localhost/chat?dialogId=b6f6576c943911efaa650242ac120006&conversationId=ca5c652be2ff49a9b32be1c5c70a70cb&isNew='
   params={
   'conversation_id': 'ca5c652be2ff49a9b32be1c5c70a70cb'
   }
   response2=session.get(Conversation_url,headers=session.headers,params=params)
   if response2.ok:
      with open('reply.html',"wb") as f:
        f.write(response2.content)
      print("成功回复")
   else:
      print("登陆失败")
except json.JSONDecoderError:
   print("登录响应不是有效的JSON格式")
except KeyError:
   print("无法登录响应从中提取access_token")

else: print(f"登录失败: {login_response.status_code} - {login_response.text}")

'Authorization': 'Bearer ragflow-JlMmIyYTFlOTc4OTExZWY5YmNiMDI'. This authentication method is correct.

KevinHuSh pushed a commit that referenced this issue Dec 3, 2024
### What problem does this PR solve?

Fix the agent reference bug and the session prologue
#3285 #3819
### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

Co-authored-by: liuhua <10215101452@stu.ecun.edu.cn>
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