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

Chat interface updates - new flags for multi-line input, model choice selection, updated paragraph wrapping for output and option flag to disable, and minor bugfixes #230

Closed
wants to merge 7 commits into from

Conversation

PeteHemery
Copy link

Following on the inspiration to share back to the community from PR 227, I offer these improvements.
The commit messages should have most of the info there.
I did modify/comment out this line
text = resp_answer #click.wrap_text(resp_answer, width=78, preserve_paragraphs=True)
since the formatted text returned does look right when it prints mardown code.

Let me know what you think.

@PeteHemery
Copy link
Author

Ah, also added a mini timeout feature, for when requests occasionally go bad. Probably should change the commit message to reflect that. Will wait for feedback

@PeteHemery PeteHemery marked this pull request as draft June 17, 2024 19:34
@PeteHemery
Copy link
Author

split commits up into manageable chunks. hope some are good for cherry picking

@PeteHemery PeteHemery changed the title Chat interface updates - multi-line input, model choice selection new flags, and minor bugfixes Chat interface updates - new flags multi-line input, model choice selection, updated and option to disable paragraph wrapping for output and and minor bugfixes Jun 17, 2024
@PeteHemery PeteHemery changed the title Chat interface updates - new flags multi-line input, model choice selection, updated and option to disable paragraph wrapping for output and and minor bugfixes Chat interface updates - new flags for multi-line input, model choice selection, updated paragraph wrapping for output and option flag to disable, and minor bugfixes Jun 17, 2024
@PeteHemery PeteHemery marked this pull request as ready for review June 17, 2024 20:39
@PeteHemery PeteHemery force-pushed the chat-interface-updates branch 5 times, most recently from c61e9e3 to 2e12df4 Compare June 17, 2024 22:45
@PeteHemery
Copy link
Author

PeteHemery commented Jun 17, 2024

always with the "just one more thing" with git ;)
played with this a lot today.

FYI, my usage style with these changes is:

$ ddgs chat -m1 -M -w <<< "replace these three words with emojis
python
coding
updates"
DuckDuckGo AI chat.
Using model: gpt-3.5
You typed:
replace these three words with emojis
python
coding
updates
Waiting for response
AI:
Sure! Here are the emojis for the words you provided:
🐍
💻
🔄

I've also been making some improvements to the save chat functionality too. being able to name saved chats as you start them, and allowing branches with reworking from a certain point. need to save the chat_vdqs along the way. open for a discussion, if it'd be of any interest?

Pete Hemery added 4 commits June 18, 2024 00:42
Previous output:
```python import click

def wrap_text_with_newlines(text, width=78):     paragraphs = text.split('\n')
wrapped_paragraphs = [click.wrap_text(paragraph, width=width) for paragraph in
paragraphs]     return '\n'.join(wrapped_paragraphs)

text = "This is a sample text.\n\nIt has multiple paragraphs.\nEach paragraph
should be wrapped separately." wrapped_text = wrap_text_with_newlines(text,
width=78) print(wrapped_text) ```

Updated output:
```python
import click

def wrap_text_with_newlines(text, width=78):
    paragraphs = text.split('\n')
    wrapped_paragraphs = [click.wrap_text(paragraph, width=width) for
    paragraph in paragraphs]
    wrapped_text = '\n'.join(wrapped_paragraphs)
    return wrapped_text

text = "This is a sample text.\nIt has multiple lines.\nEach line should be
wrapped separately."

wrapped_text = wrap_text_with_newlines(text, width=20)
print(wrapped_text)
```
Allow the user to enter multiple lines in a single prompt.
Remind the user that the EOF command key will finish the input.
When dealing with large amount of text as a prompt, it's easier to edit
 command line history when copying and pasting a number of paragraphs.

When asking coding questions it's useful to be able to edit multi-line
 input after pasting, which can't be done in the interactive console.

This new functionality will assume multi-line input is enabled, and
 check between interactive console and piping from stdin behaviour.

Since longer prompts take longer to respond, increase the timeout to 30s
@deedy5
Copy link
Owner

deedy5 commented Jun 19, 2024

The code is overcomplicated.

@deedy5 deedy5 closed this Jun 19, 2024
Repository owner deleted a comment from PeteHemery Jun 19, 2024
Repository owner locked as spam and limited conversation to collaborators Jun 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants