Spaces:
Sleeping
Sleeping
Commit
·
aa5c113
1
Parent(s):
0778433
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import openai
|
| 2 |
+
import gradio as gr
|
| 3 |
+
import os
|
| 4 |
+
from dotenv import load_dotenv
|
| 5 |
+
load_dotenv()
|
| 6 |
+
|
| 7 |
+
# OPEN_AI_KEY='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'
|
| 8 |
+
openai.api_key ='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'#
|
| 9 |
+
# openai.api_key = os.getenv(OPEN_AI_KEY)
|
| 10 |
+
|
| 11 |
+
messages = [
|
| 12 |
+
{"role": "system", "content": "You are an AI assistant that only gives responses from the website https://i-venture.org/ and you help people make decisions about how to make a difference in others' lives. You also provide the relevant links from that website as part of your answers."},
|
| 13 |
+
]
|
| 14 |
+
|
| 15 |
+
def chatbot(input):
|
| 16 |
+
if input:
|
| 17 |
+
messages.append({"role": "user", "content": input})
|
| 18 |
+
chat = openai.ChatCompletion.create(
|
| 19 |
+
model="gpt-3.5-turbo", messages=messages
|
| 20 |
+
)
|
| 21 |
+
reply = chat.choices[0].message.content
|
| 22 |
+
messages.append({"role": "assistant", "content": reply})
|
| 23 |
+
return reply
|
| 24 |
+
|
| 25 |
+
inputs = gr.inputs.Textbox(lines=7, label="Chat with I-venture @ ISB AI powered bot")
|
| 26 |
+
outputs = gr.outputs.Textbox(label="Reply")
|
| 27 |
+
|
| 28 |
+
gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="Talk with Bhagwan at I-venture @ ISB",
|
| 29 |
+
description="Anything you want to find out about entreprenuership at ISB. Sample questions include >>> how to get incubated at ISB Dlabs? >>> What is the latest event being organized by I-venture @ ISB? >>> and more",
|
| 30 |
+
theme="compact").launch(share=True, debug=True)
|