xiaogpt 2.22__py3-none-any.whl → 2.23__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- xiaogpt/bot/bard_bot.py +1 -0
 - xiaogpt/bot/gemini_bot.py +1 -0
 - xiaogpt/bot/glm_bot.py +28 -11
 - xiaogpt/bot/qwen_bot.py +3 -4
 - xiaogpt/cli.py +2 -2
 - {xiaogpt-2.22.dist-info → xiaogpt-2.23.dist-info}/METADATA +2 -2
 - {xiaogpt-2.22.dist-info → xiaogpt-2.23.dist-info}/RECORD +10 -10
 - {xiaogpt-2.22.dist-info → xiaogpt-2.23.dist-info}/WHEEL +0 -0
 - {xiaogpt-2.22.dist-info → xiaogpt-2.23.dist-info}/entry_points.txt +0 -0
 - {xiaogpt-2.22.dist-info → xiaogpt-2.23.dist-info}/licenses/LICENSE +0 -0
 
    
        xiaogpt/bot/bard_bot.py
    CHANGED
    
    
    
        xiaogpt/bot/gemini_bot.py
    CHANGED
    
    
    
        xiaogpt/bot/glm_bot.py
    CHANGED
    
    | 
         @@ -1,4 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            """ChatGLM bot"""
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       2 
3 
     | 
    
         
             
            from __future__ import annotations
         
     | 
| 
       3 
4 
     | 
    
         | 
| 
       4 
5 
     | 
    
         
             
            from typing import Any
         
     | 
| 
         @@ -13,34 +14,50 @@ class GLMBot(ChatHistoryMixin, BaseBot): 
     | 
|
| 
       13 
14 
     | 
    
         
             
                default_options = {"model": "chatglm_turbo"}
         
     | 
| 
       14 
15 
     | 
    
         | 
| 
       15 
16 
     | 
    
         
             
                def __init__(self, glm_key: str) -> None:
         
     | 
| 
       16 
     | 
    
         
            -
                    import  
     | 
| 
      
 17 
     | 
    
         
            +
                    from zhipuai import ZhipuAI
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                    self.model = "glm-4"  # Change glm model here
         
     | 
| 
       17 
20 
     | 
    
         | 
| 
       18 
21 
     | 
    
         
             
                    self.history = []
         
     | 
| 
       19 
     | 
    
         
            -
                     
     | 
| 
      
 22 
     | 
    
         
            +
                    self.client = ZhipuAI(api_key=glm_key)
         
     | 
| 
       20 
23 
     | 
    
         | 
| 
       21 
24 
     | 
    
         
             
                @classmethod
         
     | 
| 
       22 
25 
     | 
    
         
             
                def from_config(cls, config):
         
     | 
| 
       23 
26 
     | 
    
         
             
                    return cls(glm_key=config.glm_key)
         
     | 
| 
       24 
27 
     | 
    
         | 
| 
       25 
28 
     | 
    
         
             
                def ask(self, query, **options):
         
     | 
| 
       26 
     | 
    
         
            -
                    import zhipuai
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
29 
     | 
    
         
             
                    ms = self.get_messages()
         
     | 
| 
       29 
30 
     | 
    
         
             
                    kwargs = {**self.default_options, **options}
         
     | 
