File size: 2,429 Bytes
0387210
cd46058
 
4b158b4
cd46058
 
 
 
4b158b4
cd46058
 
0387210
 
 
 
 
4b158b4
cd46058
0387210
4b158b4
cd46058
 
 
4b158b4
cd46058
 
 
 
4b158b4
cd46058
 
4b158b4
cd46058
 
4b158b4
cd46058
 
4b158b4
 
0387210
 
 
 
 
 
f2e7cc9
0387210
 
 
 
 
cd46058
0387210
cd46058
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4b158b4
 
 
0387210
 
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import openai
import time
import yaml
import gradio as gr
import os
import argparse
import random
from chatbot import ChatBot

# MARKDOWN
MARKDOWN = """
# Coffee-Gym
Welcome to the COFFEE-GYM demo page! 

## DS-Coder-7B-PPO-CoffeeEval
You can try using the COFFEE-GYM feedback model (DS-Coder-7B-PPO-CoffeeEval) to get feedback on your code.

## Prompt template
To use the DS-Coder-7B-PPO-CoffeeEvall, you can follow the prompt template below:

~~~json
Problem Description:
{problem}

Incorrect Code:
```python
{code}
```

Please generate feedback for the wrong code.
~~~

## Response
The chatbot will provide feedback on the incorrect code by analyzing the problem description, input, output, and the buggy solution provided in the prompt. You can interact with the chatbot to get immediate feedback, regenerate responses, and clear the chat history.

Feel free to explore and make the most out of COFFEE-GYM!
"""




# get arguments from command line
def get_args():
    parser = argparse.ArgumentParser()
    parser.add_argument("--model_name", type=str, default="Team-Coffee-Gym/DS-Coder-7B-PPO-CoffeeEval", help="Model name to use for the chatbot.")
    parser.add_argument("--url", type=str, default="https://critic.jp.ngrok.io/v1", help="URL to use for the chatbot.")
    args = parser.parse_args()  
    return args


def main(args):
    
    chatbot = ChatBot(model_name=args.model_name, url=args.url)
    
    with gr.Blocks() as app:
        ##### Playground #####
        gr.Markdown(MARKDOWN)
        
        chat_history = gr.Chatbot(show_copy_button=True)     
        input_text = gr.Textbox(label="Enter your prompt and click 'Send'", placeholder="Type your message...")
        send_button = gr.Button("Send", elem_id="send-btn")
        
        with gr.Row():
            regenerate_button = gr.Button("Regenerate")
            clear_button = gr.Button("Clear")

        send_button.click(
            fn=chatbot.chat, 
            inputs=[chat_history, input_text], 
            outputs=chat_history
        )
        regenerate_button.click(
            fn=chatbot.regenerate, 
            inputs=[chat_history, input_text], 
            outputs=chat_history
        )

        clear_button.click(
            fn=chatbot.clear_chat, 
            inputs=[], 
            outputs=chat_history
        )
            
    app.launch(share=True)


if __name__ == "__main__":
    args = get_args()
    main(args)