Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
!pip install openai
|
3 |
+
|
4 |
+
!pip install gradio
|
5 |
+
|
6 |
+
import os
|
7 |
+
import openai
|
8 |
+
|
9 |
+
openai.api_key="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"
|
10 |
+
|
11 |
+
def get_completion(prompt, model="gpt-3.5-turbo"):
|
12 |
+
messages = [{"role": "user", "content": prompt}]
|
13 |
+
response = openai.ChatCompletion.create(
|
14 |
+
model=model,
|
15 |
+
messages=messages,
|
16 |
+
temperature=0,
|
17 |
+
)
|
18 |
+
return response.choices[0].message["content"]
|
19 |
+
|
20 |
+
import gradio as gr
|
21 |
+
|
22 |
+
# Variable to store the user input
|
23 |
+
user_input = ""
|
24 |
+
|
25 |
+
def store_string(input_string,history):
|
26 |
+
# Store the input_string in the global variable
|
27 |
+
global user_input
|
28 |
+
return get_completion(input_string)
|
29 |
+
|
30 |
+
# Create an interface with a text input and a submit button
|
31 |
+
#interface = gr.Interface(fn=store_string, inputs=gr.inputs.Textbox(), outputs="text", allow_flagging= "auto")
|
32 |
+
interface =gr.ChatInterface(store_string,analytics_enabled=True)
|
33 |
+
interface.launch(share=True, inbrowser= True, auth = ('rrr','#la_rocks'), auth_message= "Enter your username and password that you received in on LA group")
|