llama3cloud / app.py
syaikhipin's picture
Create app.py
f165bd0 verified
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)