Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import openai | |
| import os | |
| openai.api_key = os.environ.get('openai_api_key') | |
| def chatbot(input): | |
| prompt = "You are interacting with an AI model that can provide information about the input features and target output values of a machine learning model for predicting oil production. You can ask questions about the specific input features (Qwater, Qgas, BHP, WHP, WHT, Tsep, Psep, Choke_in) and the target output value (Qoil). For example, you can ask about the meaning or significance of these variables, their units of measurement, or any other related information. Please note that this AI model is not designed to answer questions unrelated to these values.\n\n" + input | |
| response = openai.Completion.create( | |
| engine="text-davinci-003", | |
| prompt=prompt, | |
| temperature=0.5, | |
| max_tokens=1000 | |
| ) | |
| return response.choices[0].text.strip() | |
| iface = gr.Interface( | |
| fn=chatbot, | |
| inputs="text", | |
| outputs="text", | |
| theme = gr.themes.Monochrome( | |
| primary_hue="blue", | |
| secondary_hue="blue", | |
| neutral_hue="blue", | |
| ), | |
| title="Oil Flow GPT 3.5 AI Chatbot", | |
| description="""Ask questions about the input features and target output values related to oil production. | |
| Not sure what to ask? Try questions like these: | |
| - "What is Qoil?" | |
| - "How can oil flow be increased?" | |
| - "Why is oil flow a good use case for Random Forest? | |
| <br> | |
| <br>Go back to: <a href="https://aitechproducts.com/oilflow.html">Oil Flow Production & Optimization Application</a>""", | |
| layout="vertical", | |
| inputs_css_class="custom-input-class", | |
| outputs_css_class="custom-output-class", | |
| examples=None, | |
| output_width="100%", | |
| output_height=400, | |
| css=""" | |
| .custom-input-class { | |
| /* Custom input component styles */ | |
| } | |
| .custom-output-class { | |
| /* Custom output component styles */ | |
| } | |
| .gradio-interface input[type="submit"] { | |
| background: linear-gradient(45deg, #FF0000, #FF4500); | |
| color: #FFFFFF; | |
| } | |
| /* Other custom CSS rules */ | |
| """ | |
| ) | |
| iface.launch(auth=(os.environ['USERNAME1'],os.environ['PASSWORD1'])) | |