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

Add ability to define custom image as an avatar by passing image url #34

Merged
merged 1 commit into from
May 11, 2023
Merged

Conversation

ahmadassaf
Copy link
Contributor

Adds the ability to define a custom Avatar image using an image URL

Example

message("Hey, \nwhat's a chatbot?", is_user=True, avatar="{URL}")

@felix0307
Copy link

Hello! Can you explain, how install the correct version of st-chat with this functionality? And please add the snippet with an example of using it.

@PascalHessler
Copy link

@felix0307

Right now it seems that the repositiry is not up to date, since the React component is still in an older version. I did build my own version, this should also work for you :)

Quick instructions to generate the newest build:

  1. fork this repo
  2. go to streamlit_chat/init.py and change "_RELEASE" to True
  3. (make additional changes to the repo)
  4. Since the original repo does not have the newest builded version of the react component we have to build a new one:
    1. go to streamlit_chat\frontend
    2. run npm install
    3. run npm run build
  5. Push everything to your repo
  6. now you created your own python package and you can install it with pip install git+https://your_repo

@eshaanagarwal
Copy link

eshaanagarwal commented Jun 7, 2023

Hey is this packaged as a part of the newest release ? @yashppawar @YashVardhan-AI it would be great if guys could get this all packaged as a new version

@shanshanRT
Copy link

Same issue here there is no "avatar" parameter in the latest version ..

@yashppawar
Copy link
Member

Same issue here there is no "avatar" parameter in the latest version ..

sorry for the misunderstanding, the PR suggested logo as the parameter taking URL as an input, so you will have to use that parameter

message('user message', is_user=True, logo=f'{USER_AVATAR_URL}')

check out static file serving if you want to use local image...

Lin-jun-xiang added a commit to Lin-jun-xiang/docGPT-langchain that referenced this pull request Aug 24, 2023
1. clean code
2. add the avatar base on sreamlit_chat: AI-Yash/st-chat#34
Lin-jun-xiang added a commit to Lin-jun-xiang/docGPT-langchain that referenced this pull request Sep 1, 2023
Lin-jun-xiang added a commit to Lin-jun-xiang/docGPT-langchain that referenced this pull request Sep 1, 2023
Lin-jun-xiang added a commit to Lin-jun-xiang/docGPT-langchain that referenced this pull request Sep 1, 2023
Lin-jun-xiang added a commit to Lin-jun-xiang/docGPT-langchain that referenced this pull request Sep 1, 2023
Lin-jun-xiang added a commit to Lin-jun-xiang/docGPT-langchain that referenced this pull request Sep 1, 2023
@kz24kz24kz24
Copy link

hi! My codes are like the following; how can I replace the default avatar with a local image? I'm running it locally. Thanks so much!


def predict(input, max_length, top_p, temperature, history=None):
tokenizer, model = get_model()
if history is None:
history = []

with container:
    if len(history) > 0:
        if len(history) > MAX_BOXES:
            history = history[-MAX_TURNS:]
        for i, (query, response) in enumerate(history):
            message(query, avatar_style="big-smile", key=str(i) + "_user")
            message(response, avatar_style="bottts", key=str(i) + "_robot")

    message(input, avatar_style="big-smile", key=str(len(history)) + "_user")
    st.write("Bot is typing:")

@yashppawar
Copy link
Member

Hello @kz24kz24kz24, you can use Static File Serving with streamlit for your local images.

Alternatively, you can switch to Chat Elements from streamlit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants