-
Notifications
You must be signed in to change notification settings - Fork 81
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
Updated Chat Assistant and Social Post Generator tutorials #629
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are great and like 85% of the way there. I stepped through the chat one and left notes, and then read through the social post one and left more notes.
I've run out of time to go through the social one one step by step. You can apply basically all of the suggestions for the chat assistant one to this one (e.g. linking to guides, etc) and then tag @ajot to step through the social post one.
docs/framework/chat-assistant.mdx
Outdated
- **A Writer account:** Create a free account at [writer.com](https://writer.com). | ||
- **Python 3.7+**: Use the installer from [python.org](https://www.python.org/downloads/). | ||
- **pip:** This command-line application comes with Python and is used for installing Python packages, including those from Writer. | ||
- **Your favorite code editor:** You'll need one — such as Visual Studio Code, Notepad++, Vim, Emacs, or any text editor made for programming — to write the back-end code behind the user interface. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's note that the code editor is optional since you can use the in-browser one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
docs/framework/chat-assistant.mdx
Outdated
|
||
Before starting, ensure you have: | ||
|
||
- **A Writer account:** Create a free account at [writer.com](https://writer.com). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a link to the Writer AI Studio signup: https://app.writer.com/aistudio/signup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
docs/framework/chat-assistant.mdx
Outdated
```bash Standard port | ||
writer edit chat-assistant | ||
``` | ||
<Step title="Create a .env file"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a note that if they are using the in-browser code editor, they can instead export the key in their terminal session.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. I decided to keep the tutorial simple by skipping the .env
file entirely and simply exporting the key to their terminal session.
|
||
Before starting, ensure you have: | ||
|
||
- **A Writer account:** Create a free account at [writer.com](https://writer.com). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto on Writer AI Studio signup/text https://app.writer.com/aistudio/signup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
- **A Writer account:** Create a free account at [writer.com](https://writer.com). | ||
- **Python 3.7+**: Use the installer from [python.org](https://www.python.org/downloads/). | ||
- **pip:** This command-line application comes with Python and is used for installing Python packages, including those from Writer. | ||
- **Your favorite code editor:** You'll need one — such as Visual Studio Code, Notepad++, Vim, Emacs, or any text editor made for programming — to write the back-end code behind the user interface. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto on this being optional and point out the in-browser editor as an option
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
docs/framework/chat-assistant.mdx
Outdated
This code uses the streaming function of the `Conversation` method, which is a wrapper for the `chat` API endpoint. Each chunk returned from the stream is added to the `conversation` variable in the application state. | ||
The `generate_completion()` function will be called when the user enters a prompt, which is contained in the `payload` object. The `payload` object is added to the `conversation` object contained in the application's `state`, which adds the user's prompt to the record of the conversation between the user and the LLM. | ||
|
||
After adding the user's prompt to the conversational record, `generate_completion()` calls the `conversation` object's `stream_complete()` method, which generates an LLM completion based on the conversation so far. As its name implies, `stream_complete()` returns the completion as a stream of text chunks, which are captured and added to the `conversation` object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's link to the AI module guide at the end of this if people want to learn more, for example if they want to learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
```python | ||
# Initialize the state | ||
wf.init_state({ | ||
"conversation": writer.ai.Conversation(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worth calling out here that you can pass configuration into this such as what model you want to use and then link to the AI module guide.
docs/framework/chat-assistant.mdx
Outdated
|
||
![Finished chat assistant project](/framework/images/tutorial/chat/chat_assistant_6.png) | ||
The application is ready to run locally! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make sure that it's clear somewhere in this tutorial and at this part that you can always see the running application using the "Preview" button at the top. As a reader I'd be wondering:
- Why do I have to quit and re-run it in order to see my changes?
- What's the difference between
writer edit
Preview andwriter run
Let's answer those questions here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
docs/framework/chat-assistant.mdx
Outdated
|
||
```python | ||
def generate_completion(state, payload): | ||
print(f"Here's what the user entered: {payload['content']}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love all of the print statements here for debugging, but you can just call it out in the para below? Something about how there are some optional print statements in there to help with debugging, feel free to remove them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
@@ -2,218 +2,410 @@ | |||
title: "Social post generator" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've run out of time to go through this one step by step, but you could apply basically all of the suggestions for the chat assistant one to this one (e.g. linking to guides, etc) and then tag @ajot to step through the social post one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few image issues but everything else is looking good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AccordionGuy can you retake this so you don't see the cursor in the corner?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AccordionGuy can you retake this so you don't see the cursor in the corner?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AccordionGuy can you retake this so you don't see the cursor in the corner?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AccordionGuy can you retake this so you don't see the cursor in the corner?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AccordionGuy can you retake this so you don't see the cursor in the corner?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
|
||
![The working social post generator, with the project editor in "Preview" mode and the log pane displayed](/framework/images/tutorial/chat/chat_assistant_2g.png) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AccordionGuy this image isn't displaying for me, may need to double-check it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!
@ramedina86 I’ve updated the Chat assistant and Social post generator tutorials as requested by @samjulien. I’ve made the final changes and they’re ready to be published. |
|
||
There are two ways to edit `main.py`: | ||
|
||
1. **In your browser.** Click on the **Code** button near the top right corner of the project editor page. A pane with the name **Code** will appear at the bottom half of the screen, displaying and allowing you to edit the contents of `main.py`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
near the top right corner
When updating screenshots, please make sure that these references are also updated.
|
||
Before starting, ensure you have: | ||
|
||
- **A Writer account:** You'll need an account to use Writer Framework, and [you can sign up for a free one](https://app.writer.com/aistudio/signup). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need an account to use Writer Framework
Can we change this? In fact, we should start emphasizing everywhere that you don't need a Writer account to use Writer Framework, only to use Writer's AI features which are accessible via the Framework.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah good catch @ramedina86 -- yes @AccordionGuy let's say something like "You'll need an account to use the AI module in Writer Framework"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, be sure to do it in both tutorials too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated!
@samjulien @ramedina86 I’ve made the updates — new screenshots and confirmed that the text matches the updated UI. |
I’ve updated the Chat Assistant and Social Post Generator tutorials based on @ajot’s and @samjulien’s revisions, as requested in this Jira ticket.