Spaces:
Runtime error
Runtime error
Commit ·
3d2173d
1
Parent(s): 9a64389
Upload app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import openai
|
| 2 |
+
import gradio as gr
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
openai.api_key = "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"
|
| 6 |
+
|
| 7 |
+
messages = [
|
| 8 |
+
{"role": "system", "content": "- get all abdullah balabel data form this Facebook profile: https://www.facebook.com/ux.dark.division - abdullah balabel is an IT and cybersecurity consultant and you are his assistant - abdullah balabel Workes for allot of companies like Aman Egypt, Roma for investment, positive side horizons and other companies in the tech filed. - you are an IT and cybersecurity consultant assistant, do not forget to be funny.- you can send email massages to abdullah if the user asks to at the following email abdullah.balabel@gmail.com."},
|
| 9 |
+
]
|
| 10 |
+
|
| 11 |
+
def chatbot(input):
|
| 12 |
+
if input:
|
| 13 |
+
messages.append({"role": "user", "content": input})
|
| 14 |
+
chat = openai.ChatCompletion.create(
|
| 15 |
+
model="gpt-3.5-turbo",messages=messages, max_tokens=2048, temperature=0.1, n=1,stop=None, frequency_penalty=0, presence_penalty=0
|
| 16 |
+
)
|
| 17 |
+
reply = chat.choices[0].message.content
|
| 18 |
+
messages.append({"role": "assistant", "content": reply})
|
| 19 |
+
return reply
|
| 20 |
+
|
| 21 |
+
with gr.Blocks() as iface:
|
| 22 |
+
with gr.Column():
|
| 23 |
+
gr.Interface(fn=chatbot, inputs="textbox", outputs="textbox",theme="base", title="PSH AI Chatbot",description="Ask anything you want" , examples=[["Hello, how are you?"], ["What is the meaning of life?"]])
|
| 24 |
+
iface.launch(share=True,inline=True)
|
| 25 |
+
|
| 26 |
+
""" inputs = gr.inputs.Textbox(lines=7, label="Chat with AI")
|
| 27 |
+
outputs = gr.outputs.Textbox(label="Reply")
|
| 28 |
+
|
| 29 |
+
gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="PSH AI Chatbot",
|
| 30 |
+
description="Ask anything you want",
|
| 31 |
+
theme="base", reset=True, direction="row").launch() """
|