darshil3011 commited on
Commit
2c02f83
1 Parent(s): e6e927f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import openai
2
+ import gradio as gr
3
+
4
+ # Set your OpenAI API key here
5
+ api_key = "YOUR_API_KEY"
6
+
7
+ # Initialize the OpenAI API client
8
+ openai.api_key = api_key
9
+
10
+ # Define a function to generate responses using GPT-3.5 Turbo
11
+ def generate_response(prompt):
12
+ response = openai.Completion.create(
13
+ model="gpt-3.5-turbo", # Use GPT-3.5 Turbo engine
14
+ prompt=prompt,
15
+ max_tokens=50, # You can adjust this to limit the response length
16
+ )
17
+ return response.choices[0].text
18
+
19
+ # Create a Gradio interface
20
+ iface = gr.Interface(
21
+ fn=generate_response,
22
+ inputs="text",
23
+ outputs="text",
24
+ title="Detect Prompt Category",
25
+ description="Enter a prompt, and GPT-3.5 Turbo will generate a response.",
26
+ )
27
+
28
+ # Start the Gradio interface
29
+ iface.launch()