HipifyPlus / app.py
jozzy's picture
Update app.py
657a460
raw
history blame
1.25 kB
import os
import gradio as gr
import openai
openai.api_key = os.environ['OPENAI_API_KEY']
user_db = {os.environ['username1']: os.environ['password1'], os.environ['username2']: os.environ['password2'], os.environ['username3']: os.environ['password3']}
def textGPT(text):
messages = [{"role": "system", "content": 'You are a coding assistant.'}]
cuda_codes = "Translate this CUDA code into HIP code:\n" + text + "\n\n###"
messages.append({"role": "user", "content": cuda_codes})
response = openai.Completion.create(model="davinci:ft-zhaoyi-2023-06-21-07-18-01", messages=messages, stop="###")
system_message = response["choices"][0]["message"]
hip_codes = system_message["content"]
return chats
text = gr.Interface(fn=textGPT, inputs="text", outputs="text")
demo = gr.TabbedInterface([text], [ "HipifyPlus"])
if __name__ == "__main__":
demo.launch(enable_queue=False, auth=lambda u, p: user_db.get(u) == p,
auth_message="This is not designed to be used publicly as it links to a personal openAI API. However, you can copy my code and create your own multi-functional ChatGPT with your unique ID and password by utilizing the 'Repository secrets' feature in huggingface.")
#demo.launch()