Spaces:
Sleeping
Sleeping
akhilhsingh
commited on
Commit
•
de4f6a6
1
Parent(s):
dff02c2
Delete main
Browse files
main
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
import requests
|
3 |
-
|
4 |
-
def chat_with_gpt3_via_fastapi(prompt):
|
5 |
-
# Make sure the URL matches your FastAPI server's address and the correct endpoint
|
6 |
-
response = requests.get("http://127.0.0.1:8000/chat/", json={"?prompt": prompt})
|
7 |
-
if response.status_code == 200:
|
8 |
-
return response.json()["response"]
|
9 |
-
else:
|
10 |
-
return f"Error: {response.status_code}, {response.text}"
|
11 |
-
|
12 |
-
interface = gr.Interface(
|
13 |
-
fn=chat_with_gpt3_via_fastapi,
|
14 |
-
inputs=gr.Textbox(lines=2, placeholder="Enter your message here..."),
|
15 |
-
outputs="text",
|
16 |
-
title="GPT-3.5 Turbo Chatbot with FastAPI",
|
17 |
-
description="This chatbot uses a FastAPI backend to communicate with OpenAI's GPT-3.5 Turbo.",
|
18 |
-
)
|
19 |
-
|
20 |
-
if __name__ == "__main__":
|
21 |
-
interface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|