Spaces:
Sleeping
Sleeping
Delete file1_chatgpt.py
Browse files- file1_chatgpt.py +0 -42
file1_chatgpt.py
DELETED
@@ -1,42 +0,0 @@
|
|
1 |
-
# -*- coding: utf-8 -*-
|
2 |
-
"""File1_chatgpt.ipynb
|
3 |
-
|
4 |
-
Automatically generated by Colaboratory.
|
5 |
-
|
6 |
-
Original file is located at
|
7 |
-
https://colab.research.google.com/drive/1ips60VEBlb1HaAsIsz41BfMWXUBjNlsG
|
8 |
-
"""
|
9 |
-
|
10 |
-
!pip install openai
|
11 |
-
|
12 |
-
!pip install gradio
|
13 |
-
|
14 |
-
import os
|
15 |
-
import openai
|
16 |
-
|
17 |
-
openai.api_key="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"
|
18 |
-
|
19 |
-
def get_completion(prompt, model="gpt-3.5-turbo"):
|
20 |
-
messages = [{"role": "user", "content": prompt}]
|
21 |
-
response = openai.ChatCompletion.create(
|
22 |
-
model=model,
|
23 |
-
messages=messages,
|
24 |
-
temperature=0,
|
25 |
-
)
|
26 |
-
return response.choices[0].message["content"]
|
27 |
-
|
28 |
-
import gradio as gr
|
29 |
-
|
30 |
-
# Variable to store the user input
|
31 |
-
user_input = ""
|
32 |
-
|
33 |
-
def store_string(input_string,history):
|
34 |
-
# Store the input_string in the global variable
|
35 |
-
global user_input
|
36 |
-
return get_completion(input_string)
|
37 |
-
|
38 |
-
# Create an interface with a text input and a submit button
|
39 |
-
#interface = gr.Interface(fn=store_string, inputs=gr.inputs.Textbox(), outputs="text", allow_flagging= "auto")
|
40 |
-
interface =gr.ChatInterface(store_string,analytics_enabled=True)
|
41 |
-
interface.launch(share=True, inbrowser= True, auth = ('rrr','#la_rocks'), auth_message= "Enter your username and password that you received in on LA group")
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|