commandchat 0.0.11__tar.gz → 0.0.12__tar.gz
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.
- {commandchat-0.0.11 → commandchat-0.0.12}/PKG-INFO +1 -1
- {commandchat-0.0.11 → commandchat-0.0.12}/commandchat.egg-info/PKG-INFO +1 -1
- {commandchat-0.0.11 → commandchat-0.0.12}/occ/CommandChat.py +7 -8
- {commandchat-0.0.11 → commandchat-0.0.12}/pyproject.toml +1 -1
- {commandchat-0.0.11 → commandchat-0.0.12}/LICENSE +0 -0
- {commandchat-0.0.11 → commandchat-0.0.12}/README.md +0 -0
- {commandchat-0.0.11 → commandchat-0.0.12}/commandchat.egg-info/SOURCES.txt +0 -0
- {commandchat-0.0.11 → commandchat-0.0.12}/commandchat.egg-info/dependency_links.txt +0 -0
- {commandchat-0.0.11 → commandchat-0.0.12}/commandchat.egg-info/entry_points.txt +0 -0
- {commandchat-0.0.11 → commandchat-0.0.12}/commandchat.egg-info/requires.txt +0 -0
- {commandchat-0.0.11 → commandchat-0.0.12}/commandchat.egg-info/top_level.txt +0 -0
- {commandchat-0.0.11 → commandchat-0.0.12}/occ/ConvertLogToMarkDown.py +0 -0
- {commandchat-0.0.11 → commandchat-0.0.12}/occ/__init__.py +0 -0
- {commandchat-0.0.11 → commandchat-0.0.12}/occ/command/__init__.py +0 -0
- {commandchat-0.0.11 → commandchat-0.0.12}/occ/command/__main__.py +0 -0
- {commandchat-0.0.11 → commandchat-0.0.12}/occ/commons/__init__.py +0 -0
- {commandchat-0.0.11 → commandchat-0.0.12}/occ/commons/config.py +0 -0
- {commandchat-0.0.11 → commandchat-0.0.12}/occ/configuration/__init__.py +0 -0
- {commandchat-0.0.11 → commandchat-0.0.12}/occ/configuration/profile_config.py +0 -0
- {commandchat-0.0.11 → commandchat-0.0.12}/occ/utils/CommonUtil.py +0 -0
- {commandchat-0.0.11 → commandchat-0.0.12}/occ/utils/__init__.py +0 -0
- {commandchat-0.0.11 → commandchat-0.0.12}/occ/utils/logger.py +0 -0
- {commandchat-0.0.11 → commandchat-0.0.12}/setup.cfg +0 -0
- {commandchat-0.0.11 → commandchat-0.0.12}/setup.py +0 -0
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import json
|
|
3
|
+
import os
|
|
3
4
|
import sys
|
|
4
5
|
import time
|
|
5
6
|
from pathlib import Path
|
|
6
7
|
from typing import AsyncGenerator
|
|
7
8
|
|
|
8
|
-
import openai
|
|
9
|
-
from openai import OpenAI, Stream
|
|
10
9
|
from openai import AzureOpenAI
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
from openai.types.chat import ChatCompletionChunk
|
|
10
|
+
from openai import OpenAI
|
|
14
11
|
from openai.types.chat.chat_completion_chunk import Choice
|
|
15
12
|
from prompt_toolkit import print_formatted_text, HTML, Application
|
|
13
|
+
from prompt_toolkit.clipboard.pyperclip import PyperclipClipboard
|
|
16
14
|
from prompt_toolkit.layout import Layout, HSplit
|
|
17
15
|
from prompt_toolkit.widgets import TextArea
|
|
18
16
|
from rich.console import Console
|
|
19
|
-
from rich.markdown import Markdown
|
|
20
17
|
from rich.live import Live
|
|
18
|
+
from rich.markdown import Markdown
|
|
21
19
|
|
|
22
20
|
from occ.commons.config import get_env
|
|
23
|
-
from occ.utils.CommonUtil import save_and_copy_image, waiting_start, waiting_stop
|
|
24
21
|
|
|
25
22
|
DEFAULT_CHAT_LOG_ID = "chat-1"
|
|
26
23
|
DEFAULT_PROFILE = "default"
|
|
@@ -37,9 +34,9 @@ def get_home_path():
|
|
|
37
34
|
return homedir
|
|
38
35
|
|
|
39
36
|
|
|
37
|
+
clip = PyperclipClipboard()
|
|
40
38
|
console = Console()
|
|
41
39
|
|
|
42
|
-
|
|
43
40
|
def print_formatted(content: str, live: Live):
|
|
44
41
|
md = Markdown(content)
|
|
45
42
|
live.update(md)
|
|
@@ -99,6 +96,7 @@ class CommandChat:
|
|
|
99
96
|
for choice in completion.choices:
|
|
100
97
|
completion_text += choice.text
|
|
101
98
|
print_formatted(completion_text, live)
|
|
99
|
+
clip.set_text(completion_text)
|
|
102
100
|
print("\n")
|
|
103
101
|
|
|
104
102
|
def chat_completions(self, message, model):
|
|
@@ -120,6 +118,7 @@ class CommandChat:
|
|
|
120
118
|
md = Markdown(final_text)
|
|
121
119
|
self.append_to_history(final_text)
|
|
122
120
|
console.print(md)
|
|
121
|
+
clip.set_text(final_text)
|
|
123
122
|
self.record_chat_logs(message, {"role": self.role, "content": final_text.replace("\n\n", "")})
|
|
124
123
|
|
|
125
124
|
async def async_stream(self) -> AsyncGenerator[Choice, None]:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|