leeeduke / revTongYi

阿里云 通义千问、通义万相 逆向工程 Python API
GNU Affero General Public License v3.0
58 stars 9 forks source link

无法连续对话 #6

Closed jxyk2007 closed 5 months ago

jxyk2007 commented 6 months ago

将返回信息里的msgId': '7d7ef5c4de7c447583ef9f733fed5cea' for resp in chatbot.ask(prompt=question ,parentId="7d7ef5c4de7c447583ef9f733fed5cea"): print(resp)

还是会新开一个对话

leeeduke commented 6 months ago

经测试是可以连续对话的,以下是使用 CLI 模式的测试结果,可以参考一下 revTongYi/__init__.py 中的 CLI 的连续对话实现方式:

```
@leeeduke ➜ /workspaces/revTongYi (main) $ python cli.py 
You > hi
AI  > Hello! How can I help you today? Is there something you would like to talk about or learn more about? I'm here to provide information and answer any questions you have to the best of my ability. Just let me know what's on your mind.
You > 用java写个hello world
AI  > 当然可以,以下是一个简单的Java "Hello, World!"程序示例:

```java
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}
```

这个程序的工作原理是:

1. `public class HelloWorld` 定义了一个公共类名为 `HelloWorld`。在Java中,每一个程序都必须包含至少一个类。

2. `public static void main(String[] args)` 是Java程序的主入口点。当你启动一个Java应用程序时,它的执行始于main方法。

3. `System.out.println("Hello, World!");` 是Java中输出语句,它会在控制台打印出字符串 "Hello, World!"。
You > 再用python写一个
AI  > 当然,以下是Python语言实现"Hello, World!"的简单示例:

```python
print("Hello, World!")
```

在Python中,`print`函数用于将括号内的内容输出到控制台。这里的 "Hello, World!" 就会被打印出来。相比Java,Python的语法更为简洁直观。
You > 再换一种语言
AI  > 好的,下面以C++语言为例:

```cpp
#include <iostream>

int main() {
    std::cout << "Hello, World!";
    return 0;
}
```

在C++中,我们首先需要引入 `<iostream>` 标准库来使用输入输出功能。然后定义 `main` 函数作为程序的入口点,通过 `std::cout` 对象进行标准输出,使用 `<<` 运算符将字符串 "Hello, World!" 输出到控制台。最后,`main` 函数返回0表示程序正常结束。
You > 
```
jxyk2007 commented 6 months ago
# 非流式模式
import revTongYi.qianwen as qwen

question = "人工智能将对人类社会发展产生什么影响?"

chatbot = qwen.Chatbot(
    cookies=&lt;cookies_dict&gt;  # 以dict形式提供cookies
)
# chatbot = qwen.Chatbot(
#     cookies_str=&lt;cookies_str&gt;  # 您也可以使用字符串形式提供cookies,cookies字符串可以从浏览器的请求头中获取
# )

print(chatbot.ask(prompt=question))

这个模式是不行的。传了对话id过去也不行。

chehongchao commented 6 months ago

sessionId忘传了,自己改下ask把sessionId传进去就行了。 微信截图_20240314005443

old-dream321 commented 5 months ago

已在最新的pr中加入sessionId参数,从响应中获取再传入或者用cli模式都可以连续对话

leeeduke commented 5 months ago

确定是bug,等待修复,或参与 #9 的贡献

leeeduke commented 5 months ago

试一下新版 v0.1.1.0

jxyk2007 commented 5 months ago

for resp in chatbot.ask(prompt=question , stream=True ,timeout=60,parentId ='f862c688761f452ba3d0f5b5bd27ae9b',sessionId='32be7d97a6c042a1b72d55f093befb33'): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: Chatbot.ask() got an unexpected keyword argument 'sessionId'

leeeduke commented 5 months ago

for resp in chatbot.ask(prompt=question , stream=True ,timeout=60,parentId ='f862c688761f452ba3d0f5b5bd27ae9b',sessionId='32be7d97a6c042a1b72d55f093befb33'): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: Chatbot.ask() got an unexpected keyword argument 'sessionId'

pip install -U revTongYi

jxyk2007 commented 5 months ago

升级还是一样 pip install -U revTongYi DEPRECATION: Loading egg at d:\program files\python311\lib\site-packages\dnspod_python-1.0.0-py3.11.egg is deprecated. pip 24.3 will enforce this behaviour change. A possible replacement is to use pip for package installation.. Discussion can be found at https://github.com/pypa/pip/issues/12330 Looking in indexes: https://mirrors.aliyun.com/pypi/simple Requirement already satisfied: revTongYi in d:\program files\python311\lib\site-packages (0.1.0.0) Requirement already satisfied: fake-useragent in d:\program files\python311\lib\site-packages (from revTongYi) (1.4.0) Requirement already satisfied: filetype in d:\program files\python311\lib\site-packages (from revTongYi) (1.2.0) Requirement already satisfied: requests in d:\program files\python311\lib\site-packages (from revTongYi) (2.31.0) Requirement already satisfied: charset-normalizer<4,>=2 in d:\program files\python311\lib\site-packages (from requests->revTongYi) (2.1.0) Requirement already satisfied: idna<4,>=2.5 in d:\program files\python311\lib\site-packages (from requests->revTongYi) (3.3) Requirement already satisfied: urllib3<3,>=1.21.1 in d:\program files\python311\lib\site-packages (from requests->revTongYi) (1.26.11) Requirement already satisfied: certifi>=2017.4.17 in d:\program files\python311\lib\site-packages (from requests->revTongYi) (2022.6.15)

jxyk2007 commented 5 months ago

可以了,我手动复制代码。

leeeduke commented 5 months ago

pypi.org 之外的镜像源的更新会延迟