Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Commit 84d2798

Browse files
authored
Merge pull request #136 from Integration-Automation/dev
Dev
2 parents 437fb52 + e3ff4d6 commit 84d2798

File tree

3 files changed

+10
-76
lines changed

3 files changed

+10
-76
lines changed

dev.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
66

77
[project]
88
name = "re_edge_gpt_dev"
9-
version = "0.0.43"
9+
version = "0.0.45"
1010
authors = [
1111
{ name = "JE-Chen", email = "jechenmailman@gmail.com" },
1212
]

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
66

77
[project]
88
name = "re_edge_gpt"
9-
version = "0.0.36"
9+
version = "0.0.37"
1010
authors = [
1111
{ name = "JE-Chen", email = "jechenmailman@gmail.com" },
1212
]

re_edge_gpt/__main__.py

Lines changed: 8 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,8 @@ async def async_main(args: argparse.Namespace) -> None:
8282
completer = create_completer(["!help", "!exit", "!reset"])
8383
initial_prompt = args.prompt
8484

85-
# Log chat history
86-
def p_hist(*args, **kwargs) -> None:
87-
pass
88-
89-
if args.history_file:
90-
history_file_path = Path(args.history_file)
91-
f = history_file_path.open("a+", encoding="utf-8")
92-
p_hist = _create_history_logger(f)
93-
9485
while True:
9586
print("\nYou:")
96-
p_hist("\nYou:")
9787
if initial_prompt:
9888
question = initial_prompt
9989
print(question)
@@ -105,7 +95,6 @@ def p_hist(*args, **kwargs) -> None:
10595
else await get_input_async(session=session, completer=completer)
10696
)
10797
print()
108-
p_hist(question + "\n")
10998
if question == "!exit":
11099
await bot.close()
111100
break
@@ -122,62 +111,14 @@ def p_hist(*args, **kwargs) -> None:
122111
await bot.reset()
123112
continue
124113
print("Bot:")
125-
p_hist("Bot:")
126-
if args.no_stream:
127-
response = (
128-
await bot.ask(
129-
prompt=question,
130-
conversation_style=args.style,
131-
wss_link=args.wss_link,
132-
search_result=args.search_result,
133-
locale=args.locale,
134-
)
135-
)["item"]["messages"][-1]["adaptiveCards"][0]["body"][0]["text"]
136-
print(response)
137-
p_hist(response)
138-
else:
139-
wrote = 0
140-
if args.rich:
141-
md = Markdown("")
142-
with Live(md, auto_refresh=False) as live:
143-
async for final, response in bot.ask_stream(
144-
prompt=question,
145-
conversation_style=args.style,
146-
wss_link=args.wss_link,
147-
search_result=args.search_result,
148-
locale=args.locale,
149-
):
150-
if not final:
151-
if not wrote:
152-
p_hist(response, end="")
153-
else:
154-
p_hist(response[wrote:], end="")
155-
if wrote > len(response):
156-
print(md)
157-
print(Markdown("***Bing revoked the response.***"))
158-
wrote = len(response)
159-
md = Markdown(response)
160-
live.update(md, refresh=True)
161-
else:
162-
async for final, response in bot.ask_stream(
163-
prompt=question,
164-
conversation_style=args.style,
165-
wss_link=args.wss_link,
166-
search_result=args.search_result,
167-
locale=args.locale,
168-
):
169-
if not final:
170-
if not wrote:
171-
print(response, end="", flush=True)
172-
p_hist(response, end="")
173-
else:
174-
print(response[wrote:], end="", flush=True)
175-
p_hist(response[wrote:], end="")
176-
wrote = len(response)
177-
print()
178-
p_hist()
179-
if args.history_file:
180-
f.close()
114+
response = await bot.ask(
115+
prompt=question,
116+
conversation_style=args.style,
117+
wss_link=args.wss_link,
118+
locale=args.locale,
119+
simplify_response=True
120+
)
121+
print(response.get("text", "No response"))
181122
await bot.close()
182123

183124

@@ -226,13 +167,6 @@ def main() -> None:
226167
required=False,
227168
help="path to cookie file",
228169
)
229-
parser.add_argument(
230-
"--history-file",
231-
type=str,
232-
default="",
233-
required=False,
234-
help="path to history file",
235-
)
236170
parser.add_argument(
237171
"--locale",
238172
type=str,

0 commit comments

Comments
 (0)