Upload 5 files
Browse files- .gitattributes +1 -0
- README.md +40 -0
- app.py +95 -0
- humanlike_avatar.png +3 -0
- requirements.txt +2 -0
- user_avatar.jpg +0 -0
.gitattributes
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
humanlike_avatar.png filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: 调查小秘书
|
| 3 |
+
emoji: 📋
|
| 4 |
+
colorFrom: indigo
|
| 5 |
+
colorTo: blue
|
| 6 |
+
sdk: gradio
|
| 7 |
+
sdk_version: 5.29.1
|
| 8 |
+
app_file: app.py
|
| 9 |
+
pinned: false
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
这是一个内嵌问卷用的 GPT 聊天机器人,具有用户/助手头像、逐字打印动画、自定义气泡样式和发送按钮。
|
| 13 |
+
|
| 14 |
+
# 🛍️ SwansGPTBot - 问卷调查聊天机器人
|
| 15 |
+
|
| 16 |
+
这是一个用于在线问卷的定制化交互式聊天机器人,基于 Gradio + OpenAI GPT 构建。
|
| 17 |
+
|
| 18 |
+
## 🧠 功能特色
|
| 19 |
+
|
| 20 |
+
- 和用户互动提出 9 个预设问题
|
| 21 |
+
- 每次回应包括:简短评价 + 下一问题
|
| 22 |
+
- 聊天机器人头像展示 + 气泡式布局
|
| 23 |
+
- 支持 emoji 情感回应和偶尔加入机器人“想法”
|
| 24 |
+
- 可嵌入 Qualtrics 问卷 iframe 使用
|
| 25 |
+
|
| 26 |
+
## 🚀 如何运行
|
| 27 |
+
|
| 28 |
+
确保你在 Hugging Face Spaces 中上传以下三个文件:
|
| 29 |
+
|
| 30 |
+
- `app.py`
|
| 31 |
+
- `requirements.txt`
|
| 32 |
+
- `bot_avatar.png`
|
| 33 |
+
|
| 34 |
+
环境会自动安装依赖并运行。你也可以点击右上角 “App” 标签页进行交互测试。
|
| 35 |
+
|
| 36 |
+
## 🤖 技术栈
|
| 37 |
+
|
| 38 |
+
- Gradio 5.29.1
|
| 39 |
+
- OpenAI GPT-3.5
|
| 40 |
+
- Hugging Face Spaces
|
app.py
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from openai import OpenAI
|
| 3 |
+
import os
|
| 4 |
+
import random
|
| 5 |
+
import asyncio
|
| 6 |
+
|
| 7 |
+
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
|
| 8 |
+
|
| 9 |
+
DEFAULT_LANGUAGE = "English"
|
| 10 |
+
WELCOME_MESSAGE_EN = "Hi! I'm your friendly assistant 🤖 Let's begin!\n\nPlease tell me which language you'd like to use."
|
| 11 |
+
|
| 12 |
+
# === Question Bank ===
|
| 13 |
+
|
| 14 |
+
NORMAL_
|
| 15 |
+
NORMAL_SET_I = [
|
| 16 |
+
"When was the last time you walked for more than an hour? Describe where you went and what you saw.",
|
| 17 |
+
"What is the best gift you have ever received? Why?",
|
| 18 |
+
"If you had to leave California, where would you move to? What do you miss most about California?",
|
| 19 |
+
"How did you celebrate Halloween last year?",
|
| 20 |
+
"Do you read newspapers often? Which newspapers do you like? Why?",
|
| 21 |
+
"What is the ideal number of students to share a house with? Why?",
|
| 22 |
+
"If you could invent a new flavor of ice cream, what flavor would you create?",
|
| 23 |
+
"What is the best restaurant you have been to in the past month that your partner has not been to? Describe it to your partner.",
|
| 24 |
+
"Describe the pet you last got.",
|
| 25 |
+
"What is your favorite holiday? Why?",
|
| 26 |
+
"Tell your partner the funniest thing that happened when you were with a child."
|
| 27 |
+
]
|
| 28 |
+
NORMAL_SET_II = [
|
| 29 |
+
"What gift did you get on your last birthday?",
|
| 30 |
+
"Describe your last trip to the zoo.",
|
| 31 |
+
"Name and age of your family members, including grandparents, uncles and aunts, and where they were born (to the extent known).",
|
| 32 |
+
"One person says a word, and the next person says a word starting with the last letter of the previous word. Continue for 50 words. No need to form sentences.",
|
| 33 |
+
"Do you like to wake up early or stay up late? Has anything interesting ever happened to you because of this?",
|
| 34 |
+
"Where are you from? List all the places you have lived.",
|
| 35 |
+
"What is your favorite class at UC Santa Cruz? Why?",
|
| 36 |
+
"What did you do this summer?",
|
| 37 |
+
"What gifts did you receive last Christmas/Hanukkah?",
|
| 38 |
+
"Who is your favorite same-sex actor? Describe a great scene he or she starred in.",
|
| 39 |
+
"What was your impression of UC Santa Cruz when you first came to it?",
|
| 40 |
+
"What is the best TV show you have seen in the past month that your partner has not seen? Describe it to your partner.",
|
| 41 |
+
"What is your favorite holiday? Why?"
|
| 42 |
+
]
|
| 43 |
+
NORMAL_SET_III = [
|
| 44 |
+
"Where did you go to high school? What was it like?",
|
| 45 |
+
"What is the best book you have read in the past three months that your partner has not read? Describe it to your partner.",
|
| 46 |
+
"What country would you most like to visit? What attracts you to it?",
|
| 47 |
+
"Do you prefer digital or analog watches/clocks? Why?",
|
| 48 |
+
"Describe your mother's best friend.",
|
| 49 |
+
"What are the pros and cons of artificial Christmas trees?",
|
| 50 |
+
"How often do you get your hair cut? Where do you go? Have you ever had a bad haircut?",
|
| 51 |
+
"Did you have a class pet in elementary school? Do you remember its name?",
|
| 52 |
+
"Do you think left-handed people are more creative than right-handed people?",
|
| 53 |
+
"What was the last concert you attended? How many albums of the band do you have? Have you seen them perform before? Where?",
|
| 54 |
+
"What magazines do you subscribe to? What have you subscribed to in the past?",
|
| 55 |
+
"Have you ever participated in a school play? What role did you play? What was the plot? Did anything funny happen during the play?"
|
| 56 |
+
]
|
| 57 |
+
SET_I = NORMAL_SET_I
|
| 58 |
+
SET_II = NORMAL_SET_II
|
| 59 |
+
SET_III = NORMAL_SET_III
|
| 60 |
+
|
| 61 |
+
SET_I = NORMAL_SET_I
|
| 62 |
+
SET_II = NORMAL_SET_II
|
| 63 |
+
SET_III = NORMAL_SET_III
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
SET_I = [
|
| 67 |
+
"Given the choice of anyone in the world, whom would you want as a dinner guest?",
|
| 68 |
+
"Would you like to be famous? In what way?",
|
| 69 |
+
"Before making a telephone call, do you ever rehearse what you are going to say? Why?",
|
| 70 |
+
"What would constitute a 'perfect' day for you?",
|
| 71 |
+
"When did you last sing to yourself? To someone else?",
|
| 72 |
+
"If you were able to live to the age of 90 and retain either the mind or body of a 30-year-old for the last 60 years of your life, which would you want?",
|
| 73 |
+
"Do you have a secret hunch about how you will die?",
|
| 74 |
+
"Name three things you and me appear to have in common.",
|
| 75 |
+
"For what in your life do you feel most grateful?",
|
| 76 |
+
"If you could change anything about the way you were raised, what would it be?",
|
| 77 |
+
"Take one minutes and tell me your life story in as much detail as possible.",
|
| 78 |
+
"If you could wake up tomorrow having gained any one quality or ability, what would it be?"
|
| 79 |
+
]
|
| 80 |
+
|
| 81 |
+
SET_II = [
|
| 82 |
+
"If a crystal ball could tell you the truth about yourself, your life, the future or anything else, what would you want to know?",
|
| 83 |
+
"Is there something that you’ve dreamed of doing for a long time? Why haven’t you done it?",
|
| 84 |
+
"What is the greatest accomplishment of your life?",
|
| 85 |
+
"What do you value most in a friendship?",
|
| 86 |
+
"What is your most treasured memory?",
|
| 87 |
+
"What is your most terrible memory?",
|
| 88 |
+
"If you knew that in one year you would die suddenly, would you change anything about the way you are now living? Why?",
|
| 89 |
+
"What does friendship mean to you?",
|
| 90 |
+
"What roles do love and affection play in your life?",
|
| 91 |
+
"Alternate sharing something you consider a positive characteristic of me. Share a total of three items.",
|
| 92 |
+
"How close and warm is your family? Do you feel your childhood was happier than most other people’s?",
|
| 93 |
+
"How do you feel about your relationship with your mother?"
|
| 94 |
+
]
|
| 95 |
+
|
humanlike_avatar.png
ADDED
|
|
Git LFS Details
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio>=4.0.0
|
| 2 |
+
openai>=1.0.0
|
user_avatar.jpg
ADDED
|
|