Upload folder using huggingface_hub
Browse files- README.md +2 -8
- chatbot-gpt.py +27 -0
README.md
CHANGED
@@ -1,12 +1,6 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
|
4 |
-
colorFrom: blue
|
5 |
-
colorTo: pink
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.42.0
|
8 |
-
app_file: app.py
|
9 |
-
pinned: false
|
10 |
---
|
11 |
-
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: iabot
|
3 |
+
app_file: chatbot-gpt.py
|
|
|
|
|
4 |
sdk: gradio
|
5 |
sdk_version: 3.42.0
|
|
|
|
|
6 |
---
|
|
|
|
chatbot-gpt.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
|
3 |
+
import openai
|
4 |
+
import gradio as gr
|
5 |
+
|
6 |
+
openai.api_key = "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"
|
7 |
+
|
8 |
+
messages = [
|
9 |
+
{"role": "system", "content": "You are a helpful and kind AI Assistant."},
|
10 |
+
]
|
11 |
+
|
12 |
+
def chatbot(input):
|
13 |
+
if input:
|
14 |
+
messages.append({"role": "user", "content": input})
|
15 |
+
chat = openai.ChatCompletion.create(
|
16 |
+
model="gpt-3.5-turbo", messages=messages
|
17 |
+
)
|
18 |
+
reply = chat.choices[0].message.content
|
19 |
+
messages.append({"role": "assistant", "content": reply})
|
20 |
+
return reply
|
21 |
+
|
22 |
+
inputs = gr.inputs.Textbox(lines=7, label="Chat with AI")
|
23 |
+
outputs = gr.outputs.Textbox(label="Reply")
|
24 |
+
|
25 |
+
gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="ChatGPT : Meow!",
|
26 |
+
description="Ask anything you want",
|
27 |
+
theme="compact").launch(share=True)
|