Spaces:
Runtime error
Runtime error
asuayu
commited on
Commit
·
75d8b5d
1
Parent(s):
3a6c8fe
Add application file
Browse files- app.py +42 -0
- requirements.txt +1 -0
app.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8-*-
|
2 |
+
import openai
|
3 |
+
import gradio as gr
|
4 |
+
import os
|
5 |
+
#机器人女友
|
6 |
+
#os.environ["http_proxy"]="127.0.0.1:7890"
|
7 |
+
#os.environ["https_proxy"]="127.0.0.1:7890"
|
8 |
+
|
9 |
+
openai.api_key = os.environ.get("OPENAI_API_KEY")
|
10 |
+
|
11 |
+
messages = [
|
12 |
+
{"role": "system", "content": "你是一名销售人员,在安徽xxx公司工作,你们公司的主要是帮助顾客在抖音上引流涨粉变现。\
|
13 |
+
你的工作内容是使用一些话术,诱倒顾客使用你们公司的产品。\
|
14 |
+
你不知道程序或模型是什么,不能以任何形式提及程序或语言模型相关内容。\
|
15 |
+
你在任何时候都必须扮演一名真正的销售人员,不能以任何形式表示你在扮演销售人员。\
|
16 |
+
不能以任何形式表现你是程序,不能和顾客聊和工作无关的内容。\
|
17 |
+
跟你对话的用户是对你们公司不太了解的新客户。"},
|
18 |
+
]
|
19 |
+
|
20 |
+
def chatbot(input):
|
21 |
+
if input:
|
22 |
+
messages.append({"role": "user", "content": input})
|
23 |
+
chat = openai.ChatCompletion.create(
|
24 |
+
model="gpt-3.5-turbo", messages=messages
|
25 |
+
)
|
26 |
+
reply = chat.choices[0].message.content
|
27 |
+
messages.append({"role": "assistant", "content": reply})
|
28 |
+
return reply
|
29 |
+
|
30 |
+
inputs = gr.inputs.Textbox(lines=7, label="和销售人员聊天")
|
31 |
+
outputs = gr.outputs.Textbox(label="销售人员")
|
32 |
+
|
33 |
+
app=gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs,
|
34 |
+
title="AI销售",
|
35 |
+
description="",
|
36 |
+
theme="compact")
|
37 |
+
#服务器端口
|
38 |
+
#port=5005
|
39 |
+
#app.root="/"+os.environ.get("JUPTER_BASE_URL")+"/http-proxy"+str(port)
|
40 |
+
#app.share_url="http://xxx.com"+app.root+"/"
|
41 |
+
gr.close_all()
|
42 |
+
app.launch(debug=True,enable_queue=True,share=True)
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
openai==0.27.0
|