| 
       30 
     | 
    
         
            -
                    kwargs[" 
     | 
| 
      
 31 
     | 
    
         
            +
                    kwargs["model"] = self.model
         
     | 
| 
       31 
32 
     | 
    
         
             
                    ms.append({"role": "user", "content": f"{query}"})
         
     | 
| 
      
 33 
     | 
    
         
            +
                    kwargs["messages"] = ms
         
     | 
| 
       32 
34 
     | 
    
         
             
                    try:
         
     | 
| 
       33 
     | 
    
         
            -
                        r =  
     | 
| 
      
 35 
     | 
    
         
            +
                        r = self.client.chat.completions.create(**kwargs)
         
     | 
| 
       34 
36 
     | 
    
         
             
                    except Exception as e:
         
     | 
| 
       35 
37 
     | 
    
         
             
                        print(str(e))
         
     | 
| 
       36 
38 
     | 
    
         
             
                        return
         
     | 
| 
       37 
     | 
    
         
            -
                    message =  
     | 
| 
       38 
     | 
    
         
            -
                    for i in r.events():
         
     | 
| 
       39 
     | 
    
         
            -
                        message += str(i.data)
         
     | 
| 
      
 39 
     | 
    
         
            +
                    message = r.choices[0].message.content
         
     | 
| 
       40 
40 
     | 
    
         | 
| 
       41 
41 
     | 
    
         
             
                    self.add_message(query, message)
         
     | 
| 
       42 
42 
     | 
    
         
             
                    print(message)
         
     | 
| 
       43 
43 
     | 
    
         
             
                    return message
         
     | 
| 
       44 
44 
     | 
    
         | 
| 
       45 
     | 
    
         
            -
                def ask_stream(self, query: str, **options: Any):
         
     | 
| 
       46 
     | 
    
         
            -
                     
     | 
| 
      
 45 
     | 
    
         
            +
                async def ask_stream(self, query: str, **options: Any):
         
     | 
| 
      
 46 
     | 
    
         
            +
                    ms = self.get_messages()
         
     | 
| 
      
 47 
     | 
    
         
            +
                    kwargs = {**self.default_options, **options}
         
     | 
| 
      
 48 
     | 
    
         
            +
                    kwargs["model"] = self.model
         
     | 
| 
      
 49 
     | 
    
         
            +
                    ms.append({"role": "user", "content": f"{query}"})
         
     | 
| 
      
 50 
     | 
    
         
            +
                    kwargs["messages"] = ms
         
     | 
| 
      
 51 
     | 
    
         
            +
                    kwargs["stream"] = True
         
     | 
| 
      
 52 
     | 
    
         
            +
                    try:
         
     | 
| 
      
 53 
     | 
    
         
            +
                        r = self.client.chat.completions.create(**kwargs)
         
     | 
| 
      
 54 
     | 
    
         
            +
                    except Exception as e:
         
     | 
| 
      
 55 
     | 
    
         
            +
                        print(str(e))
         
     | 
| 
      
 56 
     | 
    
         
            +
                        return
         
     | 
| 
      
 57 
     | 
    
         
            +
                    full_content = ""
         
     | 
| 
      
 58 
     | 
    
         
            +
                    for chunk in r:
         
     | 
| 
      
 59 
     | 
    
         
            +
                        content = chunk.choices[0].delta.content
         
     | 
| 
      
 60 
     | 
    
         
            +
                        full_content += content
         
     | 
| 
      
 61 
     | 
    
         
            +
                        print(content, end="")
         
     | 
| 
      
 62 
     | 
    
         
            +
                        yield content
         
     | 
| 
      
 63 
     | 
    
         
            +
                    self.add_message(query, full_content)
         
     | 
    
        xiaogpt/bot/qwen_bot.py
    CHANGED
    
    | 
         @@ -1,4 +1,5 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            """ 
     | 
| 
      
 1 
     | 
    
         
            +
            """Qwen bot"""
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       2 
3 
     | 
    
         
             
            from __future__ import annotations
         
     | 
| 
       3 
4 
     | 
    
         | 
| 
       4 
5 
     | 
    
         
             
            from http import HTTPStatus
         
     | 
| 
         @@ -16,9 +17,7 @@ class QwenBot(ChatHistoryMixin, BaseBot): 
     | 
|
| 
       16 
17 
     | 
    
         
             
                    import dashscope
         
     | 
| 
       17 
18 
     | 
    
         
             
                    from dashscope.api_entities.dashscope_response import Role
         
     | 
| 
       18 
19 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
                    self.history = [
         
     | 
| 
       20 
     | 
    
         
            -
                        {"role": Role.SYSTEM, "content": "You are a helpful assistant."}
         
     | 
| 
       21 
     | 
    
         
            -
                    ]
         
     | 
| 
      
 20 
     | 
    
         
            +
                    self.history = []
         
     | 
| 
       22 
21 
     | 
    
         
             
                    dashscope.api_key = qwen_key
         
     | 
| 
       23 
22 
     | 
    
         | 
| 
       24 
23 
     | 
    
         
             
                @classmethod
         
     | 
    
        xiaogpt/cli.py
    CHANGED
    
    | 
         @@ -195,8 +195,8 @@ def main(): 
     | 
|
| 
       195 
195 
     | 
    
         
             
                )
         
     | 
| 
       196 
196 
     | 
    
         | 
| 
       197 
197 
     | 
    
         
             
                options = parser.parse_args()
         
     | 
| 
       198 
     | 
    
         
            -
                if options.bot in [" 
     | 
| 
       199 
     | 
    
         
            -
                    raise Exception("For now  
     | 
| 
      
 198 
     | 
    
         
            +
                if options.bot in ["bard"] and options.stream:
         
     | 
| 
      
 199 
     | 
    
         
            +
                    raise Exception("For now Bard do not support stream")
         
     | 
| 
       200 
200 
     | 
    
         
             
                config = Config.from_options(options)
         
     | 
| 
       201 
201 
     | 
    
         | 
| 
       202 
202 
     | 
    
         
             
                miboy = MiGPT(config)
         
     | 
| 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            Metadata-Version: 2.1
         
     | 
| 
       2 
2 
     | 
    
         
             
            Name: xiaogpt
         
     | 
| 
       3 
     | 
    
         
            -
            Version: 2. 
     | 
| 
      
 3 
     | 
    
         
            +
            Version: 2.23
         
     | 
| 
       4 
4 
     | 
    
         
             
            Summary: Play ChatGPT or other LLM with xiaomi AI speaker
         
     | 
| 
       5 
5 
     | 
    
         
             
            Author-Email: yihong0618 <zouzou0208@gmail.com>
         
     | 
| 
       6 
6 
     | 
    
         
             
            License: MIT
         
     | 
| 
         @@ -13,7 +13,7 @@ Requires-Dist: miservice_fork 
     | 
|
| 
       13 
13 
     | 
    
         
             
            Requires-Dist: openai>=1
         
     | 
| 
       14 
14 
     | 
    
         
             
            Requires-Dist: aiohttp
         
     | 
| 
       15 
15 
     | 
    
         
             
            Requires-Dist: rich
         
     | 
| 
       16 
     | 
    
         
            -
            Requires-Dist: zhipuai
         
     | 
| 
      
 16 
     | 
    
         
            +
            Requires-Dist: zhipuai==2.0.1
         
     | 
| 
       17 
17 
     | 
    
         
             
            Requires-Dist: bardapi
         
     | 
| 
       18 
18 
     | 
    
         
             
            Requires-Dist: edge-tts>=6.1.3
         
     | 
| 
       19 
19 
     | 
    
         
             
            Requires-Dist: EdgeGPT==0.1.26
         
     | 
| 
         @@ -1,20 +1,20 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            xiaogpt-2. 
     | 
| 
       2 
     | 
    
         
            -
            xiaogpt-2. 
     | 
| 
       3 
     | 
    
         
            -
            xiaogpt-2. 
     | 
| 
       4 
     | 
    
         
            -
            xiaogpt-2. 
     | 
| 
      
 1 
     | 
    
         
            +
            xiaogpt-2.23.dist-info/METADATA,sha256=pV5ExJ_7YpAmcJg6iK5dukVjN4haD59AYx4NIOdMhzY,18887
         
     | 
| 
      
 2 
     | 
    
         
            +
            xiaogpt-2.23.dist-info/WHEEL,sha256=N2J68yzZqJh3mI_Wg92rwhw0rtJDFpZj9bwQIMJgaVg,90
         
     | 
| 
      
 3 
     | 
    
         
            +
            xiaogpt-2.23.dist-info/entry_points.txt,sha256=zLFzA72qQ_eWBepdA2YU5vdXFqORH8wXhv2Ox1vnYP8,46
         
     | 
| 
      
 4 
     | 
    
         
            +
            xiaogpt-2.23.dist-info/licenses/LICENSE,sha256=XdClh516MvlnOf9749JZHCxSB7y6_fyXcWmLDz6IkZY,1063
         
     | 
| 
       5 
5 
     | 
    
         
             
            xiaogpt/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
         
     | 
| 
       6 
6 
     | 
    
         
             
            xiaogpt/__main__.py,sha256=MSmt_5Xg84uHqzTN38JwgseJK8rsJn_11A8WD99VtEo,61
         
     | 
| 
       7 
7 
     | 
    
         
             
            xiaogpt/bot/__init__.py,sha256=O3Wq7WRwTVdKJdKZxkBtCPdRJ8uXrQE0dqHa1ekOnfQ,1073
         
     | 
| 
       8 
     | 
    
         
            -
            xiaogpt/bot/bard_bot.py,sha256= 
     | 
| 
      
 8 
     | 
    
         
            +
            xiaogpt/bot/bard_bot.py,sha256=qC8m87mWvtbiwipKl_OMYCqRbh79gkyZEytgz5DysC0,840
         
     | 
| 
       9 
9 
     | 
    
         
             
            xiaogpt/bot/base_bot.py,sha256=oKn6LLFHXol4hKrSrjnxknrOqrcGICtT_GPPYRNxpkw,1467
         
     | 
| 
       10 
10 
     | 
    
         
             
            xiaogpt/bot/chatgptapi_bot.py,sha256=Z4FX7F6j2n6NoUCqH6LliAAew94zaQXzp1blsE5yKoc,3656
         
     | 
| 
       11 
     | 
    
         
            -
            xiaogpt/bot/gemini_bot.py,sha256= 
     | 
| 
       12 
     | 
    
         
            -
            xiaogpt/bot/glm_bot.py,sha256= 
     | 
| 
      
 11 
     | 
    
         
            +
            xiaogpt/bot/gemini_bot.py,sha256=udKrWYP7U83AWpNBggwRp9bvgR2DTHqLMX9E_DLFv-I,1840
         
     | 
| 
      
 12 
     | 
    
         
            +
            xiaogpt/bot/glm_bot.py,sha256=QoMJbnu5_rHDz4tzwn7gh3IoAuw7E4hZQLAfziMAvNY,1825
         
     | 
| 
       13 
13 
     | 
    
         
             
            xiaogpt/bot/gpt3_bot.py,sha256=enX45_wrGjAtOh-anf8KnjCJluWSARZbjTGD_WZgoms,2781
         
     | 
| 
       14 
14 
     | 
    
         
             
            xiaogpt/bot/langchain_bot.py,sha256=4Uz5iOYzA2ongCklS-9zBse2fw-7kEE_9wITH7wdVCc,1944
         
     | 
| 
       15 
15 
     | 
    
         
             
            xiaogpt/bot/newbing_bot.py,sha256=afUmw6tyMXbgGZvfQQWaA5h0-e0V0isFolW-WGhd0Vs,2289
         
     | 
| 
       16 
     | 
    
         
            -
            xiaogpt/bot/qwen_bot.py,sha256= 
     | 
| 
       17 
     | 
    
         
            -
            xiaogpt/cli.py,sha256= 
     | 
| 
      
 16 
     | 
    
         
            +
            xiaogpt/bot/qwen_bot.py,sha256=n0WIeixAisd2_Vvky18FQFGcDIF3Cc2q2qp4ExCNBho,3521
         
     | 
| 
      
 17 
     | 
    
         
            +
            xiaogpt/cli.py,sha256=aLmpwjYw6tKPNy-WPZIE2XD5oLHsjSksova_PpH85II,5057
         
     | 
| 
       18 
18 
     | 
    
         
             
            xiaogpt/config.py,sha256=uo82JTKhujet0ro2SN3cOw2GXE-AamyzL7EmeFiGS5o,6287
         
     | 
| 
       19 
19 
     | 
    
         
             
            xiaogpt/langchain/callbacks.py,sha256=yR9AXQt9OHVYBWC47Q1I_BUT4Xg9iM44vnW2vv0BLpE,2616
         
     | 
| 
       20 
20 
     | 
    
         
             
            xiaogpt/langchain/chain.py,sha256=z0cqRlL0ElWnf31ByxZBN7AKOT-svXQDt5_NDft_nYc,1495
         
     | 
| 
         @@ -27,4 +27,4 @@ xiaogpt/tts/mi.py,sha256=9HkgGWByAs7k8sTpRdVlgJnnmjc44RNAccJa6tGDlXk,1096 
     | 
|
| 
       27 
27 
     | 
    
         
             
            xiaogpt/tts/openai.py,sha256=_Qk12zYY-UuXLKvQVe3PqIvCmoRW9OcVCqQRoGCXvNc,1533
         
     | 
| 
       28 
28 
     | 
    
         
             
            xiaogpt/utils.py,sha256=B7NCH7g19hcwHDXsnBJPTU6UcWnXoEntKWm-pgcet2I,2072
         
     | 
| 
       29 
29 
     | 
    
         
             
            xiaogpt/xiaogpt.py,sha256=_viWq5w4-rGCTsuDetPPih-4qkPZem9FtXK-tPyChlA,15473
         
     | 
| 
       30 
     | 
    
         
            -
            xiaogpt-2. 
     | 
| 
      
 30 
     | 
    
         
            +
            xiaogpt-2.23.dist-info/RECORD,,
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     |