mrolando commited on
Commit
3b6ecf3
·
1 Parent(s): 782d6d8

fixed interface

Browse files
Files changed (2) hide show
  1. Iso_Logotipo_Ceibal.png +0 -0
  2. app.py +30 -18
Iso_Logotipo_Ceibal.png ADDED
app.py CHANGED
@@ -5,6 +5,10 @@ from dotenv import load_dotenv
5
 
6
  # Load environment variables from the .env file de forma local
7
  load_dotenv()
 
 
 
 
8
 
9
 
10
 
@@ -40,20 +44,8 @@ import openai
40
 
41
  openai.api_key = os.environ['OPENAI_API_KEY']
42
 
43
- # response = openai.ChatCompletion.create(
44
- # model="gpt-3.5-turbo",
45
- # messages=[],
46
- # temperature=0.5,
47
- # max_tokens=256
48
- # )
49
- # def format_chat_prompt(message, chat_history, instruction):
50
- # prompt = f"System:{instruction}"
51
- # for turn in chat_history:
52
- # user_message, bot_message = turn
53
- # prompt = f"{prompt}\nUser: {user_message}\nAssistant: {bot_message}"
54
- # prompt = f"{prompt}\nUser: {message}\nAssistant:"
55
- # return prompt
56
-
57
 
58
  def add_new_message(message,chat_history):
59
  new_chat = []
@@ -100,12 +92,32 @@ def respond(message, chat_history):
100
  # acc_text = ""
101
 
102
  with gr.Blocks() as demo:
103
- chatbot = gr.Chatbot(height=240) #just to fit the notebook
104
- msg = gr.Textbox(label="Prompt")
105
- btn = gr.Button("Submit")
106
- clear = gr.ClearButton(components=[msg, chatbot], value="Clear console")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
 
108
  btn.click(respond, inputs=[msg, chatbot], outputs=[msg, chatbot])
109
  msg.submit(respond, inputs=[msg, chatbot], outputs=[msg, chatbot]) #Press enter to submit
 
110
 
111
  demo.launch()
 
5
 
6
  # Load environment variables from the .env file de forma local
7
  load_dotenv()
8
+ import base64
9
+
10
+ with open("Iso_Logotipo_Ceibal.png", "rb") as image_file:
11
+ encoded_image = base64.b64encode(image_file.read()).decode()
12
 
13
 
14
 
 
44
 
45
  openai.api_key = os.environ['OPENAI_API_KEY']
46
 
47
+ def clear_chat(message, chat_history):
48
+ return "", []
 
 
 
 
 
 
 
 
 
 
 
 
49
 
50
  def add_new_message(message,chat_history):
51
  new_chat = []
 
92
  # acc_text = ""
93
 
94
  with gr.Blocks() as demo:
95
+ gr.Markdown("""
96
+ <center>
97
+ <h1>
98
+ Uso de AI para un chatbot.
99
+ </h1>
100
+ <img src='data:image/jpg;base64,{}' width=200px>
101
+ <h3>
102
+ Con este espacio podrás hablar en formato conversación con ChatGTP!
103
+ </h3>
104
+ </center>
105
+ """.format(encoded_image))
106
+ with gr.Row():
107
+ chatbot = gr.Chatbot() #just to fit the notebook
108
+ with gr.Row():
109
+ with gr.Row():
110
+ with gr.Column(scale=4):
111
+ msg = gr.Textbox(label="Texto de entrada")
112
+ with gr.Column(scale=1):
113
+ btn = gr.Button("Enviar")
114
+ clear = gr.ClearButton(components=[msg, chatbot], value="Borrar chat")
115
+
116
+
117
+
118
 
119
  btn.click(respond, inputs=[msg, chatbot], outputs=[msg, chatbot])
120
  msg.submit(respond, inputs=[msg, chatbot], outputs=[msg, chatbot]) #Press enter to submit
121
+ clear.click(clear_chat,inputs=[msg, chatbot], outputs=[msg, chatbot])
122
 
123
  demo.launch()