Spaces:
Sleeping
Sleeping
File size: 1,053 Bytes
f165bd0 |
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 |
import os
from meta_ai_api import MetaAI
import gradio as gr
# Initialization
ai = MetaAI()
start_sequence = "\nAI:"
restart_sequence = "\nHuman: "
prompt = "The following is a conversation with an AI assistant. The assistant is helpful, creative, clever, and very friendly.\n\nHuman: Hello, who are you?\nAI: I am an AI created by MetaAI. How can I help you today?\nHuman: "
def metaai_create(prompt):
response = ai.prompt(message=prompt)
return response['message']
def chatgpt_clone(input, history):
history = history or []
s = list(sum(history, ()))
s.append(input)
inp = ' '.join(s)
output = metaai_create(inp)
history.append((input, output))
return history, history
block = gr.Blocks()
with block:
gr.Markdown("""<h1><center>Llama 3 Cloud </center></h1>
""")
chatbot = gr.Chatbot()
message = gr.Textbox(placeholder=prompt)
state = gr.State()
submit = gr.Button("SEND")
submit.click(chatgpt_clone, inputs=[message, state], outputs=[chatbot, state])
block.launch(debug = True)
|