File size: 1,253 Bytes
829a7e4
 
 
 
 
 
 
 
 
 
 
 
2277b25
829a7e4
56c627d
829a7e4
2277b25
829a7e4
2277b25
829a7e4
 
56c627d
829a7e4
4a49d6f
829a7e4
 
 
 
 
 
56c627d
 
829a7e4
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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", prompt=cuda_codes, stop="###")

    system_message = response["choices"][0]["message"]
    hip_codes = system_message["content"]

    return hip_codes





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()