Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from meta_ai_api import MetaAI
|
| 3 |
+
import gradio as gr
|
| 4 |
+
|
| 5 |
+
# Initialization
|
| 6 |
+
ai = MetaAI()
|
| 7 |
+
|
| 8 |
+
start_sequence = "\nAI:"
|
| 9 |
+
restart_sequence = "\nHuman: "
|
| 10 |
+
|
| 11 |
+
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: "
|
| 12 |
+
|
| 13 |
+
def metaai_create(prompt):
|
| 14 |
+
response = ai.prompt(message=prompt)
|
| 15 |
+
return response['message']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def chatgpt_clone(input, history):
|
| 19 |
+
history = history or []
|
| 20 |
+
s = list(sum(history, ()))
|
| 21 |
+
s.append(input)
|
| 22 |
+
inp = ' '.join(s)
|
| 23 |
+
output = metaai_create(inp)
|
| 24 |
+
history.append((input, output))
|
| 25 |
+
return history, history
|
| 26 |
+
|
| 27 |
+
block = gr.Blocks()
|
| 28 |
+
|
| 29 |
+
with block:
|
| 30 |
+
gr.Markdown("""<h1><center>Llama 3 Cloud </center></h1>
|
| 31 |
+
""")
|
| 32 |
+
chatbot = gr.Chatbot()
|
| 33 |
+
message = gr.Textbox(placeholder=prompt)
|
| 34 |
+
state = gr.State()
|
| 35 |
+
submit = gr.Button("SEND")
|
| 36 |
+
submit.click(chatgpt_clone, inputs=[message, state], outputs=[chatbot, state])
|
| 37 |
+
|
| 38 |
+
block.launch(debug = True)
|