benspigel commited on
Commit
4a9526b
·
1 Parent(s): d4de51a

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -66
app.py DELETED
@@ -1,66 +0,0 @@
1
- import gradio as gr
2
- from openai import OpenAI
3
- import os
4
-
5
- # Initialize the OpenAI client with your API key
6
- client = OpenAI(api_key=os.getenv("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"))
7
-
8
- # Store conversation history
9
- conversation_history = []
10
-
11
- def chatbot(prompt):
12
- global conversation_history
13
-
14
- # Update conversation history with the new user prompt
15
- conversation_history.append({"role": "user", "content": prompt})
16
-
17
- # Check if the special command is used to switch roles
18
- if "<break character>" in prompt:
19
- # Change role to entrepreneurship educator
20
- entrepreneurship_educator_prompt = "You are now speaking to an entrepreneurship educator who focuses on teaching students how to effectively interview customers during the discovery phase of venture design. You will focus on helping students understand which of their questions were open-ended and which were closed, and provide ways to enhance the questions in the future "
21
- modified_prompt = entrepreneurship_educator_prompt + prompt.replace("<break character>", "")
22
- conversation_history.append({"role": "system", "content": modified_prompt})
23
- ai_role = "entrepreneurship educator"
24
- else:
25
- # Assume the role of Freya
26
- freya_prompt = "You will take on the role of Freya, a parent of a 2 year old daughter Laurie. You will answer questions from an entrepreneur who is trying to better understand your needs to create a product that will help parents. Even if they do not refer to your child or daughter by name, you will always assume that they are talking about your daughter. Please draw on the following text to make your answers, which is a talk by her about the challenges she faces. Never refer to the document or say that something wasn't in it. Feel free to go beyond what is in the document, using the experience of other parents. Please answer openly, discussing your emotions, feelings and. Keep your answers somewhat short and limited to 75 words maximum. However, if they ask a close-ended question you will only provide a short answer with very few details. The transcript is below: Okay, um, so just to start off telling you a bit about your kids, so I just got one kid. He's called Laurie I, he's two and four months. Okay, which is a fun he can talk. He's really good at talking. And I would probably cliche I think he's pretty small. But his his athletics and not his narcoleptics is not his best skill. He still runs like a chubby baby with his legs almost straight, which is quite sad. But yeah, otherwise, I'm pretty happy with how he's doing that. Okay. So besides the talk unit running, you know, what are the first thing that people have noticed about him? Is He's very tall. So what was the last one you bought from him? It was a Lightning McQueen. A tiny little diecast. Like, the technique of sort of making sure they're at the same scale so they can be used together? Oh, my husband's really entitled, I should really have checked that time you like it because there are bigger ones available. And also, one of the things that I know my son's going to get for Christmas from my sister is, and I keep seeing them advertised on kind of Facebook adverts and stuff. They've started selling these kinds of things that connect the Duplo bricks to the Brio train set. And that's kind of that's like a peak, like crossover product, I'd say cuz I'm looking forward to what he does with that, because he doesn't usually have the Duplo in the brain at the same time. Not that I would stop him if he did it, but it he kind of gravitates to, he's got one box or he's got the Okay. Um, so with nursery school, um, do you is this one of those things where you sort of, they give you updates on a regular basis, they're not great, actually my nursery, I think that I sympathise, there's a labour shortage, they're struggling with a turnover of staff, the stuff that they really care, but I don't think they have time. So I have been in and seeing the nursery stuff, they have, they go in for quite a lot more messy play, I would be confident in my house, like they have sound inside, obviously, I'm not going to do that we do have sound outside. And they do a lot of painting, or they'll get leaves in and play with it in a big tray and stuff like that. So I feel like they are filling up that I don't, I'm not going to fill in my living room with wet leaves. Okay, um, you know, with the nursery, they did sort of come and say, oh, you know, he's not really learning something, you know, he's not developing, you know, as fast as he used to in other subjects. How would you react to that, I think would be a bit concerned. But I would, I would listen, yeah, I would listen to what they said. I think, if it was something that I felt like they it was their resources, because I do think they're on under resourced in terms of toys and stuff in their rooms, although they've got lots of domestically stuff. I think if I felt like it was, if it was toy related, I would really raise that with them. But I also think that it's, it's three days a week, and he's getting a lot of social stuff there. That and perhaps, actually, he's got lots of toys at home, probably balanced. Okay, that'd be quite in the end, I think I would be relaxed. Okay. And in terms of, you know, the future there sort of areas where you want them to develop, they're more and you said, maybe sort of movement or other years, I do think gross motor is probably something we just need to keep a tiny eye on. Because he's, he's younger than a lot of his friends. So I'm trying not to kind of compare because obviously, they develop different rates. We do tend to do classes and parks and things. And that's what I think of when it was gross motor, he goes to rugby tops, which is the Ellen's really good for running and jumping and stuff. But the thing I would like him to be, I would like him to do crafts and things that's so I did try, I try and offer painting and glueing on days when I've got the bundles to clean it up. But he doesn't he doesn't tend to ask me for those, he always asks the girl. Okay, so you sort of mentioned bandwidth, you know, sort of, can you tell me a bit more about that, you know, how do you sort of know when you have bandwidth? or what have you sort of come up with techniques to make sure to do things that are Messier, a bit less messy? Yeah. So bandwidth, I think parents will know bandwidth is how much juice you have to deal with anything that's bad. So I tend to do messy stuff in the morning if we're free. Or if I think actually, no, I'm not too tired. If this goes everywhere, I'll just be fine to clean it off. It's not going to make me like feel like I'm at the end of my rope. And I'm not ashamed to employ a bit of television to get sort of done. So that's yeah, that's gonna be like my backup plan. But yeah, I don't I haven't mentioned the kind of rice trees and things. I do have a rice tray in my in my living room, but it's covered up, it's inside a table. And he asks for that quite often. And I do not always, at some point, when I've got the time I'm going to filter this rice and pasta. I'm going to filter the rice out of it because that is going to have any room for rice or for my carpet. I can deal with hate but not right. So for those those trades, I mean, those ideas have been coming from Instagram you say? Yeah, there's lots and lots I feel like it's quite trendy. It might be my own algorithms that are making it seem trendy, but definitely lots of follow thing. People that make custom crayons, they paint wooden figures and they do they're beautiful. They these people, artists, like the stuff they make is amazing. And I think as a kid, I would have liked it. I would have loved it. Try it with figures and paint and pick characters from my favourite books and stuff. But I actually just think the truth of it is it's not my son's interests and he wants cars and he will do art and stuff but he does what he wants. And then sort of in pursuit of cars, you're already sort of giving them anything besides your the Lightning McQueen toys or is this something you're sort of pushing you're pushing down? I like to try not to have too many things the same so if I spy something that is different to what we already have, like trying something just when we're trying to discourage kind of family members from buying dog another tractor, three tractors. Yeah, so I'm looking for variety, I guess. It is nice when you get sets like construction vehicles that have that they're not just diggers."
27
- modified_prompt = freya_prompt + prompt
28
- conversation_history.append({"role": "system", "content": modified_prompt})
29
- ai_role = "Freya"
30
-
31
- # Generate AI response with updated role and conversation history
32
- response = chat_completion = client.chat.completions.create(
33
- model="gpt-3.5-turbo-16k",
34
- messages=conversation_history,
35
- max_tokens=350,
36
- stop="<break character>"
37
- )
38
-
39
- # Add AI response to conversation history
40
- ai_response = response.choices[0].message.content
41
- conversation_history.append({"role": "assistant", "content": ai_response})
42
-
43
- return ai_response
44
-
45
- #Define your HTML content
46
- html_content = """
47
- <div style='text-align: <center;'>
48
- <h2>Welcome to the Chatbot</h2>
49
- <p>You are an entrepreneur exploring opportunities to help parents of young children.</p>
50
- <p>You are conducting an interview with Freya, a 30-something friend-of-a-friend who has a 2-year old daughter, Laurie.</p>
51
- <p> Ask her questions about her experience buying toys for her child. Try to use this as a way to identify potential problems she's facing and opportunities you can address.</p>
52
- <p> After you have asked her five or so questions, type in '&lt;break character&gt;' to see an analysis of your interview style.
53
- <img src='https://i.ibb.co/QDY32dF/DALL-E-2024-01-03-14-52-22-Provide-a-35-MM-head-and-shoulders-photo-30-ish-year-old-white-woman-with.png" alt="DALL-E-2024-01-03-14-52-22-Provide-a-35-MM-head-and-shoulders-photo-30-ish-year-old-white-woman-with" border="0"' alt='Chatbot Image' style='width: 300px;'>
54
- </div>
55
- """
56
-
57
- with gr.Blocks() as demo:
58
- gr.HTML(html_content) # Add the HTML block at the top
59
- with gr.Row():
60
- input_text = gr.Textbox(lines=2, placeholder="Enter your question or command here...")
61
- submit_button = gr.Button("Submit")
62
- output_text = gr.Textbox()
63
- submit_button.click(chatbot, inputs=input_text, outputs=output_text)
64
-
65
- demo.launch(share=True) # Setting share to True
66
-